Search in sources :

Example 1 with WebContainer

use of org.glassfish.web.config.serverbeans.WebContainer in project Payara by payara.

the class GlassFishTldProvider method postConstruct.

public void postConstruct() {
    /*
         * Check whether JSP caching has been enabled
         */
    Config cfg = serverContext.getDefaultServices().getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
    WebContainer webContainer = cfg.getExtensionByType(WebContainer.class);
    if (webContainer == null) {
        return;
    }
    if (!Boolean.valueOf(webContainer.getJspCachingEnabled())) {
        return;
    }
    /*
         * JSP caching has been enabled
         */
    Class jspCachingImplClass = CacheTag.class;
    URI[] uris = null;
    Module m = null;
    if (jspCachingImplClass != null) {
        m = registry.find(jspCachingImplClass);
    }
    if (m != null) {
        uris = m.getModuleDefinition().getLocations();
    } else {
        ClassLoader classLoader = getClass().getClassLoader();
        if (classLoader instanceof URLClassLoader) {
            URL[] urls = ((URLClassLoader) classLoader).getURLs();
            if (urls != null && urls.length > 0) {
                uris = new URI[urls.length];
                for (int i = 0; i < urls.length; i++) {
                    try {
                        uris[i] = urls[i].toURI();
                    } catch (URISyntaxException e) {
                        String msg = rb.getString(LogFacade.TLD_PROVIDER_IGNORE_URL);
                        msg = MessageFormat.format(msg, urls[i]);
                        logger.log(Level.WARNING, msg, e);
                    }
                }
            }
        } else {
            logger.log(Level.WARNING, LogFacade.UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { "JSP Caching", classLoader, GlassFishTldProvider.class.getName() });
        }
    }
    if (uris != null && uris.length > 0) {
        Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
        for (URI uri : uris) {
            List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
            if (entries != null && entries.size() > 0) {
                tldMap.put(uri, entries);
            }
        }
    }
}
Also used : JarURIPattern(com.sun.enterprise.util.net.JarURIPattern) Pattern(java.util.regex.Pattern) Config(com.sun.enterprise.config.serverbeans.Config) WebContainer(org.glassfish.web.config.serverbeans.WebContainer) CacheTag(com.sun.appserv.web.taglibs.cache.CacheTag) Module(com.sun.enterprise.module.Module)

Example 2 with WebContainer

use of org.glassfish.web.config.serverbeans.WebContainer in project Payara by payara.

the class ServerConfigLookup method getInstanceSessionManager.

/**
 * Get the session manager bean from domain.xml
 * return null if not defined or other problem
 */
public SessionManager getInstanceSessionManager() {
    if (configBean == null) {
        return null;
    }
    WebContainer webContainerBean = configBean.getExtensionByType(WebContainer.class);
    if (webContainerBean == null) {
        return null;
    }
    SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
    if (sessionConfigBean == null) {
        return null;
    }
    return sessionConfigBean.getSessionManager();
}
Also used : WebContainer(org.glassfish.web.config.serverbeans.WebContainer)

Example 3 with WebContainer

use of org.glassfish.web.config.serverbeans.WebContainer in project Payara by payara.

the class ServerConfigLookup method getInstanceSessionProperties.

/**
 * Get the session properties bean from server.xml
 * return null if not defined or other problem
 */
public SessionProperties getInstanceSessionProperties() {
    if (configBean == null) {
        return null;
    }
    WebContainer webContainerBean = configBean.getExtensionByType(WebContainer.class);
    if (webContainerBean == null) {
        return null;
    }
    SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
    if (sessionConfigBean == null) {
        return null;
    }
    return sessionConfigBean.getSessionProperties();
}
Also used : WebContainer(org.glassfish.web.config.serverbeans.WebContainer)

Aggregations

WebContainer (org.glassfish.web.config.serverbeans.WebContainer)3 CacheTag (com.sun.appserv.web.taglibs.cache.CacheTag)1 Config (com.sun.enterprise.config.serverbeans.Config)1 Module (com.sun.enterprise.module.Module)1 JarURIPattern (com.sun.enterprise.util.net.JarURIPattern)1 Pattern (java.util.regex.Pattern)1