use of com.sun.enterprise.web.jsp.JspProbeEmitterImpl in project Payara by payara.
the class WebModuleListener method configureJsp.
// ------------------------------------------------------- Private Methods
/**
* Configure all JSP related aspects of the web module, including
* any relevant TLDs as well as the jsp config settings of the
* JspServlet (using the values from sun-web.xml's jsp-config).
*/
private void configureJsp(WebModule webModule) {
ServletContext servletContext = webModule.getServletContext();
servletContext.setAttribute("org.glassfish.jsp.isStandaloneWebapp", Boolean.valueOf(webModule.isStandalone()));
// Find tld URI and set it to ServletContext attribute
List<URI> appLibUris = webModule.getDeployAppLibs();
Map<URI, List<String>> appLibTldMap = new HashMap<URI, List<String>>();
if (appLibUris != null && appLibUris.size() > 0) {
Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
for (URI uri : appLibUris) {
List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
if (entries != null && entries.size() > 0) {
appLibTldMap.put(uri, entries);
}
}
}
Collection<TldProvider> tldProviders = webContainer.getTldProviders();
Map<URI, List<String>> tldMap = new HashMap<URI, List<String>>();
for (TldProvider tldProvider : tldProviders) {
// Skip any JSF related TLDs for non-JSF apps
if ("jsfTld".equals(tldProvider.getName()) && !webModule.isJsfApplication()) {
continue;
}
Map<URI, List<String>> tmap = tldProvider.getTldMap();
if (tmap != null) {
tldMap.putAll(tmap);
}
}
tldMap.putAll(appLibTldMap);
servletContext.setAttribute("com.sun.appserv.tld.map", tldMap);
/*
* Discover all TLDs that are known to contain listener
* declarations, and store the resulting map as a
* ServletContext attribute
*/
Map<URI, List<String>> tldListenerMap = new HashMap<URI, List<String>>();
for (TldProvider tldProvider : tldProviders) {
// Skip any JSF related TLDs for non-JSF apps
if ("jsfTld".equals(tldProvider.getName()) && !webModule.isJsfApplication()) {
continue;
}
Map<URI, List<String>> tmap = tldProvider.getTldListenerMap();
if (tmap != null) {
tldListenerMap.putAll(tmap);
}
}
tldListenerMap.putAll(appLibTldMap);
servletContext.setAttribute("com.sun.appserv.tldlistener.map", tldListenerMap);
ServiceLocator defaultServices = webContainer.getServerContext().getDefaultServices();
// set services for jsf injection
servletContext.setAttribute(Constants.HABITAT_ATTRIBUTE, defaultServices);
SunWebAppImpl bean = webModule.getIasWebAppConfigBean();
// Find the default jsp servlet
Wrapper wrapper = (Wrapper) webModule.findChild(org.apache.catalina.core.Constants.JSP_SERVLET_NAME);
if (wrapper == null) {
return;
}
if (webModule.getTldValidation()) {
wrapper.addInitParameter("enableTldValidation", "true");
}
if (bean != null && bean.getJspConfig() != null) {
WebProperty[] props = bean.getJspConfig().getWebProperty();
for (int i = 0; i < props.length; i++) {
String pname = props[i].getAttributeValue("name");
String pvalue = props[i].getAttributeValue("value");
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, LogFacade.JSP_CONFIG_PROPERTY, "[" + webModule.getID() + "] is [" + pname + "] = [" + pvalue + "]");
}
wrapper.addInitParameter(pname, pvalue);
}
}
// Override any log setting with the container wide logging level
wrapper.addInitParameter("logVerbosityLevel", getJasperLogLevel());
ResourceInjectorImpl resourceInjector = new ResourceInjectorImpl(webModule);
servletContext.setAttribute("com.sun.appserv.jsp.resource.injector", resourceInjector);
// START SJSAS 6311155
String sysClassPath = ASClassLoaderUtil.getModuleClassPath((ServiceLocator) defaultServices, webModule.getID(), null);
// If the configuration flag usMyFaces is set, remove javax.faces.jar
// from the system class path
Boolean useMyFaces = (Boolean) servletContext.getAttribute("com.sun.faces.useMyFaces");
if (useMyFaces != null && useMyFaces) {
sysClassPath = sysClassPath.replace("javax.faces.jar", "$disabled$.raj");
// jsf-connector.jar manifest has a Class-Path to javax.faces.jar
sysClassPath = sysClassPath.replace("jsf-connector.jar", "$disabled$.raj");
}
// servletContext.getAttribute(("org.apache.catalina.jsp_classpath")
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, LogFacade.SYS_CLASSPATH, webModule.getID() + " is " + sysClassPath);
}
if (sysClassPath.equals("")) {
// In embedded mode, services returns SingleModulesRegistry and
// it has no modules.
// Try "java.class.path" system property instead.
sysClassPath = System.getProperty("java.class.path");
}
sysClassPath = trimSysClassPath(sysClassPath);
wrapper.addInitParameter("com.sun.appserv.jsp.classpath", sysClassPath);
// END SJSAS 6311155
// Configure JSP monitoring
servletContext.setAttribute("org.glassfish.jsp.monitor.probeEmitter", new JspProbeEmitterImpl(webModule));
// Pass BeanManager's ELResolver as ServletContext attribute
// (see IT 11168)
InvocationManager invocationMgr = webContainer.getInvocationManager();
WebComponentInvocation inv = new WebComponentInvocation(webModule);
try {
invocationMgr.preInvoke(inv);
JCDIService jcdiService = defaultServices.getService(JCDIService.class);
// JCDIService can be absent if weld integration is missing in the runtime, so check for null is needed.
if (jcdiService != null && jcdiService.isCurrentModuleJCDIEnabled()) {
jcdiService.setELResolver(servletContext);
}
} catch (NamingException e) {
// Ignore
} finally {
invocationMgr.postInvoke(inv);
}
}
Aggregations