Search in sources :

Example 16 with RootDeploymentDescriptor

use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.

the class AbstractPersistenceUnitCount method check.

public Result check(Descriptor descriptor) {
    RootDeploymentDescriptor rootDescriptor = getRootDescriptor(descriptor);
    Result result = getInitializedResult();
    addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
    // default status is PASSED
    result.setStatus(Result.PASSED);
    if (rootDescriptor.getExtensionsDescriptors(PersistenceUnitsDescriptor.class).size() == 0)
        result.setStatus(Result.NOT_APPLICABLE);
    for (PersistenceUnitsDescriptor pus : rootDescriptor.getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) {
        if (pus.getPersistenceUnitDescriptors().size() == 0) {
            result.failed(smh.getLocalString(className + ".failed", "persistence.xml in persistence unit root [ {0} ] has no persistence units.", new Object[] { pus.getPuRoot() }));
        }
    }
    return result;
}
Also used : RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) Result(com.sun.enterprise.tools.verifier.Result)

Example 17 with RootDeploymentDescriptor

use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.

the class WebArchivist method postStandardDDsRead.

/**
 * After reading all the standard deployment descriptors, merge any
 * resource descriptors from EJB descriptors into the WebBundleDescriptor.
 *
 * @param descriptor the deployment descriptor for the module
 * @param archive the module archive
 * @param extensions map of extension archivists
 */
@Override
protected void postStandardDDsRead(WebBundleDescriptorImpl descriptor, ReadableArchive archive, Map<ExtensionsArchivist, RootDeploymentDescriptor> extensions) throws IOException {
    for (RootDeploymentDescriptor rd : extensions.values()) {
        if (rd instanceof EjbBundleDescriptor) {
            EjbBundleDescriptor eb = (EjbBundleDescriptor) rd;
            descriptor.addJndiNameEnvironment(eb);
            for (EjbDescriptor ejb : eb.getEjbs()) {
                ejb.notifyNewModule(descriptor);
            }
        }
    }
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 18 with RootDeploymentDescriptor

use of org.glassfish.deployment.common.RootDeploymentDescriptor 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)

Example 19 with RootDeploymentDescriptor

use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.

the class Util method getMainClassNameForAppClient.

/**
 *Returns the main class name for the app client represented by the module descriptor.
 *@param moduleDescr the module descriptor for the app client of interest
 *@return main class name of the app client
 */
public static String getMainClassNameForAppClient(ModuleDescriptor moduleDescr) throws IOException, FileNotFoundException, org.xml.sax.SAXParseException {
    RootDeploymentDescriptor bd = moduleDescr.getDescriptor();
    ApplicationClientDescriptor acDescr = (ApplicationClientDescriptor) bd;
    String mainClassName = acDescr.getMainClassName();
    return mainClassName;
}
Also used : RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor)

Example 20 with RootDeploymentDescriptor

use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.

the class UndeployedLaunchable method newUndeployedLaunchable.

static UndeployedLaunchable newUndeployedLaunchable(final ServiceLocator habitat, final ReadableArchive ra, final String callerSuppliedMainClassName, final String callerSuppliedAppName, final ClassLoader classLoader) throws IOException, SAXParseException, UserError {
    ArchivistFactory af = Util.getArchivistFactory();
    /*
         * Try letting the factory decide what type of archive this is.  That
         * will often allow an app client or an EAR archive to be detected
         * automatically.
         */
    Archivist archivist = af.getArchivist(ModuleType.CAR.toString(), classLoader);
    if (archivist == null) {
        throw new UserError(localStrings.get("appclient.invalidArchive", ra.getURI().toASCIIString()));
    }
    final ArchiveType moduleType = archivist.getModuleType();
    if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
        return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
    } else if (moduleType != null && moduleType.equals(DOLUtils.earType())) {
        /*
             * Locate the app client submodule that matches the main class name
             * or the app client name.
             */
        Application app = (Application) archivist.open(ra);
        for (ModuleDescriptor<BundleDescriptor> md : app.getModules()) {
            if (!md.getModuleType().equals(DOLUtils.carType())) {
                continue;
            }
            ApplicationClientDescriptor acd = (ApplicationClientDescriptor) md.getDescriptor();
            final String displayName = acd.getDisplayName();
            final String appName = acd.getModuleID();
            ArchiveFactory archiveFactory = Util.getArchiveFactory();
            ReadableArchive clientRA = archiveFactory.openArchive(ra.getURI().resolve(md.getArchiveUri()));
            /*
                 * Choose this nested app client if the caller-supplied name
                 * matches, or if the caller-supplied main class matches, or
                 * if neither was provided.  
                 */
            final boolean useThisClient = (displayName != null && displayName.equals(callerSuppliedAppName)) || (appName != null && appName.equals(callerSuppliedAppName)) || (callerSuppliedMainClassName != null && clientRA.exists(classToResource(callerSuppliedMainClassName)) || (callerSuppliedAppName == null && callerSuppliedMainClassName == null));
            if (useThisClient) {
                return new UndeployedLaunchable(habitat, clientRA, acd, callerSuppliedMainClassName);
            }
            clientRA.close();
        }
        throw new UserError(localStrings.get("appclient.noMatchingClientInEAR", ra.getURI(), callerSuppliedMainClassName, callerSuppliedAppName));
    } else {
        /*
             * There is a possibility that the user is trying to launch an
             * archive that is more than one type of archive: such as an EJB
             * but also an app client (because the manifest identifies a main
             * class, for example).
             *
             * Earlier the archivist factory might have returned the other type
             * of archivist - such as the EJB archivist.  Now see if the app
             * client archivist will work when selected directly.
             */
        archivist = af.getArchivist(DOLUtils.carType());
        /*
             * Try to open the archive as an app client archive just to see
             * if it works.
             */
        RootDeploymentDescriptor tempACD = archivist.open(ra);
        if (tempACD != null && tempACD instanceof ApplicationClientDescriptor) {
            /*
                 * Start with a fresh archivist - unopened - so we can request
                 * anno processing, etc. before opening it for real.
                 */
            archivist = af.getArchivist(DOLUtils.carType());
            return new UndeployedLaunchable(habitat, ra, (AppClientArchivist) archivist, callerSuppliedMainClassName);
        }
        throw new UserError(localStrings.get("appclient.unexpectedArchive", ra.getURI()));
    }
}
Also used : ArchiveFactory(com.sun.enterprise.deploy.shared.ArchiveFactory) AppClientArchivist(com.sun.enterprise.deployment.archivist.AppClientArchivist) Archivist(com.sun.enterprise.deployment.archivist.Archivist) ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) AppClientArchivist(com.sun.enterprise.deployment.archivist.AppClientArchivist) ArchivistFactory(com.sun.enterprise.deployment.archivist.ArchivistFactory) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Application(com.sun.enterprise.deployment.Application)

Aggregations

RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)24 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)6 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)6 HashMap (java.util.HashMap)3 Application (com.sun.enterprise.deployment.Application)2 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)2 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)2 PersistenceUnitDescriptor (com.sun.enterprise.deployment.PersistenceUnitDescriptor)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 PrincipalNameDescriptor (com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)2 StringTokenizer (java.util.StringTokenizer)2 ArchiveType (org.glassfish.api.deployment.archive.ArchiveType)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1 DataSourceDefinitionDescriptor (com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)1 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)1 PersistenceUnitsDescriptor (com.sun.enterprise.deployment.PersistenceUnitsDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)1