Search in sources :

Example 26 with ModuleDescriptor

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

the class Application method getBundleDescriptors.

/**
 * Obtain a full set of bundle descriptors for a particular type
 *
 * @param type the bundle descriptor type requested
 * @return the set of bundle descriptors
 */
public <T extends BundleDescriptor> Set<T> getBundleDescriptors(Class<T> type) {
    if (type == null) {
        return null;
    }
    Set<T> bundleSet = new OrderedSet<T>();
    for (ModuleDescriptor aModule : getModules()) {
        try {
            T descriptor = type.cast(aModule.getDescriptor());
            bundleSet.add(descriptor);
        } catch (ClassCastException e) {
        // ignore
        }
        // type has nothing to do with the children extensions.
        if (aModule.getDescriptor() != null) {
            bundleSet.addAll(aModule.getDescriptor().getExtensionsDescriptors(type));
        }
    }
    return bundleSet;
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 27 with ModuleDescriptor

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

the class WSTest method getAbstractArchiveUri.

protected String getAbstractArchiveUri(WebServiceEndpoint desc) {
    String archBase = getVerifierContext().getAbstractArchive().getURI().toString();
    final ModuleDescriptor moduleDescriptor = desc.getBundleDescriptor().getModuleDescriptor();
    if (moduleDescriptor.isStandalone()) {
        // it must be a stand-alone module; no such physical dir exists
        return archBase;
    } else {
        return archBase + "/" + FileUtils.makeFriendlyFilename(moduleDescriptor.getArchiveUri());
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 28 with ModuleDescriptor

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

the class JarNotFound method getAbsolutePuRoot.

/**
 * This method calculates the absolute path of the root of a PU.
 * Absolute path is not the path with regards to root of file system.
 * It is the path from the root of the Java EE application this
 * persistence unit belongs to.
 * Returned path always uses '/' as path separator.
 * @param applicationLocation absolute path of application root
 * @param persistenceUnitDescriptor
 * @return the absolute path of the root of this persistence unit
 */
private String getAbsolutePuRoot(String applicationLocation, PersistenceUnitDescriptor persistenceUnitDescriptor) {
    RootDeploymentDescriptor rootDD = persistenceUnitDescriptor.getParent().getParent();
    String puRoot = persistenceUnitDescriptor.getPuRoot();
    if (rootDD.isApplication()) {
        return puRoot;
    } else {
        ModuleDescriptor module = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
        if (module.isStandalone()) {
            return puRoot;
        } else {
            final String moduleLocation = DeploymentUtils.getRelativeEmbeddedModulePath(applicationLocation, module.getArchiveUri());
            // see we always '/'
            return moduleLocation + '/' + puRoot;
        }
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 29 with ModuleDescriptor

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

the class EJBContainerProviderImpl method getRequestedEJBModuleOrLibrary.

/**
 * @returns DeploymentElement if this file represents an EJB module or a library.
 * Returns null if it's an EJB module which name is not present in the list of requested
 * module names.
 */
private DeploymentElement getRequestedEJBModuleOrLibrary(File file, Map<String, Boolean> moduleNames) throws Exception {
    DeploymentElement result = null;
    String fileName = file.getName();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("... Testing ... " + fileName);
    }
    ReadableArchive archive = null;
    InputStream is = null;
    try {
        boolean isEJBModule = false;
        String moduleName = DeploymentUtils.getDefaultEEName(fileName);
        archive = archiveFactory.openArchive(file);
        is = getDeploymentDescriptor(archive);
        if (is != null) {
            isEJBModule = true;
            EjbDeploymentDescriptorFile eddf = new EjbDeploymentDescriptorFile();
            eddf.setXMLValidation(false);
            EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) eddf.read(is);
            ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
            moduleDesc.setArchiveUri(fileName);
            moduleName = moduleDesc.getModuleName();
        } else {
            GenericAnnotationDetector detector = new GenericAnnotationDetector(ejbAnnotations);
            isEJBModule = detector.hasAnnotationInArchive(archive);
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("... is EJB module: " + isEJBModule);
            if (isEJBModule) {
                _logger.fine("... is Requested EJB module [" + moduleName + "]: " + (moduleNames.isEmpty() || moduleNames.containsKey(moduleName)));
            }
        }
        if (!isEJBModule || moduleNames.isEmpty()) {
            result = new DeploymentElement(file, isEJBModule, moduleName);
        } else if (moduleNames.containsKey(moduleName) && !moduleNames.get(moduleName)) {
            // Is a requested EJB module and was not found already
            result = new DeploymentElement(file, isEJBModule, moduleName);
            moduleNames.put(moduleName, true);
        }
        return result;
    } finally {
        if (archive != null)
            archive.close();
        if (is != null)
            is.close();
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) EjbDeploymentDescriptorFile(org.glassfish.ejb.deployment.io.EjbDeploymentDescriptorFile) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) GenericAnnotationDetector(org.glassfish.deployment.common.GenericAnnotationDetector) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive)

Example 30 with ModuleDescriptor

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

the class PipeHelper method getClientModuleID.

private static String getClientModuleID(ServiceReferenceDescriptor srd) {
    String rvalue = "#default-client-context#";
    if (srd != null) {
        ModuleDescriptor md = null;
        BundleDescriptor bd = (BundleDescriptor) srd.getBundleDescriptor();
        if (bd != null) {
            md = bd.getModuleDescriptor();
        }
        Application a = (bd == null) ? null : bd.getApplication();
        if (a != null) {
            if (a.isVirtual()) {
                rvalue = a.getRegistrationName();
            } else if (md != null) {
                rvalue = FileUtils.makeFriendlyFilename(md.getArchiveUri());
            }
        } else if (md != null) {
            rvalue = FileUtils.makeFriendlyFilename(md.getArchiveUri());
        }
    }
    return rvalue;
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Aggregations

ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)44 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)13 Application (com.sun.enterprise.deployment.Application)8 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)6 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)6 DOLUtils.setExtensionArchivistForSubArchivist (com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist)5 File (java.io.File)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)4 InputStream (java.io.InputStream)4 ApplicationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile)3 ConfigurationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)3 DeploymentDescriptorFile (com.sun.enterprise.deployment.io.DeploymentDescriptorFile)3 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 Vector (java.util.Vector)2