/** * Checks whether two methods that might have been loaded by * different class loaders are equal. * @param compareDeclaringClass if true, declaring class will * be considered as part of equality test. */ private boolean methodsEqual(MethodDescriptor m1, Method m2, boolean compareDeclaringClass) { Method m = m1.getMethod(parentDesc); return methodsEqual(m, m2, compareDeclaringClass); }
private MethodDescriptor processTimeoutMethod(EjbDescriptor ejb, MethodDescriptor timeoutMethodDescOrig, AnnotationTypesProvider provider, Class ejbClass) throws ClassNotFoundException { Method m = timeoutMethodDescOrig.getDeclaredMethod(ejb); if (m == null) { // In case deployment descriptor didn't specify "javax.ejb.Timer" // as the method-params, and we were not relying on it before, // check explicitly for a method with "javax.ejb.Timer" param type. Class[] params = new Class[1]; if (provider!=null) { params[0] = provider.getType("javax.ejb.Timer"); } else { throw new RuntimeException("Cannot find AnnotationTypesProvider named 'EJB'"); } m = timeoutMethodDescOrig.getDeclaredMethod(ejb, params); } if (m == null) { throw new RuntimeException("Class " + ejbClass.getName() + " does not define timeout method " + timeoutMethodDescOrig.getFormattedString()); } return new MethodDescriptor(m, MethodDescriptor.EJB_BEAN); } }
if (getStyle() == 1) { // STYLE 1 for (Iterator itr = allMethods.iterator(); itr.hasNext();) { MethodDescriptor next = (MethodDescriptor) itr.next(); if (this.getEjbName() != null && this.getEjbName().length() > 0) { next.setEjbName(ejbDescriptor.getName()); if (!next.isExact()) { if (this.getDescription() != null && this.getDescription().length() > 0) { next.setDescription(this.getDescription()); if (getEjbClassSymbol()==null) { v.addElement(next); } else if (this.getEjbClassSymbol().equals(next.getEjbClassSymbol())) { v.addElement(next); } else if (this.getParameterClassNames() == null) { // STYLE 2 v.addAll(this.getMethodDescriptorsOfName(this.getName(), allMethods)); } else { // STYLE 3, but maybe not exact if (getEjbClassSymbol()==null) { v.addAll(this.getMethodDescriptorsOfNameAndParameters(this.getName(), this.getParameterClassNames(), allMethods)); } else { v.addElement(this); // this must be exact
public String getFormattedString() { return this.getName() + this.getPrettyParameterString(); }
/** Returns true if I have enough information to specifiy a unique method * on an ejb's home or remote interface unambiguously. */ public boolean isExact() { if (isExact) { return true; } boolean isExactName = !this.getName().equals(ALL_METHODS); boolean hasMethodIntf = getEjbClassSymbol()!=null; boolean hasParamsListed = (this.getParameterClassNames() != null); return isExactName && hasMethodIntf && hasParamsListed; }
private MethodDescriptor getMethodDescriptor(AccessibleObject o, Class managedBeanClass) { MethodDescriptor mDesc = null; if (o instanceof Method) { mDesc = new MethodDescriptor((Method)o); } else if (o instanceof Constructor) { Class[] ctorParamTypes = ((Constructor)o).getParameterTypes(); String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes); // MethodDescriptor.EJB_BEAN is just a tag, not to add a new one mDesc = new MethodDescriptor(managedBeanClass.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN); } return mDesc; }
String mthdName = md.getName(); String mthdIntf = md.getEjbClassSymbol(); String mthdParams[] = md.getStyle() == 3 ? md.getParameterClassNames() : null; Method mthd = md.getMethod(eDescriptor); String mthdIntf = md.getEjbClassSymbol(); md.getName(), md.getParameterClassNames()});
public Method getDeclaredMethod(Class declaringClass) { try { return TypeUtil.getDeclaredMethod(declaringClass, declaringClass.getClassLoader(), getName(), getJavaParameterClassNames()); } catch(Exception e) { _logger.log(Level.SEVERE,"enterprise.deployment.backend.methodClassLoadFailure",new Object[]{declaringClass}); return null; } }
/** * <p> * @return the style level of this method descriptors. According to the J2EE spec, methods * can be described byt using style 1, style 2 or style 3 xml tags. * </p> */ public int getStyle() { if ( (getName().equals(ALL_METHODS)) ) { return 1; } if (getParameterClassNames()==null) return 2; return 3; }
private Set getMethodDescriptorsOfName(String name, Collection methodDescriptors) { Set set = new HashSet(); for (Iterator itr = methodDescriptors.iterator(); itr.hasNext();) { MethodDescriptor next = (MethodDescriptor) itr.next(); next.setEjbName(getEjbName()); if (name.equals(next.getName())) { if (getEjbClassSymbol()==null) { set.add(next); } else if (getEjbClassSymbol().equals(next.getEjbClassSymbol())) { set.add(next); } } } return set; }
/** Equlity iff the parameter names match and the name matches.*/ public boolean equals(Object other) { if (other instanceof MethodDescriptor) { MethodDescriptor otherMethodDescriptor = (MethodDescriptor) other; if (otherMethodDescriptor.getName().equals(getName()) && stringArrayEquals(otherMethodDescriptor.getParameterClassNames(), getParameterClassNames())) { if (getEjbClassSymbol()!=null && otherMethodDescriptor.getEjbClassSymbol()!=null) { return getEjbClassSymbol().equals(otherMethodDescriptor.getEjbClassSymbol()); } // if the ejb class symbol is not defined in both descriptor, we consider // the method described being the same. return true; } } return false; }
private Set getMethodDescriptorsOfNameAndParameters(String name, String[] parameterArray, Collection methodDescriptors) { Set methods = new HashSet(); for (Iterator itr = getMethodDescriptorsOfName(name, methodDescriptors).iterator(); itr.hasNext();) { MethodDescriptor next = (MethodDescriptor) itr.next(); next.setEjbName(getEjbName()); if (stringArrayEquals(parameterArray, next.getParameterClassNames())) { methods.add(next); } } return methods; }
@Override public MethodDescriptor getDescriptor() { if (descriptor == null) descriptor = new MethodDescriptor(); return descriptor; }
/** * @return the MethodDescriptor for the given Method object */ public MethodDescriptor getBusinessMethodDescriptorFor(Method m, String methodIntf) { Set businessMethodDescriptors = getBusinessMethodDescriptors(); MethodDescriptor methodDesc = new MethodDescriptor(m, methodIntf); MethodDescriptor match = null; for(Object next : businessMethodDescriptors) { MethodDescriptor nextMethodDesc = (MethodDescriptor) next; if( nextMethodDesc.equals(methodDesc)) { match = nextMethodDesc; break; } } return match; }
/** Indicates if a method descriptor implies the other one*/ public boolean implies(Object other) { if (other != null && other instanceof MethodDescriptor) { MethodDescriptor otherMethodDescriptor = (MethodDescriptor) other; if (getName().equals(ALL_METHODS) || getName().equals(otherMethodDescriptor.getName())) { if (getParameterClassNames() == null || stringArrayEquals(getParameterClassNames(), otherMethodDescriptor.getParameterClassNames())) { return true; } } } return false; }
Method method = ejbTimeoutMethodDesc.getMethod(ejbDescriptor); processEjbTimeoutMethod(method); Method method = schd.getTimeoutMethod().getMethod(ejbDescriptor); if (method == null) { "ejb.no_timeout_method", "Class {0} does not define timeout method {1}", ejbClass.getName(), schd.getTimeoutMethod().getFormattedString()));
/** * @param methodDesc * @param ejbDesc * @return whether the given methodDesc has permission defined in ejbDesc */ private boolean hasMethodPermissionsFromDD(MethodDescriptor methodDesc, EjbDescriptor ejbDesc) { HashMap methodPermissionsFromDD = ejbDesc.getMethodPermissionsFromDD(); if (methodPermissionsFromDD != null) { Set allMethods = ejbDesc.getMethodDescriptors(); String ejbClassSymbol = methodDesc.getEjbClassSymbol(); for (Object mdObjsObj : methodPermissionsFromDD.values()) { List mdObjs = (List)mdObjsObj; for (Object mdObj : mdObjs) { MethodDescriptor md = (MethodDescriptor)mdObj; for (Object style3MdObj : md.doStyleConversion(ejbDesc, allMethods)) { MethodDescriptor style3Md = (MethodDescriptor)style3MdObj; if (methodDesc.equals(style3Md)) { return true; } } } } } return false; }
provider.getType("javax.ejb.TimedObject").isAssignableFrom(ejbClass) ) { MethodDescriptor timedObjectMethod = new MethodDescriptor("ejbTimeout", "TimedObject timeout method", new String[] {"javax.ejb.Timer"}, } catch (Exception e) { throw new RuntimeException(ejb.getName() + ": Invalid schedule " + "defined on method " + sd.getTimeoutMethod().getFormattedString() + ": " + e.getMessage());
public Method getDeclaredMethod(EjbDescriptor ejbDescriptor) { ClassLoader classloader = ejbDescriptor.getEjbBundleDescriptor().getClassLoader(); try { Class[] parameterTypes = TypeUtil.paramClassNamesToTypes( getJavaParameterClassNames(), classloader); return getDeclaredMethod(ejbDescriptor, parameterTypes); } catch(Exception e) { _logger.log(Level.SEVERE,"enterprise.deployment.backend.methodClassLoadFailure",new Object[]{e, ejbDescriptor}); } return null; }