Search in sources :

Example 6 with ModuleDescriptor

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

the class InternalInterceptorBindingImpl method registerInterceptor.

public void registerInterceptor(Object systemInterceptor) {
    InvocationManager invManager = services.getService(InvocationManager.class);
    ComponentInvocation currentInv = invManager.getCurrentInvocation();
    if (currentInv == null) {
        throw new IllegalStateException("no current invocation");
    } else if (currentInv.getInvocationType() != ComponentInvocation.ComponentInvocationType.SERVLET_INVOCATION) {
        throw new IllegalStateException("Illegal invocation type : " + currentInv.getInvocationType() + ".  This operation is only available from a web app context");
    }
    ComponentEnvManager compEnvManager = services.getService(ComponentEnvManager.class);
    JndiNameEnvironment env = compEnvManager.getCurrentJndiNameEnvironment();
    BundleDescriptor webBundle = (BundleDescriptor) env;
    ModuleDescriptor moduleDesc = webBundle.getModuleDescriptor();
    // Register interceptor for EJB components
    if (EjbContainerUtilImpl.isInitialized()) {
        Collection<EjbBundleDescriptor> ejbBundles = moduleDesc.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);
        if (ejbBundles.size() == 1) {
            EjbBundleDescriptor ejbBundle = ejbBundles.iterator().next();
            for (EjbDescriptor ejb : ejbBundle.getEjbs()) {
                BaseContainer container = EjbContainerUtilImpl.getInstance().getContainer(ejb.getUniqueId());
                container.registerSystemInterceptor(systemInterceptor);
            }
        }
    }
    // Register interceptor for any managed beans
    // TODO Handle 299-enabled case
    ManagedBeanManager managedBeanManager = services.getService(ManagedBeanManager.class, "ManagedBeanManagerImpl");
    managedBeanManager.registerRuntimeInterceptor(systemInterceptor, webBundle);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) ManagedBeanManager(com.sun.enterprise.container.common.spi.ManagedBeanManager)

Example 7 with ModuleDescriptor

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

the class ListSubComponentsCommand method getSubModuleListForEar.

private Collection<ModuleDescriptor<BundleDescriptor>> getSubModuleListForEar(com.sun.enterprise.deployment.Application application, String type) {
    Collection<ModuleDescriptor<BundleDescriptor>> modules = new ArrayList<ModuleDescriptor<BundleDescriptor>>();
    if (type == null) {
        modules = application.getModules();
    } else if (type.equals("servlets")) {
        modules = application.getModuleDescriptorsByType(DOLUtils.warType());
    } else if (type.equals("ejbs")) {
        modules = application.getModuleDescriptorsByType(DOLUtils.ejbType());
        // ejb in war case
        Collection<ModuleDescriptor<BundleDescriptor>> webModules = application.getModuleDescriptorsByType(DOLUtils.warType());
        for (ModuleDescriptor webModule : webModules) {
            if (webModule.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class).size() > 0) {
                modules.add(webModule);
            }
        }
    }
    return modules;
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) ArrayList(java.util.ArrayList)

Example 8 with ModuleDescriptor

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

the class EarDeployer method doOnAllBundles.

private void doOnAllBundles(Application application, BundleBlock runnable) throws Exception {
    Collection<ModuleDescriptor> bundles = new LinkedHashSet<ModuleDescriptor>();
    bundles.addAll(application.getModules());
    // we load the modules by their declaration order in application.xml
    if (application.isInitializeInOrder()) {
        for (final ModuleDescriptor bundle : bundles) {
            runnable.doBundle(bundle);
        }
    } else // otherwise we load modules by default order: connector, ejb, web and
    // saving app client for last (because other submodules might generated
    // artifacts that should be included in the generated app client JAR
    {
        // first we take care of the connectors
        bundles.removeAll(doOnAllTypedBundles(application, DOLUtils.rarType(), runnable));
        // now the EJBs
        bundles.removeAll(doOnAllTypedBundles(application, DOLUtils.ejbType(), runnable));
        // finally the war files.
        bundles.removeAll(doOnAllTypedBundles(application, DOLUtils.warType(), runnable));
        // extract the app client bundles to take care of later
        Collection<ModuleDescriptor<BundleDescriptor>> appClientBundles = application.getModuleDescriptorsByType(DOLUtils.carType());
        bundles.removeAll(appClientBundles);
        // now ther remaining bundles
        for (final ModuleDescriptor bundle : bundles) {
            runnable.doBundle(bundle);
        }
        // Last, deal with the app client bundles
        doOnBundles(appClientBundles, runnable);
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 9 with ModuleDescriptor

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

the class AppClientGroupFacadeGenerator method generateGroupFacade.

private void generateGroupFacade() {
    final Application application = dc.getModuleMetaData(Application.class);
    final Collection<ModuleDescriptor<BundleDescriptor>> appClients = application.getModuleDescriptorsByType(carType);
    final StringBuilder appClientGroupListSB = new StringBuilder();
    /*
        /*
         * For each app client, get its facade's URI to include in the
         * generated EAR facade's client group listing.
         */
    for (Iterator<ModuleDescriptor<BundleDescriptor>> it = appClients.iterator(); it.hasNext(); ) {
        ModuleDescriptor<BundleDescriptor> md = it.next();
        appClientGroupListSB.append((appClientGroupListSB.length() > 0) ? " " : "").append(earDirUserURIText(dc)).append(appClientFacadeUserURI(md.getArchiveUri()));
    }
    try {
        addTopLevelContentToGroupFacade();
        /*
             * Pass the EAR's generated/xml directory for where to generated the
             * group facade.  Because the directories are flattened, even if the
             * client is actually x/y/z.jar its expanded directory will be just
             * one level lower than the EAR's directory.
             */
        generateAndRecordEARFacadeContents(dc, appClientGroupListSB.toString());
        recordGroupFacadeGeneration();
    } catch (Exception e) {
        throw new DeploymentException(e);
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) Application(com.sun.enterprise.deployment.Application) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 10 with ModuleDescriptor

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

the class PersistenceUnitInfoImpl method getAbsolutePuRootWithinApplication.

/**
 * 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.
 * @return the absolute path of the root of this persistence unit
 */
private String getAbsolutePuRootWithinApplication() {
    // TODO shift this into PersistenceUnitDescriptor to better encapsulate
    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 {
            // The module is embedded in an ear (an ejb jar or war)
            final // Would point to the directory where module is expanded. For example myejb_jar
            String moduleLocation = DeploymentUtils.getRelativeEmbeddedModulePath(providerContainerContractInfo.getApplicationLocation(), 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)

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