use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class TransactionalInterceptorBase method resetTransactionOperationsManager.
void resetTransactionOperationsManager() {
if (testTransactionManager != null) {
// test
return;
}
ComponentInvocation currentInvocation = getCurrentInvocation();
if (currentInvocation == null) {
// There should always be a currentInvocation and so this would seem a bug
// but not a fatal one as app should not be relying on this, so log warning only
_logger.log(WARNING, "TransactionalInterceptorBase.markThreadAsTransactional currentInvocation==null");
return;
}
currentInvocation.setTransactionOperationsManager(preexistingTransactionOperationsManager);
}
use of org.glassfish.api.invocation.ComponentInvocation 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 org.glassfish.api.invocation.ComponentInvocation 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 org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class WeldDeployer method processApplicationLoaded.
private void processApplicationLoaded(ApplicationInfo applicationInfo) {
WeldBootstrap bootstrap = applicationInfo.getTransientAppMetaData(WELD_BOOTSTRAP, WeldBootstrap.class);
if (bootstrap != null) {
DeploymentImpl deploymentImpl = applicationInfo.getTransientAppMetaData(WELD_DEPLOYMENT, DeploymentImpl.class);
deploymentImpl.buildDeploymentGraph();
List<BeanDeploymentArchive> archives = deploymentImpl.getBeanDeploymentArchives();
addResourceLoaders(archives);
addCdiServicesToNonModuleBdas(deploymentImpl.getLibJarRootBdas(), services.getService(InjectionManager.class));
addCdiServicesToNonModuleBdas(deploymentImpl.getRarRootBdas(), services.getService(InjectionManager.class));
// Get current TCL
ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
invocationManager.pushAppEnvironment(() -> applicationInfo.getName());
ComponentInvocation componentInvocation = createComponentInvocation(applicationInfo);
try {
bootstrap.startExtensions(postProcessExtensions(deploymentImpl.getExtensions(), archives));
bootstrap.startContainer(deploymentImpl.getContextId() + ".bda", SERVLET, deploymentImpl);
bootstrap.startInitialization();
fireProcessInjectionTargetEvents(bootstrap, deploymentImpl);
bootstrap.deployBeans();
bootstrap.validateBeans();
invocationManager.preInvoke(componentInvocation);
bootstrap.endInitialization();
} catch (Throwable t) {
doBootstrapShutdown(applicationInfo);
throw new DeploymentException(getDeploymentErrorMsgPrefix(t) + t.getMessage(), t);
} finally {
invocationManager.postInvoke(componentInvocation);
invocationManager.popAppEnvironment();
// The TCL is originally the EAR classloader and is reset during Bean deployment to the
// corresponding module classloader in BeanDeploymentArchiveImpl.getBeans
// for Bean classloading to succeed.
// The TCL is reset to its old value here.
Thread.currentThread().setContextClassLoader(oldTCL);
deploymentComplete(deploymentImpl);
}
}
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class JCDIServiceImpl method isCurrentModuleJCDIEnabled.
@Override
public boolean isCurrentModuleJCDIEnabled() {
BundleDescriptor bundle = null;
ComponentInvocation inv = invocationManager.getCurrentInvocation();
if (inv == null) {
return false;
}
JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
if (componentEnv != null) {
if (componentEnv instanceof BundleDescriptor) {
bundle = (BundleDescriptor) componentEnv;
} else if (componentEnv instanceof EjbDescriptor) {
bundle = ((EjbDescriptor) componentEnv).getEjbBundleDescriptor();
}
}
return (bundle != null) ? isJCDIEnabled(bundle) : false;
}
Aggregations