use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class ContainerTransactionNode method endElement.
@Override
public boolean endElement(XMLElement element) {
boolean doneWithNode = super.endElement(element);
if (doneWithNode) {
ContainerTransaction ct = new ContainerTransaction(trans_attribute, description);
for (Iterator methodsIterator = methods.iterator(); methodsIterator.hasNext(); ) {
MethodDescriptor md = (MethodDescriptor) methodsIterator.next();
EjbBundleDescriptorImpl bundle = (EjbBundleDescriptorImpl) getParentNode().getDescriptor();
EjbDescriptor ejb = bundle.getEjbByName(md.getEjbName(), true);
ejb.getMethodContainerTransactions().put(md, ct);
}
}
return doneWithNode;
}
use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class ASEjbJarPublicID method check.
/**
* Ejb PUBLIC identifier test
* The ejb deployment descriptor has PUBLIC identifier with a PubidLiteral
* of "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
*
* @param descriptor the Ejb deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(EjbDescriptor descriptor) {
// EXCEPTION as descriptor.getDocType() returns null. Also how to differnetiate between sun-ejb-jar or ejb-jar DocType
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (!getVerifierContext().getisXMLBasedOnSchema()) {
try {
String[] acceptablePubidLiterals = { DTDRegistry.SUN_EJBJAR_200_DTD_PUBLIC_ID, DTDRegistry.SUN_EJBJAR_210_DTD_PUBLIC_ID };
String[] acceptableURLs = { DTDRegistry.SUN_EJBJAR_200_DTD_SYSTEM_ID, DTDRegistry.SUN_EJBJAR_210_DTD_SYSTEM_ID };
boolean foundDOCTYPE = false, foundPubid = false, foundURL = false;
EjbBundleDescriptorImpl ejbBundleDesc = descriptor.getEjbBundleDescriptor();
EjbBundleRuntimeNode ejbBundleRuntimeNode = new EjbBundleRuntimeNode(ejbBundleDesc);
String s = ejbBundleRuntimeNode.getDocType();
if (s != null) {
if (s.indexOf("DOCTYPE") > -1)
foundDOCTYPE = true;
if (foundDOCTYPE) {
for (int i = 0; i < acceptablePubidLiterals.length; i++) {
if (s.indexOf(acceptablePubidLiterals[i]) > -1) {
foundPubid = true;
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1", "PASSED [AS-EJB ] : The Sun deployment descriptor has the proper PubidLiteral: {0}", new Object[] { acceptablePubidLiterals[i] }));
}
// check if the URLs match as well
if (s.indexOf(acceptableURLs[i]) > -1) {
foundURL = true;
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed2", "PASSED [AS-EJB] : The Sun deployment descriptor has the proper URL corresponding the the PubIdLiteral: {0}", new Object[] { acceptableURLs[i] }));
}
}
}
}
if (!foundDOCTYPE) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed1", "FAILED [AS-EJB] : No document type declaration found in the deployment descriptor for {0}", new Object[] { descriptor.getName() }));
} else if (!foundPubid) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed2", "FAILED [AS-EJB ejb] : The deployment descriptor for {0} does not have an expected PubidLiteral ", new Object[] { descriptor.getName() }));
} else if (!foundURL) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed", "The deployment descriptor {0} doesnot have the right URL corresponding to the PubIdLiteral", new Object[] { descriptor.getName() }));
}
} catch (Exception ex) {
result.failed(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
}
} else {
// NOT APPLICABLE
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT-APPLICABLE: No DOCTYPE found for [ {0} ]", new Object[] { descriptor.getName() }));
}
return result;
}
use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class EjbCheckMgrImpl method check.
/**
* Check Ejb for spec. conformance
*
* @param descriptor Ejb descriptor
*/
public void check(Descriptor descriptor) throws Exception {
// run persistence tests first.
checkPersistenceUnits(EjbBundleDescriptorImpl.class.cast(descriptor));
// an EjbBundleDescriptor can have an WebServicesDescriptor
checkWebServices(descriptor);
// an EjbBundleDescriptor can have WebService References
checkWebServicesClient(descriptor);
if (verifierFrameworkContext.isPartition() && !verifierFrameworkContext.isEjb())
return;
EjbBundleDescriptorImpl bundleDescriptor = (EjbBundleDescriptorImpl) descriptor;
setDescClassLoader(bundleDescriptor);
// an ejb-ref is unresolved etc.
try {
EjbBundleValidator validator = new EjbBundleValidator();
validator.accept(bundleDescriptor);
} catch (Exception e) {
}
// initialize JDOC if bundle has CMP's
if (bundleDescriptor.containsCMPEntity()) {
try {
// See bug #6274161. We now pass an additional boolean
// to indicate whether we are in portable or AS mode.
jdc.init(bundleDescriptor, context.getClassLoader(), getAbstractArchiveUri(bundleDescriptor), verifierFrameworkContext.isPortabilityMode());
} catch (Throwable ex) {
context.setJDOException(ex);
}
}
// set the JDO Codegenerator into the context
context.setJDOCodeGenerator(jdc);
// run the ParseDD test
if (bundleDescriptor.getSpecVersion().compareTo("2.1") < 0) {
// NOI18N
EjbDeploymentDescriptorFile ddf = new EjbDeploymentDescriptorFile();
File file = new File(getAbstractArchiveUri(bundleDescriptor), ddf.getDeploymentDescriptorPath());
FileInputStream is = new FileInputStream(file);
try {
if (is != null) {
Result result = new ParseDD().validateEJBDescriptor(is);
result.setComponentName(new File(bundleDescriptor.getModuleDescriptor().getArchiveUri()).getName());
setModuleName(result);
verifierFrameworkContext.getResultManager().add(result);
}
} finally {
try {
if (is != null) {
is.close();
}
} catch (Exception e) {
}
}
}
for (Iterator itr = bundleDescriptor.getEjbs().iterator(); itr.hasNext(); ) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
super.check(ejbDescriptor);
}
if (bundleDescriptor.containsCMPEntity() && context.getJDOException() == null) {
jdc.cleanup();
context.setJDOCodeGenerator(null);
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class EjbCheckMgrImpl method checkWebServicesClient.
protected void checkWebServicesClient(Descriptor descriptor) throws Exception {
if (verifierFrameworkContext.isPartition() && !verifierFrameworkContext.isWebServicesClient())
return;
EjbBundleDescriptorImpl desc = (EjbBundleDescriptorImpl) descriptor;
WebServiceClientCheckMgrImpl webServiceClientCheckMgr = new WebServiceClientCheckMgrImpl(verifierFrameworkContext);
if (desc.hasWebServiceClients()) {
Set ejbdescs = desc.getEjbs();
Iterator ejbIt = ejbdescs.iterator();
while (ejbIt.hasNext()) {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbIt.next();
context.setEjbDescriptorForServiceRef(ejbDesc);
Set serviceRefDescriptors = ejbDesc.getServiceReferenceDescriptors();
Iterator it = serviceRefDescriptors.iterator();
while (it.hasNext()) {
webServiceClientCheckMgr.setVerifierContext(context);
webServiceClientCheckMgr.check((ServiceReferenceDescriptor) it.next());
}
}
context.setEjbDescriptorForServiceRef(null);
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class UniqueAbstractSchemaName method check.
/**
* The abstract schema name for every CMP bean within a jar file should be unique.
*
* @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 oneFailed = false;
String abstractSchema = null;
if (descriptor instanceof EjbEntityDescriptor) {
if (((EjbEntityDescriptor) descriptor).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) {
if (((EjbCMPEntityDescriptor) descriptor).getCMPVersion() == EjbCMPEntityDescriptor.CMP_2_x) {
abstractSchema = ((EjbCMPEntityDescriptor) descriptor).getAbstractSchemaName();
if (abstractSchema == null) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.failed(smh.getLocalString(getClass().getName() + ".failed2", "No Abstract Schema Name specified for a CMP 2.0 Entity Bean {0} ", new Object[] { descriptor.getName() }));
return result;
}
}
}
if (abstractSchema == null) {
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "This test is only for CMP 2.0 beans. Abstract Schema Names should be unique within an ejb JAR file."));
return result;
}
EjbBundleDescriptorImpl bundle = descriptor.getEjbBundleDescriptor();
Iterator iterator = (bundle.getEjbs()).iterator();
Vector<String> schemaNames = new Vector<String>();
while (iterator.hasNext()) {
EjbDescriptor entity = (EjbDescriptor) iterator.next();
if (entity instanceof EjbEntityDescriptor) {
if (!entity.equals(descriptor)) {
if (((EjbEntityDescriptor) entity).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) {
schemaNames.addElement(((EjbCMPEntityDescriptor) entity).getAbstractSchemaName());
}
}
}
}
for (int i = 0; i < schemaNames.size(); i++) {
if (abstractSchema.equals(schemaNames.elementAt(i))) {
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Abstract Schema Names should be unique within an ejb JAR file. Abstract Schema Name [ {0} ] is not unique.", new Object[] { abstractSchema }));
oneFailed = true;
}
}
if (oneFailed == false) {
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED : Abstract Schema Names for all beans within the ejb JAR file are unique."));
} else
result.setStatus(Result.FAILED);
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "This test is only for CMP 2.0 beans. Abstract Schema Names should be unique within an ejb JAR file."));
}
return result;
}
Aggregations