use of com.sun.enterprise.deployment.EjbSessionDescriptor in project Payara by payara.
the class SessionType method check.
/**
* Session Bean State management test (stateful/stateless).
* If the enterprise bean is a Session Bean, the Bean provider must use
* the "session-type" element to declare whether the session bean
* is stateful or stateless.
*
* @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) {
String stateType = ((EjbSessionDescriptor) descriptor).getSessionType();
if ((EjbSessionDescriptor.STATELESS.equals(stateType)) || (EjbSessionDescriptor.STATEFUL.equals(stateType))) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "[ {0} ] is valid stateType within bean [ {1} ].", new Object[] { stateType, descriptor.getName() }));
} else {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: [ {0} ] is not valid stateType within bean [ {1} ].", new Object[] { stateType, descriptor.getName() }));
}
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 com.sun.enterprise.deployment.EjbSessionDescriptor in project Payara by payara.
the class EjbHasLocalorRemoteorBothInterfaces method check.
/**
* Bean interface type test.
* The bean provider must provide either Local or Remote or Both 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 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 ((descriptor.getRemoteClassName() == null || "".equals(descriptor.getRemoteClassName())) && (descriptor.getLocalClassName() == null || "".equals(descriptor.getLocalClassName()))) {
if (implementsEndpoints(descriptor)) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.webservice.notapp", "Not Applicable because, EJB [ {0} ] implements a Service Endpoint Interface.", new Object[] { compName.toString() }));
return result;
} else {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Ejb [ {0} ] does not have local or remote interfaces", new Object[] { descriptor.getEjbClassName() }));
return result;
}
} else {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Ejb [ {0} ] does have valid local and/or remote interfaces", new Object[] { descriptor.getEjbClassName() }));
return result;
}
}
use of com.sun.enterprise.deployment.EjbSessionDescriptor in project Payara by payara.
the class EjbBeanType method check.
/**
* Bean Type Test.
* The bean provider must use the appropriate session or entity element
* to declare the bean type.
*
* @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)) {
try {
Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader());
boolean validBean = false;
// walk up the class tree (bug #4243606)
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.EntityBean") && (descriptor instanceof EjbEntityDescriptor)) {
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 {1}Bean interface.", new Object[] { descriptor.getEjbClassName(), "Entity" }));
break;
} else 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 {1}Bean interface.", new Object[] { descriptor.getEjbClassName(), "Session" }));
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} ] is not a valid bean. The bean provider must use the appropriate {1} or {2} element to declare the bean type.", new Object[] { descriptor.getEjbClassName(), "session", "entity" }));
}
} 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} ] not called with a Session or Entity Bean.", new Object[] { getClass() }));
return result;
}
}
use of com.sun.enterprise.deployment.EjbSessionDescriptor in project Payara by payara.
the class EjbDescriptorImpl method getLocalBusinessInterfaces.
/**
* Gets the local business interfaces of the EJB
*
* @return An iterator over the local business interfaces
*/
@Override
public Collection<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces() {
Set<BusinessInterfaceDescriptor<?>> localBusIntfs = new HashSet<BusinessInterfaceDescriptor<?>>();
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
Set<String> localNames = sessionDesc.getLocalBusinessClassNames();
// Include the no-interface Local view
if (sessionDesc.isLocalBean()) {
localNames.add(sessionDesc.getEjbClassName());
}
for (String local : localNames) {
try {
Class<?> localClass = sessionDesc.getEjbBundleDescriptor().getClassLoader().loadClass(local);
@SuppressWarnings({ "rawtypes", "unchecked" }) BusinessInterfaceDescriptor<?> busIntfDesc = new BusinessInterfaceDescriptorImpl(localClass);
localBusIntfs.add(busIntfDesc);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
}
}
return localBusIntfs;
}
use of com.sun.enterprise.deployment.EjbSessionDescriptor in project Payara by payara.
the class EjbDescriptorImpl method getRemoteBusinessInterfaces.
@Override
public Collection<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces() {
Set<BusinessInterfaceDescriptor<?>> remoteBusIntfs = new HashSet<BusinessInterfaceDescriptor<?>>();
if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
Set<String> remoteNames = sessionDesc.getRemoteBusinessClassNames();
for (String remote : remoteNames) {
try {
Class<?> remoteClass = sessionDesc.getEjbBundleDescriptor().getClassLoader().loadClass(remote);
@SuppressWarnings({ "rawtypes", "unchecked" }) BusinessInterfaceDescriptor<?> busIntfDesc = new BusinessInterfaceDescriptorImpl(remoteClass);
remoteBusIntfs.add(busIntfDesc);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
}
}
return remoteBusIntfs;
}
Aggregations