Fields Summary |
---|
private static final String[] | entityBeanHomeMethodsDisallowed |
private static final String[] | entityBeanRemoteMethodsDisallowed |
private static final String[] | entityBeanLocalHomeMethodsDisallowed |
private static final String[] | entityBeanLocalInterfaceMethodsDisallowed |
private static final String[] | sessionBeanMethodsDisallowed |
private static final String[] | sessionLocalBeanMethodsDisallowed |
private static Map | disallowedMethodsPerInterface |
Methods Summary |
---|
private static void | addAllInterfaceMethodsIn(java.util.Collection methods, java.lang.Class c)
methods.addAll(Arrays.asList(c.getMethods()));
|
private static java.util.Collection | extractDisallowedMethodsFor(java.lang.Class interfaceType, java.lang.String[] methodNames)
Vector v = new Vector();
// no disallowed methods for this interface
if (methodNames.length==0)
return v;
Method methods[] = interfaceType.getMethods();
for (int i=0; i<methods.length; i++) {
// all methods of the interface are disallowed
if (methodNames[0].equals("*"))
v.addElement(methods[i]);
else if (Arrays.binarySearch(methodNames, methods[i].getName())>=0)
v.addElement(methods[i]);
}
return v;
|
protected static java.util.Map | getDisallowedMethodsNames()
if (disallowedMethodsPerInterface==null) {
disallowedMethodsPerInterface = new Hashtable();
disallowedMethodsPerInterface.put(javax.ejb.EJBHome.class, entityBeanHomeMethodsDisallowed);
disallowedMethodsPerInterface.put(javax.ejb.EJBObject.class, entityBeanRemoteMethodsDisallowed);
disallowedMethodsPerInterface.put(javax.ejb.EJBLocalHome.class, entityBeanLocalHomeMethodsDisallowed);
disallowedMethodsPerInterface.put(javax.ejb.EJBLocalObject.class, entityBeanLocalInterfaceMethodsDisallowed);
}
return disallowedMethodsPerInterface;
|
private static java.lang.String[] | getDisallowedMethodsNamesFor(java.lang.Class interfaceType)
return (String[]) getDisallowedMethodsNames().get(interfaceType);
|
private static java.util.Collection | getDisallowedTransactionMethodsFor(java.lang.Class interfaceType)
return extractDisallowedMethodsFor(interfaceType, getDisallowedMethodsNamesFor(interfaceType));
|
public static java.util.Vector | getMethodsFor(EjbDescriptor ejbDescriptor, java.lang.ClassLoader classLoader)
Vector methods = new Vector();
if (ejbDescriptor.isRemoteInterfacesSupported()) {
addAllInterfaceMethodsIn(methods, classLoader.loadClass(ejbDescriptor.getHomeClassName()));
addAllInterfaceMethodsIn(methods, classLoader.loadClass(ejbDescriptor.getRemoteClassName()));
}
if (ejbDescriptor.isRemoteBusinessInterfacesSupported()) {
for(String intf : ejbDescriptor.getRemoteBusinessClassNames()) {
addAllInterfaceMethodsIn(methods, classLoader.loadClass(intf));
}
}
if (ejbDescriptor.isLocalInterfacesSupported()) {
addAllInterfaceMethodsIn(methods, classLoader.loadClass(ejbDescriptor.getLocalHomeClassName()));
addAllInterfaceMethodsIn(methods, classLoader.loadClass(ejbDescriptor.getLocalClassName()));
}
if (ejbDescriptor.isLocalBusinessInterfacesSupported()) {
for(String intf : ejbDescriptor.getLocalBusinessClassNames()) {
addAllInterfaceMethodsIn(methods, classLoader.loadClass(intf));
}
}
if (ejbDescriptor.hasWebServiceEndpointInterface()) {
addAllInterfaceMethodsIn(methods, classLoader.loadClass(ejbDescriptor.getWebServiceEndpointInterfaceName()));
}
return methods;
|
public static java.util.Vector | getPossibleCmpCmrFields(java.lang.ClassLoader cl, java.lang.String className)
Vector fieldDescriptors = new Vector();
Class theClass = cl.loadClass(className);
// Start with all *public* methods
Method[] methods = theClass.getMethods();
// Find all accessors that could be cmp fields. This list
// will contain all cmr field accessors as well, since there
// is no good way to distinguish between the two purely based
// on method signature.
for(int mIndex = 0; mIndex < methods.length; mIndex++) {
Method next = methods[mIndex];
String nextName = next.getName();
int nextModifiers = next.getModifiers();
if( Modifier.isAbstract(nextModifiers) ) {
if( nextName.startsWith("get") &&
nextName.length() > 3 ) {
String field =
nextName.substring(3,4).toLowerCase() +
nextName.substring(4);
fieldDescriptors.add(new FieldDescriptor(field));
}
}
}
return fieldDescriptors;
|
private static java.util.Collection | getTransactionMethodsFor(java.lang.ClassLoader loader, java.lang.String interfaceName, java.util.Collection disallowedMethods)
Class clazz = loader.loadClass(interfaceName);
return getTransactionMethodsFor(clazz, disallowedMethods);
|
private static java.util.Collection | getTransactionMethodsFor(java.lang.Class interfaceImpl, java.util.Collection disallowedMethods)
Vector v = new Vector(Arrays.asList(interfaceImpl.getMethods()));
v.removeAll(disallowedMethods);
return v;
|
private static java.util.Collection | getTransactionMethodsFor(java.lang.Class interfaceType, java.lang.Class interfaceImpl)
Collection disallowedTransactionMethods = getDisallowedTransactionMethodsFor(interfaceType);
return getTransactionMethodsFor(interfaceImpl, disallowedTransactionMethods);
|
public static java.util.Collection | getTransactionalMethodsFor(EjbDescriptor ejbDescriptor, java.lang.ClassLoader loader)
// only set if desc is a stateful session bean. NOTE that
// !statefulSessionBean does not imply stateless session bean
boolean statefulSessionBean = false;
Vector methods = new Vector();
if (ejbDescriptor instanceof EjbSessionDescriptor) {
statefulSessionBean =
((EjbSessionDescriptor) ejbDescriptor).isStateful();
// Session Beans
if (ejbDescriptor.isRemoteInterfacesSupported()) {
Collection disallowedMethods = extractDisallowedMethodsFor(javax.ejb.EJBObject.class, sessionBeanMethodsDisallowed);
Collection potentials = getTransactionMethodsFor(loader, ejbDescriptor.getRemoteClassName() , disallowedMethods);
transformAndAdd(potentials, MethodDescriptor.EJB_REMOTE, methods);
}
if( ejbDescriptor.isRemoteBusinessInterfacesSupported() ) {
for(String intfName :
ejbDescriptor.getRemoteBusinessClassNames() ) {
Class businessIntf = loader.loadClass(intfName);
Method[] busIntfMethods = businessIntf.getMethods();
for (Method next : busIntfMethods ) {
methods.add(new MethodDescriptor
(next, MethodDescriptor.EJB_REMOTE));
}
}
}
if (ejbDescriptor.isLocalInterfacesSupported()) {
Collection disallowedMethods = extractDisallowedMethodsFor(javax.ejb.EJBLocalObject.class, sessionLocalBeanMethodsDisallowed);
Collection potentials = getTransactionMethodsFor(loader, ejbDescriptor.getLocalClassName() , disallowedMethods);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCAL, methods);
}
if( ejbDescriptor.isLocalBusinessInterfacesSupported() ) {
for(String intfName :
ejbDescriptor.getLocalBusinessClassNames() ) {
Class businessIntf = loader.loadClass(intfName);
Method[] busIntfMethods = businessIntf.getMethods();
for (Method next : busIntfMethods ) {
methods.add(new MethodDescriptor
(next, MethodDescriptor.EJB_LOCAL));
}
}
}
if (ejbDescriptor.hasWebServiceEndpointInterface()) {
Class webServiceClass = loader.loadClass
(ejbDescriptor.getWebServiceEndpointInterfaceName());
Method[] webMethods = webServiceClass.getMethods();
for (int i=0;i<webMethods.length;i++) {
methods.add(new MethodDescriptor(webMethods[i],
MethodDescriptor.EJB_WEB_SERVICE));
}
}
} else {
// entity beans local interfaces
String homeIntf = ejbDescriptor.getHomeClassName();
if (homeIntf!=null) {
Class home = loader.loadClass(homeIntf);
Collection potentials = getTransactionMethodsFor(javax.ejb.EJBHome.class, home);
transformAndAdd(potentials, MethodDescriptor.EJB_HOME, methods);
String remoteIntf = ejbDescriptor.getRemoteClassName();
Class remote = loader.loadClass(remoteIntf);
potentials = getTransactionMethodsFor(javax.ejb.EJBObject.class, remote);
transformAndAdd(potentials, MethodDescriptor.EJB_REMOTE, methods);
}
// enity beans remote interfaces
String localHomeIntf = ejbDescriptor.getLocalHomeClassName();
if (localHomeIntf!=null) {
Class home = loader.loadClass(localHomeIntf);
Collection potentials = getTransactionMethodsFor(javax.ejb.EJBLocalHome.class, home);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCALHOME, methods);
String remoteIntf = ejbDescriptor.getLocalClassName();
Class remote = loader.loadClass(remoteIntf);
potentials = getTransactionMethodsFor(javax.ejb.EJBLocalObject.class, remote);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCAL, methods);
}
}
if( !statefulSessionBean ) {
Class ejbClass = loader.loadClass(ejbDescriptor.getEjbClassName());
if( ejbDescriptor.isTimedObject() ) {
methods.add(ejbDescriptor.getEjbTimeoutMethod());
}
}
return methods;
|
private static void | transformAndAdd(java.util.Collection methods, java.lang.String methodIntf, java.util.Vector globalList)utiliy method to transform our collection of Method objects into
MethodDescriptor objects and add them to our global list of
elligible methods
for (Iterator itr = methods.iterator();itr.hasNext();) {
Method m = (Method) itr.next();
MethodDescriptor md = new MethodDescriptor(m, methodIntf);
globalList.add(md);
}
|