User: reverbel
  Date: 01/11/21 04:43:03

  Modified:    iiop/src/main/org/jboss/iiop/rmi ContainerAnalysis.java
  Log:
  Analysis changed to look at inherited methods of remote interfaces
  (the IIOP container invoker needs to know about inherited methods).
  
  Bug fix: attribute detection now compares getter/setter method names.
  
  Revision  Changes    Path
  1.5       +32 -8     contrib/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java
  
  Index: ContainerAnalysis.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerAnalysis.java    2001/10/30 12:34:58     1.4
  +++ ContainerAnalysis.java    2001/11/21 12:43:03     1.5
  @@ -42,7 +42,7 @@
    *  Specification", version 1.1 (01-06-07).
    *      
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.4 $
  + *  @version $Revision: 1.5 $
    */
   public abstract class ContainerAnalysis
      extends ClassAnalysis
  @@ -366,7 +366,7 @@
   
         for (int i = 0; i < intfs.length; ++i) {
            if (cls.isInterface() &&
  -             java.rmi.RemoteException.class.isAssignableFrom(cls)) {
  +             java.rmi.Remote.class.isAssignableFrom(cls)) {
               // Ignore java.rmi.Remote for interfaces
               if (intfs[i] == java.rmi.Remote.class)
                  continue;
  @@ -392,8 +392,14 @@
       */
      protected void analyzeMethods()
      {
  -      //methods = cls.getMethods();
  -      methods = cls.getDeclaredMethods();
  +      // The dynamic stub and skeleton strategy generation mechanism
  +      // requires the inclusion of inherited methods in the analysis of
  +      // remote interfaces. To speed things up, inherited methods are
  +      // not considered in the analysis of a class or non-remote interface.
  +      if (cls.isInterface() && java.rmi.Remote.class.isAssignableFrom(cls))
  +         methods = cls.getMethods();
  +      else
  +         methods = cls.getDeclaredMethods();
         m_flags = new byte[methods.length];
         mutators = new int[methods.length];
    
  @@ -405,9 +411,11 @@
                      methods[i].getName() + "\".");
   
            if (isAccessor(methods[i]) && (m_flags[i]&M_READ) == 0) {
  +            String attrName = attributeReadName(methods[i].getName());
               Class iReturn = methods[i].getReturnType();
               for (int j = i+1; j < methods.length; ++j) {
  -               if (isMutator(methods[j]) && (m_flags[j]&M_WRITE) == 0) {
  +               if (isMutator(methods[j]) && (m_flags[j]&M_WRITE) == 0 &&
  +                   attrName.equals(attributeWriteName(methods[j].getName()))) {
                     Class[] jParams = methods[j].getParameterTypes();
                     if (jParams.length == 1 && jParams[0] == iReturn) {
                        m_flags[i] |= M_READ;
  @@ -418,9 +426,11 @@
                  }
               }
            } else if (isMutator(methods[i]) && (m_flags[i]&M_WRITE) == 0) {
  +            String attrName = attributeWriteName(methods[i].getName());
               Class[] iParams = methods[i].getParameterTypes();
               for (int j = i+1; j < methods.length; ++j) {
  -               if (isAccessor(methods[j]) && (m_flags[j]&M_READ) == 0) {
  +               if (isAccessor(methods[j]) && (m_flags[j]&M_READ) == 0 &&
  +                   attrName.equals(attributeReadName(methods[j].getName()))) {
                     Class jReturn = methods[j].getReturnType();
                     if (iParams.length == 1 && iParams[0] == jReturn) {
                        m_flags[i] |= M_WRITE;
  @@ -473,6 +483,20 @@
      }
   
      /**
  +    *  Convert an attribute write method name in Java format to
  +    *  an attribute name in Java format.
  +    */
  +   protected String attributeWriteName(String name)
  +   {
  +      if (name.startsWith("set"))
  +         name = name.substring(3);
  +      else
  +         throw new IllegalArgumentException("Not an accessor: " + name);
  +
  +      return name;
  +   }
  +
  +   /**
       *  Analyse constants.
       *  This will fill in the <code>constants</code> array.
       */
  @@ -531,8 +555,8 @@
   
         for (int i = 0; i < methods.length; ++i) {
   System.err.println("m_flags["+i+"]=" + m_flags[i]);
  -         if ((m_flags[i]&M_INHERITED) != 0)
  -            continue;
  +         //if ((m_flags[i]&M_INHERITED) != 0)
  +         //  continue;
   
            if ((m_flags[i] & (M_READ|M_READONLY)) != 0) {
               // Read method of an attribute.
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to