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);
}
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;
}
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);
}
}
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);
}
}
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;
}
}
}
Aggregations