Example usage for com.liferay.portal.kernel.util JavaConstants JAVAX_SERVLET_CONTEXT_TEMPDIR

List of usage examples for com.liferay.portal.kernel.util JavaConstants JAVAX_SERVLET_CONTEXT_TEMPDIR

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util JavaConstants JAVAX_SERVLET_CONTEXT_TEMPDIR.

Prototype

String JAVAX_SERVLET_CONTEXT_TEMPDIR

To view the source code for com.liferay.portal.kernel.util JavaConstants JAVAX_SERVLET_CONTEXT_TEMPDIR.

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();
    }//from ww  w. j a va  2 s  .  c  o m

    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 void setAttribute(String name, Object value) {
    if (name.equals(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR)
            || name.equals(PluginContextListener.PLUGIN_CLASS_LOADER)) {

        return;//www  .ja  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.httpservice.internal.servlet.BundleServletContext.java

License:Open Source License

protected File getTempDir() {
    if (_tempDir != null) {
        return _tempDir;
    }//from  w w  w.j  av a2 s  .  co  m

    File parentTempDir = (File) super.getAttribute(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR);

    File tempDir = new File(parentTempDir, _servletContextName);

    if (!tempDir.exists() && !tempDir.mkdirs()) {
        throw new IllegalStateException("Unable to make temporary directory " + tempDir);
    }

    _tempDir = tempDir;

    return _tempDir;
}

From source file:com.liferay.rtl.servlet.filters.dynamiccss.DynamicCSSFilter.java

License:Open Source License

protected void doInit(FilterConfig filterConfig, ServletContext servletContext) {

    super.init(filterConfig);

    _servletContext = servletContext;/*from  w  w w  .  j a v a 2  s. c o  m*/

    File tempDir = (File) servletContext.getAttribute(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR);

    _tempDir = new File(tempDir, _TEMP_DIR);

    _tempDir.mkdirs();

    DynamicCSSUtil.init();
}

From source file:com.liferay.rtl.servlet.filters.dynamiccss.DynamicCSSUtil.java

License:Open Source License

private static File _getSassTempDir(ServletContext servletContext) {
    File sassTempDir = (File) servletContext.getAttribute(_SASS_DIR_KEY);

    if (sassTempDir != null) {
        return sassTempDir;
    }//from   www .j a  v  a  2  s  . c  om

    File tempDir = (File) servletContext.getAttribute(JavaConstants.JAVAX_SERVLET_CONTEXT_TEMPDIR);

    sassTempDir = new File(tempDir, _SASS_DIR);

    sassTempDir.mkdirs();

    servletContext.setAttribute(_SASS_DIR_KEY, sassTempDir);

    return sassTempDir;
}