use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class RemoteHomeInterfaceRmiIIOP method check.
/**
* Home Interface follows the standard rules for RMI-IIOP remote interfaces
* test.
*
* All enterprise beans home interface's must follow the standard rules
* for RMI-IIOP remote interfaces.
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor.getHomeClassName() == null || "".equals(descriptor.getHomeClassName())) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp", "Not Applicable because, EJB [ {0} ] has Local Interfaces only.", new Object[] { descriptor.getEjbClassName() }));
return result;
}
if ((descriptor instanceof EjbSessionDescriptor) || (descriptor instanceof EjbEntityDescriptor)) {
try {
ClassLoader jcl = getVerifierContext().getClassLoader();
Class c = Class.forName(descriptor.getHomeClassName(), false, jcl);
// remote interface must be defined as valid Rmi-IIOP remote interface
boolean isValidRmiIIOPInterface = false;
if (RmiIIOPUtils.isValidRmiIIOPInterface(c) && RmiIIOPUtils.isValidRmiIIOPInterfaceMethods(c)) {
isValidRmiIIOPInterface = true;
}
// remote interface must be defined as valid Rmi-IIOP remote interface
if (!isValidRmiIIOPInterface) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] is not defined as valid RMI-IIOP remote interface. All enterprise beans home interfaces must be defined as valid RMI-IIOP remote interface. [ {1} ] is not a valid remote home interface.", new Object[] { descriptor.getHomeClassName(), descriptor.getHomeClassName() }));
} else {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] properly declares the home interface as valid RMI-IIOP remote interface.", new Object[] { descriptor.getHomeClassName() }));
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { descriptor.getHomeClassName() }));
}
return result;
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean or {2} bean, but called with {3}.", new Object[] { getClass(), "Session", "Entity", descriptor.getName() }));
return result;
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class InterfaceClassExist method check.
/**
* Local Interface test.
* Verify that the bean remote or local interface class exist and is loadable.
*
* @param descriptor the Enterprise Java Bean deployment descriptor
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (!(descriptor instanceof EjbSessionDescriptor) && !(descriptor instanceof EjbEntityDescriptor)) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable1", "Test apply only to session or entity beans."));
return result;
}
if (getInterfaceName(descriptor) == null || "".equals(getInterfaceName(descriptor))) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable2", "Not Applicable because, EJB [ {0} ] does not have {1} Interface.", new Object[] { descriptor.getEjbClassName(), getInterfaceType() }));
return result;
}
// verify that the local or remote interface class exist and is loadable
try {
ClassLoader jcl = getVerifierContext().getClassLoader();
Class c = Class.forName(getClassName(descriptor), false, jcl);
if (!c.isInterface()) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.failed", "[ {0} ] is defined as a class. It should be an interface.", new Object[] { getClassName(descriptor) }));
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: " + getInterfaceType() + " interface [ {0} ] does not exist or is not loadable.", new Object[] { getClassName(descriptor) }));
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", getInterfaceType() + " interface [ {0} ] exist and is loadable.", new Object[] { getClassName(descriptor) }));
}
return result;
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class InterfacePublic method check.
/**
* Declare local and remote interfaces as public interfaces test.
* All enterprise bean local and/or interfaces must be declared as public.
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (!(descriptor instanceof EjbSessionDescriptor) && !(descriptor instanceof EjbEntityDescriptor)) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.homeintf.HomeMethodTest.notApplicable1", "Test apply only to session or entity beans."));
return result;
}
String assertionClass = "com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfacePublic";
for (String intfName : getInterfaceNames(descriptor)) {
try {
ClassLoader jcl = getVerifierContext().getClassLoader();
Class c = Class.forName(intfName, false, jcl);
// local and remote interface must be defined as public
if (!Modifier.isPublic(c.getModifiers())) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(assertionClass + ".failed", "Error: [ {0} ] is not defined as a public interface.", new Object[] { intfName }));
}
} catch (ClassNotFoundException e) {
// ignore as it will be caught in EjbArchiveClassesLoadable
logger.log(Level.FINER, e.getMessage(), e);
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(assertionClass + ".passed", "Valid public interface(s)."));
}
return result;
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class SessionBeanInterface method check.
/**
* Implements the SessionBean Interface test.
* All session Beans must implement, directly or indirectly, the SessionBean
* interface.
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbSessionDescriptor) {
try {
VerifierTestContext context = getVerifierContext();
ClassLoader jcl = context.getClassLoader();
Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
boolean validBean = false;
// walk up the class tree
do {
Class[] interfaces = c.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
logger.log(Level.FINE, getClass().getName() + ".debug1", new Object[] { interfaces[i].getName() });
if (interfaces[i].getName().equals("javax.ejb.SessionBean") && descriptor instanceof EjbSessionDescriptor) {
validBean = true;
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] properly implements the SessionBean interface.", new Object[] { descriptor.getEjbClassName() }));
break;
}
}
} while ((((c = c.getSuperclass()) != null) && (!validBean)));
if (!validBean) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] does not properly implement the SessionBean interface. All session Beans must implement the SessionBean interface. [ {1} ] is not a valid bean.", new Object[] { descriptor.getEjbClassName(), descriptor.getEjbClassName() }));
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failedException", "Error: [ {0} ] class not found.", new Object[] { descriptor.getEjbClassName() }));
}
return result;
} else {
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "[ {0} ] expected {1} bean, but called with {2} bean.", new Object[] { getClass(), "Session", "Entity" }));
return result;
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class TransactionDemarcationSessionSynchronizationInterface method check.
/**
* Optionally implemented SessionSynchronization interface transaction
* demarcation test.
* If an enterprise bean implements the javax.ejb.SessionSynchronization
* interface, the Application Assembler can specify only the following values
* for the transaction attributes of the bean's methods:
* Required
* RequiresNew
* Mandatory
*
* @param descriptor the Enterprise Java Bean deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFound = false;
if (descriptor instanceof EjbSessionDescriptor) {
try {
VerifierTestContext context = getVerifierContext();
ClassLoader jcl = context.getClassLoader();
Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
// walk up the class tree
do {
Class[] interfaces = c.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i].getName().equals("javax.ejb.SessionSynchronization")) {
oneFound = true;
break;
}
}
} while ((c = c.getSuperclass()) != null);
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failedException1", "Error: [ {0} ] class not found.", new Object[] { descriptor.getEjbClassName() }));
return result;
}
// Required, RequiresNew, Mandatory
if (oneFound) {
String transactionAttribute = "";
ContainerTransaction containerTransaction = null;
boolean oneFailed = false;
if (!descriptor.getMethodContainerTransactions().isEmpty()) {
for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements(); ) {
MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement();
containerTransaction = (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor);
if (!(containerTransaction != null && properAttribDefined(containerTransaction))) {
transactionAttribute = containerTransaction.getTransactionAttribute();
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid.", new Object[] { transactionAttribute, methodDescriptor.getName() }));
}
}
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "TransactionAttributes are defined properly for the bean"));
}
return result;
}
Aggregations