Example usage for com.liferay.portal.kernel.servlet PluginContextListener PLUGIN_CLASS_LOADER

List of usage examples for com.liferay.portal.kernel.servlet PluginContextListener PLUGIN_CLASS_LOADER

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet PluginContextListener PLUGIN_CLASS_LOADER.

Prototype

String PLUGIN_CLASS_LOADER

To view the source code for com.liferay.portal.kernel.servlet PluginContextListener PLUGIN_CLASS_LOADER.

Click Source Link

Usage

From source file:com.liferay.httpservice.internal.servlet.BundleServletContext.java

License:Open Source License

@Override
public Object getAttribute(String name) {
    if (name.equals(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR)) {
        return getTempDir();
    } else if (name.equals("osgi-bundle")) {
        return _bundle;
    } else if (name.equals("osgi-bundlecontext")) {
        return _bundle.getBundleContext();
    }//  w ww  .jav a  2 s. c  om

    Object value = _contextAttributes.get(name);

    if (value == null) {
        if (name.equals(PluginContextListener.PLUGIN_CLASS_LOADER)) {
            return getClassLoader();
        } else if (name.equals("org.apache.catalina.JSP_PROPERTY_GROUPS")) {
            value = new HashMap<Object, Object>();

            _contextAttributes.put(name, value);
        } else if (name.equals("org.apache.tomcat.InstanceManager")) {
            return super.getAttribute(name);
        }
    }

    return value;
}

From source file:com.liferay.httpservice.internal.servlet.BundleServletContext.java

License:Open Source License

@Override
public ClassLoader getClassLoader() {
    ClassLoader classLoader = (ClassLoader) _contextAttributes.get(PluginContextListener.PLUGIN_CLASS_LOADER);

    if (classLoader == null) {
        BundleWiring bundleWiring = _bundle.adapt(BundleWiring.class);

        classLoader = bundleWiring.getClassLoader();

        _contextAttributes.put(PluginContextListener.PLUGIN_CLASS_LOADER, classLoader);
    }//from www. j  ava2 s. c  om

    return classLoader;
}

From source file:com.liferay.httpservice.internal.servlet.BundleServletContext.java

License:Open Source License

@Override
public void setAttribute(String name, Object value) {
    if (name.equals(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR)
            || name.equals(PluginContextListener.PLUGIN_CLASS_LOADER)) {

        return;//w ww. j  a v a  2  s. c  o m
    }

    Object originalValue = _contextAttributes.get(name);

    _contextAttributes.put(name, value);

    for (ServletContextAttributeListener servletContextAttributeListener : _servletContextAttributeListeners) {

        ServletContextAttributeEvent servletContextAttributeEvent = new ServletContextAttributeEvent(this, name,
                value);

        if (originalValue != null) {
            servletContextAttributeListener.attributeReplaced(servletContextAttributeEvent);
        } else {
            servletContextAttributeListener.attributeAdded(servletContextAttributeEvent);
        }
    }
}

From source file:com.liferay.scriptingexecutor.util.ClassLoaderUtil.java

License:Open Source License

private static ClassLoader _getPluginClassLoader(String servletContextName) {

    ServletContext servletContext = ServletContextPool.get(servletContextName);

    ClassLoader pluginClassLoader = (ClassLoader) servletContext
            .getAttribute(PluginContextListener.PLUGIN_CLASS_LOADER);

    return pluginClassLoader;
}