use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method processDescriptorForRAReferences.
private void processDescriptorForRAReferences(Application app, Descriptor descriptor, String moduleName) {
if (descriptor instanceof JndiNameEnvironment) {
processDescriptorForRAReferences(app, moduleName, (JndiNameEnvironment) descriptor);
}
// ejb descriptors
if (descriptor instanceof EjbBundleDescriptor) {
EjbBundleDescriptor ejbDesc = (EjbBundleDescriptor) descriptor;
Set<? extends EjbDescriptor> ejbDescriptors = ejbDesc.getEjbs();
for (EjbDescriptor ejbDescriptor : ejbDescriptors) {
processDescriptorForRAReferences(app, moduleName, ejbDescriptor);
if (ejbDescriptor instanceof EjbMessageBeanDescriptor) {
EjbMessageBeanDescriptor messageBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor;
String raMid = messageBeanDesc.getResourceAdapterMid();
// there seem to be applications that do not specify ra-mid
if (raMid != null) {
app.addResourceAdapter(raMid);
}
}
}
// ejb interceptors
Set<EjbInterceptor> ejbInterceptors = ejbDesc.getInterceptors();
for (EjbInterceptor ejbInterceptor : ejbInterceptors) {
processDescriptorForRAReferences(app, moduleName, ejbInterceptor);
}
}
if (descriptor instanceof BundleDescriptor) {
// managed bean descriptors
Set<ManagedBeanDescriptor> managedBeanDescriptors = ((BundleDescriptor) descriptor).getManagedBeans();
for (ManagedBeanDescriptor mbd : managedBeanDescriptors) {
processDescriptorForRAReferences(app, moduleName, mbd);
}
}
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class ComponentValidator method getManagedBeanMap.
/**
* Get a map of bean class to managed bean descriptor for the managed beans
* defined within the current module.
*/
private Map<String, ManagedBeanDescriptor> getManagedBeanMap() {
BundleDescriptor thisBundle = getBundleDescriptor();
Set<ManagedBeanDescriptor> managedBeans = new HashSet<ManagedBeanDescriptor>();
// for managed beans
if (thisBundle != null) {
Object desc = thisBundle.getModuleDescriptor().getDescriptor();
if (desc instanceof BundleDescriptor) {
managedBeans = ((BundleDescriptor) desc).getManagedBeans();
}
}
Map<String, ManagedBeanDescriptor> managedBeanMap = new HashMap<String, ManagedBeanDescriptor>();
for (ManagedBeanDescriptor managedBean : managedBeans) {
String beanClassName = managedBean.getBeanClassName();
managedBeanMap.put(beanClassName, managedBean);
}
return managedBeanMap;
}
use of com.sun.enterprise.deployment.BundleDescriptor 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.BundleDescriptor in project Payara by payara.
the class ApplicationFactory method openArchive.
/**
* Open a jar file and return an application object for the modules contained
* in the archive. If the archive is a standalone module, this API will
* create an empty application and add the standalone module to it
*
* @param appName the application moduleID
* @param archivist to use to open the archive file
* @param in the input archive
* @param handleRuntimeInfo set to true to read configuration deployment descriptors
* @return the application object
*/
public Application openArchive(String appName, Archivist archivist, ReadableArchive in, boolean handleRuntimeInfo) throws IOException, SAXParseException {
// we are not reading the runtime deployment descriptor now...
archivist.setHandleRuntimeInfo(false);
BundleDescriptor descriptor = archivist.open(in);
Application application;
if (descriptor instanceof Application) {
application = (Application) descriptor;
application.setAppName(appName);
application.setRegistrationName(appName);
} else {
if (descriptor == null) {
logger.log(Level.SEVERE, localStrings.getLocalString("enterprise.deployment.cannotreadDDs", "Cannot read the Deployment Descriptors for module {0}", new Object[] { in.getURI() }));
return null;
}
ModuleDescriptor newModule = archivist.createModuleDescriptor(descriptor);
newModule.setArchiveUri(in.getURI().getSchemeSpecificPart());
application = Application.createVirtualApplication(appName, newModule);
}
// now read the runtime deployment descriptor
if (handleRuntimeInfo) {
// now read the runtime deployment descriptors from the original jar file
archivist.setHandleRuntimeInfo(true);
archivist.readRuntimeDeploymentDescriptor(in, (BundleDescriptor) descriptor);
}
// validate
if (application != null) {
application.setClassLoader(archivist.getClassLoader());
application.visit((ApplicationVisitor) new ApplicationValidator());
}
return application;
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class ApplicationFactory method createApplicationFromStandardDD.
/**
* This method creates an Application object from reading the
* standard deployment descriptor.
* @param archive the archive for the application
*/
public Application createApplicationFromStandardDD(ReadableArchive archive, String archiveType) throws IOException, SAXParseException {
Archivist archivist = archivistFactory.getArchivist(archiveType, null);
String xmlValidationLevel = dasConfig.getDeployXmlValidation();
archivist.setXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setXMLValidation(false);
}
BundleDescriptor desc = archivist.readStandardDeploymentDescriptor(archive);
Application application = null;
if (desc instanceof Application) {
application = (Application) desc;
} else {
ModuleDescriptor newModule = archivist.createModuleDescriptor(desc);
newModule.setArchiveUri(archive.getURI().getSchemeSpecificPart());
String moduleName = newModule.getModuleName();
application = Application.createVirtualApplication(moduleName, newModule);
}
return application;
}
Aggregations