Methods Summary |
---|
public Result | check(EjbDescriptor descriptor)ContainerTransaction Style 3 - Each container transaction element consists
of a list of one or more method elements, and the trans-attribute element.
The container transaction element specifies that all the listed methods are
assigned the specified transaction attribute value.
Style 3:
EJBNAME
METHOD
PARAMETER_1
...
PARAMETER_N
This style is used to refer to a single method within a set of methods with
an overloaded name. The method must be one defined in the remote or home
interface of the specified enterprise bean. If there is also a container
transaction element that uses the Style 2 element for the method name, or
the Style 1 element for the bean, the value specified by the Style 3 element
takes precedence.
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
this.descriptor = descriptor;
if (!(descriptor instanceof EjbSessionDescriptor) &&
!(descriptor instanceof EjbEntityDescriptor)) {
result.notApplicable(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.ejb.homeintf.HomeMethodTest.notApplicable1",
"Test apply only to session or entity beans."));
return result;
}
// The method must be one defined in the remote, home or business interface of
// the specified enterprise bean.
if (!descriptor.getMethodContainerTransactions().isEmpty())
commonToAllInterfaces();
if(result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"Valid container transaction methods."));
}
return result;
|
private void | commonToAllInterfaces()Iterate over all the bean methods and check if they are present in any
of the bean's interfaces.
boolean isTimedObject=false;
try {
ClassLoader jcl = getVerifierContext().getClassLoader();
Class beanClass = Class.forName(descriptor.getEjbClassName(), false, jcl);
isTimedObject = javax.ejb.TimedObject.class.isAssignableFrom(beanClass);
} catch (ClassNotFoundException e) {} //continue
initializeMethods();
for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) {
MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS) ||
methodDescriptor.getParameterClassNames() == null) // style 1 and 2
continue;
if(isTimedObject &&
MethodDescriptor.EJB_BEAN.equals(methodDescriptor.getEjbClassSymbol()) &&
methodDescriptor.getName().equals("ejbTimeout")) {
String[] params=methodDescriptor.getJavaParameterClassNames();
if(params.length==1 && params[0].trim().equals("javax.ejb.Timer"))
continue;//found a match
}//if implements timer
Set<Method> methods = getAllInterfaceMethods(methodDescriptor);
if(!isMethodContained(methods, methodDescriptor)) { // report failure
String ejbClassSymbol = methodDescriptor.getEjbClassSymbol();
String intf = ejbClassSymbol;
if(ejbClassSymbol == null) {
intf = smh.getLocalString(getClass().getName() + ".msg", "any of bean");
} else if(ejbClassSymbol.equals(MethodDescriptor.EJB_REMOTE)) {
intf = "Remote or RemoteBusiness";
} else if(ejbClassSymbol.equals(MethodDescriptor.EJB_LOCAL)) {
intf = "Local or LocalBusiness";
}
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Container Transaction method name [ {0} ] not " +
"defined in [ {1} ] interface(s).",
new Object[] {methodDescriptor.getName(), intf}));
}
}
|
private java.util.Set | getAllInterfaceMethods(MethodDescriptor methodDescriptor)Collect all the methods the bean interfaces specified in methodDescriptor
Set<Method> methods = new HashSet<Method>();
String methodIntf = methodDescriptor.getEjbClassSymbol();
if((methodIntf == null)) {
methods.addAll(Arrays.asList(homeMethods));
methods.addAll(Arrays.asList(localHomeMethods));
methods.addAll(Arrays.asList(remoteMethods));
methods.addAll(Arrays.asList(localMethods));
methods.addAll(Arrays.asList(serviceMethods));
} else if(methodIntf.equals(MethodDescriptor.EJB_HOME)) {
methods.addAll(Arrays.asList(homeMethods));
} else if(methodIntf.equals(MethodDescriptor.EJB_LOCALHOME)) {
methods.addAll(Arrays.asList(localHomeMethods));
} else if(methodIntf.equals(MethodDescriptor.EJB_REMOTE)) {
methods.addAll(Arrays.asList(remoteMethods));
} else if(methodIntf.equals(MethodDescriptor.EJB_LOCAL)) {
methods.addAll(Arrays.asList(localMethods));
} else if(methodIntf.equals(MethodDescriptor.EJB_WEB_SERVICE)) {
methods.addAll(Arrays.asList(serviceMethods));
}
return methods;
|
private java.lang.reflect.Method[] | getBusinessMethods(java.util.Set classNames, java.lang.reflect.Method[] intfMethods)returns an array of business methods that are collected from set classNames
if(!classNames.isEmpty()) {
List<Method> methods = new ArrayList<Method>();
for (String clsName : classNames) {
Method[] methodArray = getMethods(clsName);
if(methodArray != null)
methods.addAll(Arrays.asList(methodArray));
}
if(intfMethods != null)
methods.addAll(Arrays.asList(intfMethods));
return methods.toArray(new Method[]{});
}
return intfMethods;
|
private java.lang.reflect.Method[] | getMethods(java.lang.String clsName)get all the methods defined in the given class clsName
if(clsName==null)
return new Method[]{};
ClassLoader jcl = getVerifierContext().getClassLoader();
try {
Class cls = Class.forName(clsName, false, jcl);
return cls.getMethods();
} catch (ClassNotFoundException e) {} // ignore and continue
return new Method[]{};
|
private void | initializeMethods()get methods from all of bean's interfaces
homeMethods = getMethods(descriptor.getHomeClassName());
localHomeMethods = getMethods(descriptor.getLocalHomeClassName());
remoteMethods = getMethods(descriptor.getRemoteClassName());
remoteMethods = getBusinessMethods(descriptor.getRemoteBusinessClassNames(),remoteMethods);
localMethods = getMethods(descriptor.getLocalClassName());
localMethods = getBusinessMethods(descriptor.getLocalBusinessClassNames(), localMethods);
serviceMethods = getMethods(descriptor.getWebServiceEndpointInterfaceName());
|
private boolean | isMethodContained(java.util.Set methods, MethodDescriptor methodDescriptor)returns true if methodDescriptor is contained in the set methods
boolean foundIt = false;
for (Method method : methods) {
if(method.getName().equals(methodDescriptor.getName()) &&
MethodUtils.stringArrayEquals(methodDescriptor.getParameterClassNames(),
(new MethodDescriptor(method)).getParameterClassNames())) {
foundIt = true;
break;
}
}
return foundIt;
|