use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class EjbLinkElement method check.
/**
* The value of the ejb-link element is the ejb-name of an enterprise
* bean in the same J2EE Application archive.
*
* @param descriptor the Web Application deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(WebBundleDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean resolved = false;
boolean oneFailed = false;
int na = 0;
// The value of the ejb-link element must be the ejb-name of an enterprise
// bean in the same J2EE Application archive.
String applicationName = null;
if (!descriptor.getEjbReferenceDescriptors().isEmpty()) {
for (Iterator itr = descriptor.getEjbReferenceDescriptors().iterator(); itr.hasNext(); ) {
EjbReferenceDescriptor nextEjbReference = (EjbReferenceDescriptor) itr.next();
if (nextEjbReference.isLinked()) {
String ejb_link = nextEjbReference.getLinkName();
ejb_link = ejb_link.substring(ejb_link.indexOf("#") + 1);
// get the application descriptor and check all ejb-jars in the application
try {
Application application = descriptor.getApplication();
applicationName = application.getName();
// File tmpFile = new File(System.getProperty("java.io.tmpdir"));
// tmpFile = new File(tmpFile, Verifier.TMPFILENAME + ".tmp");
// iterate through the ejb jars in this J2EE Application
Set ejbBundles = application.getBundleDescriptors(EjbBundleDescriptor.class);
Iterator ejbBundlesIterator = ejbBundles.iterator();
EjbBundleDescriptor ejbBundle = null;
while (ejbBundlesIterator.hasNext()) {
ejbBundle = (EjbBundleDescriptor) ejbBundlesIterator.next();
// }
for (Iterator itr2 = ejbBundle.getEjbs().iterator(); itr2.hasNext(); ) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) itr2.next();
if (ejbDescriptor.getName().equals(ejb_link)) {
resolved = true;
logger.log(Level.FINE, getClass().getName() + ".passed", new Object[] { ejb_link, ejbDescriptor.getName() });
result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "ejb-link [ {0} ] found same value as EJB [ {1} ]", new Object[] { ejb_link, ejbDescriptor.getName() }));
break;
}
}
}
} catch (Exception e) {
logger.log(Level.FINE, "com.sun.enterprise.tools.verifier.testsprint {0}", new Object[] { "[" + getClass() + "] Error: " + e.getMessage() });
if (!oneFailed) {
oneFailed = true;
}
}
// resolved the last ejb-link okay
if (!resolved) {
if (!oneFailed) {
oneFailed = true;
}
result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: No EJB matching [ {0} ] found within [ {1} ] ear file.", new Object[] { ejb_link, applicationName }));
} else {
// clear the resolved flag for the next ejb-link
resolved = false;
}
} else {
// Cannot get the link name of an ejb reference referring
// to an external bean
result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
result.addNaDetails(smh.getLocalString(getClass().getName() + ".notApplicable1", "Not Applicable: Cannot verify the existance of an ejb reference [ {0} ] to external bean within different .ear file.", new Object[] { nextEjbReference.getName() }));
na++;
}
}
if (oneFailed) {
result.setStatus(result.FAILED);
} else if (na == descriptor.getEjbReferenceDescriptors().size()) {
result.setStatus(result.NOT_APPLICABLE);
} else {
result.setStatus(result.PASSED);
}
// tmpFile.delete();
return result;
} else {
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no ejb references to other beans within this web archive [ {0} ]", new Object[] { descriptor.getName() }));
}
return result;
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class StaticRmiStubGenerator method ejbc.
/**
* Generates and compiles the necessary impl classes, stubs and skels.
*
* <pre>
*
* This method makes the following assumptions:
* - the deployment descriptor xmls are registered with Config
* - the class paths are registered with Config
*
* @@@
* In case of re-deployment, the following steps should happen before:
* - rename the src dir from previous deployment (ex. /app/pet-old)
* - rename the stubs dir from previous deployment (ex. /stub/pet-old)
* - explode the ear file (ex. /app/petstore)
* - register the deployment descriptor xml with config
* - register the class path with config
*
* After successful completion of this method, the old src and sutbs
* directories may be deleted.
*
* </pre>
*
* @param deploymentCtx
*
* @return array of the client stubs files as zip items or empty array
*/
public void ejbc(DeploymentContext deploymentCtx) throws Exception {
// stubs dir for the current deployment
File stubsDir = deploymentCtx.getScratchDir("ejb");
String explodedDir = deploymentCtx.getSource().getURI().getSchemeSpecificPart();
// deployment descriptor object representation
EjbBundleDescriptor ejbBundle = deploymentCtx.getModuleMetaData(EjbBundleDescriptor.class);
long startTime = now();
// class path to be used for this application during javac & rmic
String classPath = deploymentCtx.getTransientAppMetaData(CMPDeployer.MODULE_CLASSPATH, String.class);
// Warning: A class loader is passed in while constructing the
// application object
final ClassLoader jcl = ejbBundle.getClassLoader();
// stubs dir is used as repository for code generator
final String gnrtrTMP = stubsDir.getCanonicalPath();
// ---- EJB DEPLOYMENT DESCRIPTORS -------------------------------
// The main use-case we want to support is the one where existing
// stand-alone java clients that access ejbs hosted in our appserver
// directly through CosNaming need the generated stubs. We don't want to
// force them to run rmic themselves so it's better for them
// just to tell us during the deployment of an ejb client app
// or ejb app that we should run rmic and put the stubs in the
// client.jar. Turning on the deployment-time rmic flag ONLY
// controls the generation of rmic stubs. Dynamic stubs will be used
// in the server, in the Application Client container, and in
// stand-alone clients that instantiate our naming provider.
progress(localStrings.getStringWithDefault("generator.processing_beans", "Processing beans..."));
// ---- END OF EJB DEPLOYMENT DESCRIPTORS --------------------------
// ---- RMIC ALL STUB CLASSES --------------------------------------
Set<String> allStubClasses = new HashSet<String>();
// stubs classes for ejbs within this app that need rmic
Set<String> ejbStubClasses = getStubClasses(jcl, ejbBundle);
allStubClasses.addAll(ejbStubClasses);
// Compile and RMIC all Stubs
rmic(classPath, allStubClasses, stubsDir, gnrtrTMP, explodedDir);
_logger.log(Level.INFO, "[RMIC] RMIC execution time: " + (now() - startTime) + " msec");
// ---- END OF RMIC ALL STUB CLASSES -------------------------------
// Create list of all server files and client files
List<String> allClientFiles = new ArrayList<String>();
// assemble the client files
addGeneratedFiles(allStubClasses, allClientFiles, stubsDir);
ClientArtifactsManager cArtifactsManager = ClientArtifactsManager.get(deploymentCtx);
for (String file : allClientFiles) {
cArtifactsManager.add(stubsDir, new File(file));
}
_logger.log(Level.INFO, "ejbc.end", deploymentCtx.getModuleMetaData(Application.class).getRegistrationName());
_logger.log(Level.INFO, "[RMIC] Total time: " + (now() - startTime) + " msec");
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class EjbRelationshipRoleNode method getEjbBundleDescriptor.
private EjbBundleDescriptor getEjbBundleDescriptor() {
XMLNode parent = getParentNode();
Object parentDesc = parent.getDescriptor();
while (parent != null && !(parentDesc instanceof EjbBundleDescriptor)) {
parent = parent.getParentNode();
if (parent != null)
parentDesc = parent.getDescriptor();
}
if (parent != null) {
return (EjbBundleDescriptor) parentDesc;
} else {
throw new IllegalArgumentException("Cannot find bundle descriptor");
}
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class DefaultWebServiceLoginConfigNode method endElement.
@Override
public boolean endElement(XMLElement element) {
log.log(Level.FINEST, "End Element: {0}", element.getQName());
if (authMethod != null && element.getQName().equals(RuntimeTagNames.WEBSERVICE_DEFAULT_LOGIN_CONFIG)) {
EjbBundleDescriptor descriptor = (EjbBundleDescriptor) getParentNode().getDescriptor();
for (WebService wsDesc : descriptor.getWebServices().getWebServices()) {
for (WebServiceEndpoint endpoint : wsDesc.getEndpoints()) {
if (!endpoint.hasAuthMethod()) {
log.log(Level.FINE, "Default Login for Web Service Endpoint: {0}, Method {1}, Realm {2}", new Object[] { endpoint.getName(), authMethod, realm });
endpoint.setAuthMethod(authMethod);
endpoint.setRealm(realm);
}
}
}
}
return super.endElement(element);
}
use of com.sun.enterprise.deployment.EjbBundleDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method getJMSDestination.
/*
* Get JMS destination resource from application
*/
private JMSDestinationDefinitionDescriptor getJMSDestination(String logicalDestination, Application application) {
if (application == null) {
return null;
}
JMSDestinationDefinitionDescriptor destination = getJMSDestination(logicalDestination, application.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
Set<WebBundleDescriptor> webBundleDescriptors = application.getBundleDescriptors(WebBundleDescriptor.class);
for (WebBundleDescriptor webBundleDescriptor : webBundleDescriptors) {
destination = getJMSDestination(logicalDestination, webBundleDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
}
Set<EjbBundleDescriptor> ejbBundleDescriptors = application.getBundleDescriptors(EjbBundleDescriptor.class);
for (EjbBundleDescriptor ejbBundleDescriptor : ejbBundleDescriptors) {
destination = getJMSDestination(logicalDestination, ejbBundleDescriptor);
if (isValidDestination(destination)) {
return destination;
}
}
Set<ApplicationClientDescriptor> appClientDescriptors = application.getBundleDescriptors(ApplicationClientDescriptor.class);
for (ApplicationClientDescriptor appClientDescriptor : appClientDescriptors) {
destination = getJMSDestination(logicalDestination, appClientDescriptor.getResourceDescriptors(JavaEEResourceType.JMSDD));
if (isValidDestination(destination)) {
return destination;
}
}
return null;
}
Aggregations