use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class BeanManagerNamingProxy method handle.
@Override
public Object handle(String name) throws NamingException {
Object beanManager = null;
if (BEAN_MANAGER_CONTEXT.equals(name)) {
try {
// Use invocation context to find applicable BeanDeploymentArchive.
ComponentInvocation inv = invocationManager.getCurrentInvocation();
if (inv != null) {
JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
if (componentEnv != null) {
BundleDescriptor bundle = null;
if (componentEnv instanceof EjbDescriptor) {
bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
} else if (componentEnv instanceof WebBundleDescriptor) {
bundle = (BundleDescriptor) componentEnv;
}
if (bundle != null) {
BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
if (bda != null) {
WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
// System.out.println("BeanManagerNamingProxy:: getting BeanManagerImpl for" + bda);
beanManager = bootstrap.getManager(bda);
}
}
if (beanManager == null) {
throw new IllegalStateException("Cannot resolve bean manager");
}
} else {
throw new IllegalStateException("No invocation context found");
}
}
} catch (Throwable t) {
NamingException ne = new NamingException("Error retrieving java:comp/BeanManager");
ne.initCause(t);
throw ne;
}
}
return beanManager;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class ValidationNamingProxy method obtainBeanManager.
/**
* Obtain the BeanManagerNamingProxy from hk2, so the BeanManager can be looked up
*
* @throws NamingException
*/
private synchronized BeanManager obtainBeanManager() throws NamingException {
BeanManager beanManager = null;
// Use invocation context to find applicable BeanDeploymentArchive.
ComponentInvocation inv = invocationManager.getCurrentInvocation();
if (inv != null) {
JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
if (componentEnv != null) {
BundleDescriptor bundle = null;
if (componentEnv instanceof EjbDescriptor) {
bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
} else if (componentEnv instanceof WebBundleDescriptor) {
bundle = (BundleDescriptor) componentEnv;
}
if (bundle != null) {
BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
if (bda != null) {
WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
beanManager = bootstrap.getManager(bda);
}
}
}
}
return beanManager;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class WeldDeployer method addWeldListenerToAllWars.
private void addWeldListenerToAllWars(DeploymentContext context) {
// if there's at least 1 ejb jar then add the listener to all wars
ApplicationHolder applicationHolder = context.getModuleMetaData(ApplicationHolder.class);
if (applicationHolder != null) {
if (applicationHolder.app.getBundleDescriptors(EjbBundleDescriptor.class).size() > 0) {
Set<WebBundleDescriptor> webBundleDescriptors = applicationHolder.app.getBundleDescriptors(WebBundleDescriptor.class);
for (WebBundleDescriptor oneWebBundleDescriptor : webBundleDescriptors) {
// Add the Weld Listener if it does not already exist..
// we have to do this regardless because the war may not be cdi-enabled but an ejb is.
oneWebBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
oneWebBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
}
}
}
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class AppServRegistry method getWebModule.
/*
* This function is called once for every endpoint registration.
* and the WebModule corresponding to that endpoint is stored.
*/
static WebModule getWebModule(WebServiceEndpoint wsep) {
ApplicationRegistry appRegistry = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
String appName = wsep.getBundleDescriptor().getApplication().getAppName();
ApplicationInfo appInfo = appRegistry.get(appName);
WebApplication webApp = null;
if (appInfo != null) {
Collection<ModuleInfo> moduleInfos = appInfo.getModuleInfos();
Set<EngineRef> engineRefs = null;
WebBundleDescriptor requiredWbd = (WebBundleDescriptor) wsep.getBundleDescriptor();
for (ModuleInfo moduleInfo : moduleInfos) {
engineRefs = moduleInfo.getEngineRefs();
for (EngineRef engineRef : engineRefs) {
if (engineRef.getApplicationContainer() instanceof WebApplication) {
webApp = (WebApplication) engineRef.getApplicationContainer();
WebBundleDescriptor wbd = webApp.getDescriptor();
if (wbd.equals(requiredWbd)) {
// WebApp corresponding to wsep is found.
break;
} else {
webApp = null;
}
}
}
}
}
// get the required WebModule from the webApp.
if (webApp != null) {
String requiredModule = ((WebBundleDescriptor) wsep.getBundleDescriptor()).getModuleName();
Set<WebModule> webModules = webApp.getWebModules();
for (WebModule wm : webModules) {
if (wm.getModuleName().equalsIgnoreCase(requiredModule)) {
return wm;
}
}
}
return null;
}
use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method combineEnvironmentEntries.
@Override
protected void combineEnvironmentEntries(JndiNameEnvironment env) {
for (Object oenve : env.getEnvironmentProperties()) {
EnvironmentEntry enve = (EnvironmentEntry) oenve;
EnvironmentProperty envProp = _getEnvironmentPropertyByName(enve.getName());
if (envProp != null) {
combineInjectionTargets(envProp, (EnvironmentProperty) enve);
EnvironmentProperty envP = (EnvironmentProperty) enve;
if (!envProp.hasInjectionTargetFromXml() && (!envProp.isSetValueCalled()) && envP.isSetValueCalled()) {
envProp.setValue(enve.getValue());
}
} else {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictEnvironmentEntry()) {
throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictenventry", "There are more than one environment entries defined in web fragments with the same name, but not overrided in web.xml"));
} else {
addEnvironmentEntry(enve);
}
}
}
}
Aggregations