use of com.sun.enterprise.deployment.JndiNameEnvironment in project Payara by payara.
the class InjectionManagerImpl method injectInstance.
public void injectInstance(Object instance, boolean invokePostConstruct) throws InjectionException {
ComponentInvocation invocation = invocationMgr.getCurrentInvocation();
if (invocation == null) {
throw new InjectionException(localStrings.getLocalString("injection-manager.null-invocation-context", "Null invocation context"));
}
JndiNameEnvironment componentEnvironment = compEnvManager.getJndiNameEnvironment(invocation.getComponentId());
if (componentEnvironment == null) {
throw new InjectionException(localStrings.getLocalString("injection-manager.no-descriptor-registered-for-invocation", "No descriptor registered for current invocation: {0}", invocation));
}
inject(instance.getClass(), instance, componentEnvironment, null, invokePostConstruct);
}
use of com.sun.enterprise.deployment.JndiNameEnvironment in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method processDescriptorForRAReferences.
private void processDescriptorForRAReferences(Application app, Descriptor descriptor, String moduleName) {
if (descriptor instanceof JndiNameEnvironment) {
processDescriptorForRAReferences(app, moduleName, (JndiNameEnvironment) descriptor);
}
// ejb descriptors
if (descriptor instanceof EjbBundleDescriptor) {
EjbBundleDescriptor ejbDesc = (EjbBundleDescriptor) descriptor;
Set<? extends EjbDescriptor> ejbDescriptors = ejbDesc.getEjbs();
for (EjbDescriptor ejbDescriptor : ejbDescriptors) {
processDescriptorForRAReferences(app, moduleName, ejbDescriptor);
if (ejbDescriptor instanceof EjbMessageBeanDescriptor) {
EjbMessageBeanDescriptor messageBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor;
String raMid = messageBeanDesc.getResourceAdapterMid();
// there seem to be applications that do not specify ra-mid
if (raMid != null) {
app.addResourceAdapter(raMid);
}
}
}
// ejb interceptors
Set<EjbInterceptor> ejbInterceptors = ejbDesc.getInterceptors();
for (EjbInterceptor ejbInterceptor : ejbInterceptors) {
processDescriptorForRAReferences(app, moduleName, ejbInterceptor);
}
}
if (descriptor instanceof BundleDescriptor) {
// managed bean descriptors
Set<ManagedBeanDescriptor> managedBeanDescriptors = ((BundleDescriptor) descriptor).getManagedBeans();
for (ManagedBeanDescriptor mbd : managedBeanDescriptors) {
processDescriptorForRAReferences(app, moduleName, mbd);
}
}
}
use of com.sun.enterprise.deployment.JndiNameEnvironment in project Payara by payara.
the class ServletWebServiceDelegate method postInit.
@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
String servletName = "unknown";
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
WebBundleDescriptor webBundle = null;
if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
webBundle = ((WebBundleDescriptor) jndiNameEnv);
} else {
throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
servletName = servletConfig.getServletName();
WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
if (webComponent != null) {
WebServicesDescriptor webServices = webBundle.getWebServices();
Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
// Only 1 endpoint per servlet is supported, even though
// data structure implies otherwise.
endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
registerEndpoint(classLoader);
// security
if (secServ != null) {
SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
if (securityHandlerDelegate != null) {
rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
// need to invoke the endpoint lifecylcle
endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
}
}
} else {
throw new ServletException(servletName + " not found");
}
} catch (Throwable t) {
String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
logger.log(Level.WARNING, msg, t);
throw new ServletException(t);
}
}
use of com.sun.enterprise.deployment.JndiNameEnvironment 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.JndiNameEnvironment 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;
}
Aggregations