cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/ejb WSIFPort_EJB.java

[email protected]
Newsgroups gmane.comp.apache.webservices.wsif.devel
Message-ID <[email protected]>
owenb       2003/06/11 06:51:26

  Modified:    java/src/org/apache/wsif/providers/ejb WSIFPort_EJB.java
  Log:
  Performance improvement - work out the remote interface class locally rather than using EJBMetaData
  
  Revision  Changes    Path
  1.14      +22 -9     xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFPort_EJB.java
  
  Index: WSIFPort_EJB.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFPort_EJB.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- WSIFPort_EJB.java	6 Jun 2003 13:58:54 -0000	1.13
  +++ WSIFPort_EJB.java	11 Jun 2003 13:51:26 -0000	1.14
  @@ -60,9 +60,7 @@
   import java.io.IOException;
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
  -import java.io.Serializable;
   import java.lang.reflect.Method;
  -import java.rmi.RemoteException;
   import java.util.HashMap;
   import java.util.Hashtable;
   import java.util.Iterator;
  @@ -276,16 +274,31 @@
                       throw new WSIFException("Unable to get EJBObject class, fieldEjbHome is null");
                   }
   
  +                // Get the Class of the remote interface by looking for the return type of the
  +                // create method. In general only stateless session beans are supported as
  +                // web services so look for a no args create method.
                   try {
  -                    ejbObjectClass =
  -                        fieldEjbHome.getEJBMetaData().getRemoteInterfaceClass();
  -                } catch (RemoteException re) {
  -                    Trc.ignoredException(re);
  +                	Method createMethod = fieldEjbHome.getClass().getDeclaredMethod("create", null);
  +                	ejbObjectClass = createMethod.getReturnType();
  +                } catch (NoSuchMethodException nsme) {
  +                    Trc.ignoredException(nsme);
  +                } catch (SecurityException se) {
  +                	Trc.ignoredException(se);
                   }
  -                // As a last resort, attempt to create the EJBObject and get its class
  +
  +                // If it's a stateful session bean it may not have a no args create method.
  +                // Since WSIF allows you to call a create method on the home interface for
  +                // such a bean, look for any create method - they should all return the same
  +                // object
                   if (ejbObjectClass == null) {
  -                	getEjbObject();
  -                	ejbObjectClass = fieldEjbObject.getClass();
  +                	Method[] methods = fieldEjbHome.getClass().getDeclaredMethods();
  +                	for (int m = 0; m < methods.length; m++) {
  +                		Method temp = methods[m];
  +                		if (temp.getName().equals("create")) {
  +                			ejbObjectClass = temp.getReturnType();
  +                			break;
  +                		}
  +                	}
                   }
               }
           }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.