use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ApplicationArchivist method readModulesDescriptors.
/**
* read the modules deployment descriptor from this application object using the passed archive
*
* @param app
* application containing the list of modules.
* @param appArchive
* containing the sub modules files.
* @return true if everything went fine
*/
public boolean readModulesDescriptors(Application app, ReadableArchive appArchive) throws IOException, SAXParseException {
List<ModuleDescriptor> nonexistentModules = new ArrayList<ModuleDescriptor>();
List<ModuleDescriptor> sortedModules = sortModules(app);
for (ModuleDescriptor aModule : sortedModules) {
if (aModule.getArchiveUri().indexOf(" ") != -1) {
throw new IllegalArgumentException(localStrings.getLocalString("enterprise.deployment.unsupporturi", "Unsupported module URI {0}, it contains space(s)", new Object[] { aModule.getArchiveUri() }));
}
if (getDefaultLogger().isLoggable(FINE)) {
getDefaultLogger().fine("Opening sub-module " + aModule);
}
BundleDescriptor descriptor = null;
Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType());
newArchivist.initializeContext(this);
newArchivist.setRuntimeXMLValidation(this.getRuntimeXMLValidation());
newArchivist.setRuntimeXMLValidationLevel(this.getRuntimeXMLValidationLevel());
newArchivist.setAnnotationProcessingRequested(annotationProcessingRequested);
ReadableArchive embeddedArchive = appArchive.getSubArchive(aModule.getArchiveUri());
if (embeddedArchive == null) {
throw new IllegalArgumentException(localStrings.getLocalString("enterprise.deployment.nosuchmodule", "Could not find sub module [{0}] as defined in application.xml", new Object[] { aModule.getArchiveUri() }));
}
embeddedArchive.setParentArchive(appArchive);
setExtensionArchivistForSubArchivist(habitat, embeddedArchive, aModule, app, newArchivist);
if (aModule.getAlternateDescriptor() != null) {
// The module use alternate deployement descriptor, ignore the DDs in the archive.
InputStream is = appArchive.getEntry(aModule.getAlternateDescriptor());
DeploymentDescriptorFile ddFile = newArchivist.getStandardDDFile();
ddFile.setXMLValidation(newArchivist.getXMLValidation());
ddFile.setXMLValidationLevel(newArchivist.getXMLValidationLevel());
if (appArchive.getURI() != null) {
ddFile.setErrorReportingString(appArchive.getURI().getSchemeSpecificPart());
}
descriptor = (BundleDescriptor) ddFile.read(is);
descriptor.setApplication(app);
is.close();
// TODO : JD need to be revisited for EAR files with Alternative descriptors, what does
// it mean for sub components.
Map<ExtensionsArchivist, RootDeploymentDescriptor> extensions = new HashMap<ExtensionsArchivist, RootDeploymentDescriptor>();
List<ExtensionsArchivist> extensionsArchivists = newArchivist.getExtensionArchivists();
if (extensionsArchivists != null) {
for (ExtensionsArchivist extension : extensionsArchivists) {
Object rdd = extension.open(newArchivist, embeddedArchive, descriptor);
if (rdd instanceof RootDeploymentDescriptor) {
extensions.put(extension, (RootDeploymentDescriptor) rdd);
}
}
}
newArchivist.postStandardDDsRead(descriptor, embeddedArchive, extensions);
newArchivist.readAnnotations(embeddedArchive, descriptor, extensions);
newArchivist.postAnnotationProcess(descriptor, embeddedArchive);
newArchivist.postOpen(descriptor, embeddedArchive);
// Now reads the runtime deployment descriptor...
if (isHandlingRuntimeInfo()) {
readAlternativeRuntimeDescriptor(appArchive, embeddedArchive, newArchivist, descriptor, aModule.getAlternateDescriptor());
// Read extensions runtime deployment descriptors if any
for (Map.Entry<ExtensionsArchivist, RootDeploymentDescriptor> extension : extensions.entrySet()) {
// After standard DD and annotations are processed we should have an extension descriptor now
if (extension.getValue() != null) {
extension.getKey().readRuntimeDeploymentDescriptor(newArchivist, embeddedArchive, extension.getValue());
}
}
}
} else {
// Open the subarchive to get the deployment descriptor...
descriptor = newArchivist.open(embeddedArchive, app);
}
embeddedArchive.close();
if (descriptor != null) {
descriptor.getModuleDescriptor().setArchiveUri(aModule.getArchiveUri());
aModule.setModuleName(descriptor.getModuleDescriptor().getModuleName());
aModule.setDescriptor(descriptor);
descriptor.setApplication(app);
aModule.setManifest(newArchivist.getManifest());
// For optional application.xml case, set the context root as module name for web modules
if (!appArchive.exists("META-INF/application.xml")) {
if (aModule.getModuleType().equals(DOLUtils.warType())) {
WebBundleDescriptor wbd = (WebBundleDescriptor) descriptor;
if (wbd.getContextRoot() != null && !wbd.getContextRoot().equals("")) {
aModule.setContextRoot(wbd.getContextRoot());
} else {
aModule.setContextRoot(aModule.getModuleName());
}
}
}
} else {
// Display a message only if we had a handle on the sub archive
return false;
}
}
// don't get processed further
for (ModuleDescriptor nonexistentModule : nonexistentModules) {
app.removeModule(nonexistentModule);
}
return true;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class MessageDestinationRefNode method setElementValue.
@Override
public void setElementValue(XMLElement element, String value) {
if (TagNames.MESSAGE_DESTINATION_REFERENCE_NAME.equals(element.getQName())) {
XMLNode parentNode = getParentNode();
Object parentDesc = null;
// in case of web
if (parentNode.getDescriptor() instanceof WebBundleDescriptor) {
parentDesc = parentNode.getDescriptor();
// in case of appclient and ejb
} else {
parentDesc = getParentNode().getDescriptor();
}
if (parentDesc instanceof MessageDestinationReferenceContainer) {
try {
descriptor = ((MessageDestinationReferenceContainer) parentDesc).getMessageDestinationReferenceByName(value);
} catch (IllegalArgumentException iae) {
DOLUtils.getDefaultLogger().warning(iae.getMessage());
}
}
} else
super.setElementValue(element, value);
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class Verifier method verifyArchive.
private void verifyArchive() {
if (!getApplication().isVirtual()) {
// don't run app tests for standalone module
runVerifier(new ApplicationVerifier(verifierFrameworkContext));
}
for (Iterator itr = getApplication().getBundleDescriptors(EjbBundleDescriptor.class).iterator(); itr.hasNext(); ) {
EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
runVerifier(new EjbVerifier(verifierFrameworkContext, ejbd));
}
for (Iterator itr = getApplication().getBundleDescriptors(WebBundleDescriptor.class).iterator(); itr.hasNext(); ) {
WebBundleDescriptor webd = (WebBundleDescriptor) itr.next();
runVerifier(new WebVerifier(verifierFrameworkContext, webd));
}
for (Iterator itr = getApplication().getBundleDescriptors(ApplicationClientDescriptor.class).iterator(); itr.hasNext(); ) {
ApplicationClientDescriptor appClientDescriptor = (ApplicationClientDescriptor) itr.next();
runVerifier(new AppClientVerifier(verifierFrameworkContext, appClientDescriptor));
}
for (Iterator itr = getApplication().getBundleDescriptors(ConnectorDescriptor.class).iterator(); itr.hasNext(); ) {
ConnectorDescriptor cond = (ConnectorDescriptor) itr.next();
runVerifier(new ConnectorVerifier(verifierFrameworkContext, cond));
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class EjbDeployer method load.
@Override
public EjbApplication load(EjbContainerStarter containerStarter, DeploymentContext dc) {
super.load(containerStarter, dc);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer Loading app from: " + dc.getSourceDir());
}
// Register the EjbSecurityComponentInvocationHandler
RegisteredComponentInvocationHandler handler = habitat.getService(RegisteredComponentInvocationHandler.class, "ejbSecurityCIH");
handler.register();
EjbBundleDescriptorImpl ejbBundle = dc.getModuleMetaData(EjbBundleDescriptorImpl.class);
if (ejbBundle == null) {
throw new RuntimeException("Unable to load EJB module. DeploymentContext does not contain any EJB " + " Check archive to ensure correct packaging for " + dc.getSourceDir());
}
ejbBundle.setClassLoader(dc.getClassLoader());
ejbBundle.setupDataStructuresForRuntime();
if (ejbBundle.containsCMPEntity()) {
CMPService cmpService = cmpServiceProvider.get();
if (cmpService == null) {
throw new RuntimeException("CMP Module is not available");
} else if (!cmpService.isReady()) {
throw new RuntimeException("CMP Module is not initialized");
}
}
EjbApplication ejbApp = new EjbApplication(ejbBundle, dc, dc.getClassLoader(), habitat);
try {
compEnvManager.bindToComponentNamespace(ejbBundle);
// If within .war, also bind dependencies declared by web application. There is
// a single naming environment for the entire .war module. Yhis is necessary
// in order for eagerly initialized ejb components to have visibility to all the
// dependencies b/c the web container does not bind to the component namespace until
// its start phase, which comes after the ejb start phase.
Object rootDesc = ejbBundle.getModuleDescriptor().getDescriptor();
if ((rootDesc != ejbBundle) && (rootDesc instanceof WebBundleDescriptor)) {
WebBundleDescriptor webBundle = (WebBundleDescriptor) rootDesc;
compEnvManager.bindToComponentNamespace(webBundle);
}
} catch (Exception e) {
throw new RuntimeException("Exception registering ejb bundle level resources", e);
}
ejbApp.loadContainers(dc);
return ejbApp;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ServletWebServiceDelegate method postInit.
@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
String servletName = "unknown";
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
WebBundleDescriptor webBundle = null;
if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
webBundle = ((WebBundleDescriptor) jndiNameEnv);
} else {
throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
servletName = servletConfig.getServletName();
WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
if (webComponent != null) {
WebServicesDescriptor webServices = webBundle.getWebServices();
Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
// Only 1 endpoint per servlet is supported, even though
// data structure implies otherwise.
endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
registerEndpoint(classLoader);
// security
if (secServ != null) {
SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
if (securityHandlerDelegate != null) {
rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
// need to invoke the endpoint lifecylcle
endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
}
}
} else {
throw new ServletException(servletName + " not found");
}
} catch (Throwable t) {
String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
logger.log(Level.WARNING, msg, t);
throw new ServletException(t);
}
}
Aggregations