use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager 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.container.common.spi.util.ComponentEnvManager in project Payara by payara.
the class WSServletContextListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
WebBundleDescriptor webBundle = null;
if (jndiNameEnv != null && jndiNameEnv instanceof BundleDescriptor && ((BundleDescriptor) jndiNameEnv).getModuleType().equals(DOLUtils.warType())) {
webBundle = ((WebBundleDescriptor) jndiNameEnv);
} else {
throw new WebServiceException("Cannot intialize the JAXWSServlet for " + jndiNameEnv);
}
contextRoot = webBundle.getContextRoot();
WebServicesDescriptor webServices = webBundle.getWebServices();
try {
for (WebServiceEndpoint endpoint : webServices.getEndpoints()) {
registerEndpoint(endpoint, sce.getServletContext());
}
} catch (Throwable t) {
// TODO Fix Rama
logger.log(Level.WARNING, LogUtils.DEPLOYMENT_FAILED, t);
sce.getServletContext().removeAttribute("ADAPTER_LIST");
throw new RuntimeException("Servlet web service endpoint '" + "' failure", t);
}
}
use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.
the class JAXWSServlet method init.
public void init(ServletConfig servletConfig) throws ServletException {
String servletName = "unknown";
try {
super.init(servletConfig);
wsEngine_ = WebServiceEngineImpl.getInstance();
// Register endpoints here
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 JAXWSServlet for " + jndiNameEnv);
}
servletName = servletConfig.getServletName();
contextRoot = webBundle.getContextRoot();
WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
if (webComponent != null) {
WebServicesDescriptor webServices = webBundle.getWebServices();
Collection<WebServiceEndpoint> endpoints = webServices.getEndpointsImplementedBy(webComponent);
// Only 1 endpoint per servlet is supported, even though
// data structure implies otherwise.
endpoint = endpoints.iterator().next();
} else {
throw new ServletException(servletName + " not found");
}
// need to invoke the endpoint lifecylcle
if (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding()))) {
// Doing this so that restful service are not monitored
wsEngine_.createHandler(endpoint);
}
if (endpoint.getWsdlExposed() != null) {
wsdlExposed = Boolean.parseBoolean(endpoint.getWsdlExposed());
}
// For web components, this will be relative to the web app
// context root. Make sure there is a leading slash.
String uri = endpoint.getEndpointAddressUri();
urlPattern = uri.startsWith("/") ? uri : "/" + uri;
} 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);
}
requestTracing = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(RequestTracingService.class);
}
use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.
the class JavaModuleNamingProxy method getAppName.
private String getAppName() throws NamingException {
ComponentEnvManager namingMgr = habitat.getService(ComponentEnvManager.class);
String appName = null;
if (namingMgr != null) {
JndiNameEnvironment env = namingMgr.getCurrentJndiNameEnvironment();
BundleDescriptor bd = null;
if (env instanceof EjbDescriptor) {
bd = ((EjbDescriptor) env).getEjbBundleDescriptor();
} else if (env instanceof BundleDescriptor) {
bd = (BundleDescriptor) env;
}
if (bd != null) {
Application app = bd.getApplication();
appName = app.getAppName();
} else {
ApplicationEnvironment applicationEnvironment = namingMgr.getCurrentApplicationEnvironment();
if (applicationEnvironment != null) {
appName = applicationEnvironment.getName();
}
}
}
if (appName == null) {
throw new NamingException("Could not resolve " + JAVA_APP_NAME);
}
return appName;
}
use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.
the class JavaModuleNamingProxy method getJavaModuleOrAppEJB.
private Object getJavaModuleOrAppEJB(String name) throws NamingException {
String newName = null;
Object returnValue = null;
if (habitat != null) {
ComponentEnvManager namingMgr = habitat.getService(ComponentEnvManager.class);
if (namingMgr != null) {
JndiNameEnvironment env = namingMgr.getCurrentJndiNameEnvironment();
BundleDescriptor bd = null;
if (env instanceof EjbDescriptor) {
bd = ((EjbDescriptor) env).getEjbBundleDescriptor();
} else if (env instanceof BundleDescriptor) {
bd = (BundleDescriptor) env;
}
if (bd != null) {
Application app = bd.getApplication();
String appName = null;
if (!app.isVirtual()) {
appName = app.getAppName();
}
String moduleName = bd.getModuleDescriptor().getModuleName();
StringBuffer javaGlobalName = new StringBuffer("java:global/");
if (name.startsWith(JAVA_APP_CONTEXT)) {
if (appName != null) {
javaGlobalName.append(appName);
javaGlobalName.append("/");
}
// Replace java:app/ with the fully-qualified global portion
int javaAppLength = JAVA_APP_CONTEXT.length();
javaGlobalName.append(name.substring(javaAppLength));
} else {
if (appName != null) {
javaGlobalName.append(appName);
javaGlobalName.append("/");
}
javaGlobalName.append(moduleName);
javaGlobalName.append("/");
// Replace java:module/ with the fully-qualified global portion
int javaModuleLength = JAVA_MODULE_CONTEXT.length();
javaGlobalName.append(name.substring(javaModuleLength));
}
newName = javaGlobalName.toString();
}
}
}
if (newName != null) {
try {
if (processType == ProcessType.ACC) {
ManagedBeanManager mbMgr = habitat.getService(ManagedBeanManager.class);
try {
returnValue = mbMgr.getManagedBean(newName);
} catch (Exception e) {
NamingException ne = new NamingException("Error creating ACC managed bean " + newName);
ne.initCause(e);
throw ne;
}
}
if (returnValue == null) {
returnValue = ic.lookup(newName);
}
} catch (NamingException ne) {
_logger.log(Level.FINE, newName + " Unable to map " + name + " to derived name " + newName, ne);
}
}
return returnValue;
}
Aggregations