Search in sources :

Example 16 with WebBundleDescriptor

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;
}
Also used : DOLUtils.setExtensionArchivistForSubArchivist(com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist) HashMap(java.util.HashMap) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) DeploymentDescriptorFile(com.sun.enterprise.deployment.io.DeploymentDescriptorFile) ApplicationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile) ConfigurationDeploymentDescriptorFile(com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with WebBundleDescriptor

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);
}
Also used : MessageDestinationReferenceContainer(com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer) XMLNode(com.sun.enterprise.deployment.node.XMLNode) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 18 with WebBundleDescriptor

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));
    }
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AppClientVerifier(com.sun.enterprise.tools.verifier.appclient.AppClientVerifier) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebVerifier(com.sun.enterprise.tools.verifier.web.WebVerifier) ApplicationVerifier(com.sun.enterprise.tools.verifier.app.ApplicationVerifier) Iterator(java.util.Iterator) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbVerifier(com.sun.enterprise.tools.verifier.ejb.EjbVerifier) ConnectorVerifier(com.sun.enterprise.tools.verifier.connector.ConnectorVerifier) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor)

Example 19 with WebBundleDescriptor

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;
}
Also used : RegisteredComponentInvocationHandler(org.glassfish.api.invocation.RegisteredComponentInvocationHandler) CMPService(org.glassfish.ejb.spi.CMPService) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 20 with WebBundleDescriptor

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);
    }
}
Also used : WebServicesDescriptor(com.sun.enterprise.deployment.WebServicesDescriptor) WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) SystemHandlerDelegate(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) JAXRPCEndpointImpl(org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)

Aggregations

WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)47 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)14 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)10 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)7 Application (com.sun.enterprise.deployment.Application)6 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ArrayList (java.util.ArrayList)4 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)4 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)3 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)3 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)3 WebResourceCollection (com.sun.enterprise.deployment.web.WebResourceCollection)3 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 XMLNode (com.sun.enterprise.deployment.node.XMLNode)2 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)2 File (java.io.File)2