Search in sources :

Example 1 with ModuleScanner

use of com.sun.enterprise.deployment.annotation.impl.ModuleScanner in project Payara by payara.

the class WebArchivist method postAnnotationProcess.

@Override
protected void postAnnotationProcess(WebBundleDescriptorImpl descriptor, ReadableArchive archive) throws IOException {
    super.postAnnotationProcess(descriptor, archive);
    // read web-fragment.xml
    List<WebFragmentDescriptor> wfList = readStandardFragments(descriptor, archive);
    // extension annotation processing will be done in top level
    if (isProcessAnnotation(descriptor)) {
        Map<ExtensionsArchivist, RootDeploymentDescriptor> localExtensions = new HashMap<>();
        for (WebFragmentDescriptor wfDesc : wfList) {
            // should be overridden and be true also
            if (descriptor.isFullAttribute()) {
                wfDesc.setFullAttribute(String.valueOf(descriptor.isFullAttribute()));
            }
            super.readAnnotations(archive, wfDesc, localExtensions);
        }
        // scan manifest classpath
        ModuleScanner scanner = getScanner();
        if (scanner instanceof WarScanner) {
            ((WarScanner) scanner).setScanOtherLibraries(true);
            readAnnotations(archive, descriptor, localExtensions, scanner);
        }
    }
    WebFragmentDescriptor mergedWebFragment = new WebFragmentDescriptor();
    mergedWebFragment.setExists(false);
    for (WebFragmentDescriptor wf : wfList) {
        // we have the first fragment that's contains the web-fragment.xml file
        if (!mergedWebFragment.isExists() && wf.isExists()) {
            mergedWebFragment.setExists(true);
            mergedWebFragment.setDistributable(wf.isDistributable());
        }
        mergedWebFragment.addWebBundleDescriptor(wf);
    }
    if (!wfList.isEmpty()) {
        descriptor.addWebBundleDescriptor(mergedWebFragment);
        // if there any mapping stubs left, there is something invalid referenced from web.xml
        for (WebComponentDescriptor desc : descriptor.getWebComponentDescriptors()) {
            if (desc instanceof WebComponentDescriptorStub) {
                throw new RuntimeException(String.format("There is no web component by the name of %s here.", desc.getName()));
            }
        }
    }
    // apply default from default-web.xml to web.xml
    WebBundleDescriptorImpl defaultWebBundleDescriptor = getPlainDefaultWebXmlBundleDescriptor();
    descriptor.addDefaultWebBundleDescriptor(defaultWebBundleDescriptor);
}
Also used : WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) HashMap(java.util.HashMap) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ModuleScanner(com.sun.enterprise.deployment.annotation.impl.ModuleScanner) ExtensionsArchivist(com.sun.enterprise.deployment.archivist.ExtensionsArchivist) WarScanner(org.glassfish.web.deployment.annotation.impl.WarScanner)

Aggregations

WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 ModuleScanner (com.sun.enterprise.deployment.annotation.impl.ModuleScanner)1 ExtensionsArchivist (com.sun.enterprise.deployment.archivist.ExtensionsArchivist)1 HashMap (java.util.HashMap)1 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)1 WarScanner (org.glassfish.web.deployment.annotation.impl.WarScanner)1