Example usage for javax.servlet ServletConfig getServletContext

List of usage examples for javax.servlet ServletConfig getServletContext

Introduction

In this page you can find the example usage for javax.servlet ServletConfig getServletContext.

Prototype

public ServletContext getServletContext();

Source Link

Document

Returns a reference to the ServletContext in which the caller is executing.

Usage

From source file:org.apache.chemistry.opencmis.server.impl.browser.CmisBrowserBindingServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    // initialize the call context handler
    callContextHandler = null;/*from  w  ww . j  a va 2  s. c  om*/

    String callContextHandlerClass = config.getInitParameter(PARAM_CALL_CONTEXT_HANDLER);

    if (callContextHandlerClass != null) {
        try {
            callContextHandler = (CallContextHandler) Class.forName(callContextHandlerClass).newInstance();
        } catch (Exception e) {
            throw new ServletException("Could not load call context handler: " + e, e);
        }
    }

    // get memory threshold and temp directory
    CmisServiceFactory factory = (CmisServiceFactory) config.getServletContext()
            .getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY);

    tempDir = factory.getTempDirectory();
    memoryThreshold = factory.getMemoryThreshold();

    // initialize the dispatchers
    repositoryDispatcher = new Dispatcher(false);
    rootDispatcher = new Dispatcher(false);

    try {
        repositoryDispatcher.addResource(SELECTOR_REPOSITORY_INFO, METHOD_GET, RepositoryService.class,
                "getRepositoryInfo");
        repositoryDispatcher.addResource(SELECTOR_LAST_RESULT, METHOD_GET, RepositoryService.class,
                "getLastResult");
        repositoryDispatcher.addResource(SELECTOR_TYPE_CHILDREN, METHOD_GET, RepositoryService.class,
                "getTypeChildren");
        repositoryDispatcher.addResource(SELECTOR_TYPE_DESCENDANTS, METHOD_GET, RepositoryService.class,
                "getTypeDescendants");
        repositoryDispatcher.addResource(SELECTOR_TYPE_DEFINITION, METHOD_GET, RepositoryService.class,
                "getTypeDefinition");
        repositoryDispatcher.addResource(SELECTOR_QUERY, METHOD_GET, DiscoveryService.class, "query");
        repositoryDispatcher.addResource(SELECTOR_CHECKEDOUT, METHOD_GET, NavigationService.class,
                "getCheckedOutDocs");
        repositoryDispatcher.addResource(SELECTOR_CONTENT_CHANGES, METHOD_GET, DiscoveryService.class,
                "getContentChanges");

        repositoryDispatcher.addResource(CMISACTION_QUERY, METHOD_POST, DiscoveryService.class, "query");
        repositoryDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class,
                "createDocument");
        repositoryDispatcher.addResource(CMISACTION_CREATE_DOCUMENT_FROM_SOURCE, METHOD_POST,
                ObjectService.class, "createDocumentFromSource");
        repositoryDispatcher.addResource(CMISACTION_CREATE_POLICY, METHOD_POST, ObjectService.class,
                "createPolicy");
        repositoryDispatcher.addResource(CMISACTION_CREATE_RELATIONSHIP, METHOD_POST, ObjectService.class,
                "createRelationship");

        rootDispatcher.addResource(SELECTOR_OBJECT, METHOD_GET, ObjectService.class, "getObject");
        rootDispatcher.addResource(SELECTOR_PROPERTIES, METHOD_GET, ObjectService.class, "getProperties");
        rootDispatcher.addResource(SELECTOR_ALLOWABLEACTIONS, METHOD_GET, ObjectService.class,
                "getAllowableActions");
        rootDispatcher.addResource(SELECTOR_RENDITIONS, METHOD_GET, ObjectService.class, "getRenditions");
        rootDispatcher.addResource(SELECTOR_CONTENT, METHOD_GET, ObjectService.class, "getContentStream");
        rootDispatcher.addResource(SELECTOR_CHILDREN, METHOD_GET, NavigationService.class, "getChildren");
        rootDispatcher.addResource(SELECTOR_DESCENDANTS, METHOD_GET, NavigationService.class, "getDescendants");
        rootDispatcher.addResource(SELECTOR_FOLDER_TREE, METHOD_GET, NavigationService.class, "getFolderTree");
        rootDispatcher.addResource(SELECTOR_PARENT, METHOD_GET, NavigationService.class, "getFolderParent");
        rootDispatcher.addResource(SELECTOR_PARENTS, METHOD_GET, NavigationService.class, "getObjectParents");
        rootDispatcher.addResource(SELECTOR_VERSIONS, METHOD_GET, VersioningService.class, "getAllVersions");
        rootDispatcher.addResource(SELECTOR_RELATIONSHIPS, METHOD_GET, RelationshipService.class,
                "getObjectRelationships");
        rootDispatcher.addResource(SELECTOR_CHECKEDOUT, METHOD_GET, NavigationService.class,
                "getCheckedOutDocs");
        rootDispatcher.addResource(SELECTOR_POLICIES, METHOD_GET, PolicyService.class, "getAppliedPolicies");
        rootDispatcher.addResource(SELECTOR_ACL, METHOD_GET, AclService.class, "getACL");

        rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT, METHOD_POST, ObjectService.class,
                "createDocument");
        rootDispatcher.addResource(CMISACTION_CREATE_DOCUMENT_FROM_SOURCE, METHOD_POST, ObjectService.class,
                "createDocumentFromSource");
        rootDispatcher.addResource(CMISACTION_CREATE_FOLDER, METHOD_POST, ObjectService.class, "createFolder");
        rootDispatcher.addResource(CMISACTION_CREATE_POLICY, METHOD_POST, ObjectService.class, "createPolicy");
        rootDispatcher.addResource(CMISACTION_UPDATE_PROPERTIES, METHOD_POST, ObjectService.class,
                "updateProperties");
        rootDispatcher.addResource(CMISACTION_SET_CONTENT, METHOD_POST, ObjectService.class,
                "setContentStream");
        rootDispatcher.addResource(CMISACTION_DELETE_CONTENT, METHOD_POST, ObjectService.class,
                "deleteContentStream");
        rootDispatcher.addResource(CMISACTION_DELETE, METHOD_POST, ObjectService.class, "deleteObject");
        rootDispatcher.addResource(CMISACTION_DELETE_TREE, METHOD_POST, ObjectService.class, "deleteTree");
        rootDispatcher.addResource(CMISACTION_MOVE, METHOD_POST, ObjectService.class, "moveObject");
        rootDispatcher.addResource(CMISACTION_ADD_OBJECT_TO_FOLDER, METHOD_POST, MultiFilingService.class,
                "addObjectToFolder");
        rootDispatcher.addResource(CMISACTION_REMOVE_OBJECT_FROM_FOLDER, METHOD_POST, MultiFilingService.class,
                "removeObjectFromFolder");
        rootDispatcher.addResource(CMISACTION_CHECK_OUT, METHOD_POST, VersioningService.class, "checkOut");
        rootDispatcher.addResource(CMISACTION_CANCEL_CHECK_OUT, METHOD_POST, VersioningService.class,
                "cancelCheckOut");
        rootDispatcher.addResource(CMISACTION_CHECK_IN, METHOD_POST, VersioningService.class, "checkIn");
        rootDispatcher.addResource(CMISACTION_APPLY_POLICY, METHOD_POST, PolicyService.class, "applyPolicy");
        rootDispatcher.addResource(CMISACTION_REMOVE_POLICY, METHOD_POST, PolicyService.class, "removePolicy");
        rootDispatcher.addResource(CMISACTION_APPLY_ACL, METHOD_POST, AclService.class, "applyACL");
    } catch (NoSuchMethodException e) {
        LOG.error("Cannot initialize dispatcher!", e);
    }
}

From source file:com.ecyrd.jspwiki.WikiEngine.java

/**
 *  Gets a WikiEngine related to the servlet. Works like getInstance(ServletConfig),
 *  but does not force the Properties object. This method is just an optional way
 *  of initializing a WikiEngine for embedded JSPWiki applications; normally, you
 *  should use getInstance(ServletConfig).
 *
 *  @param config The ServletConfig of the webapp servlet/JSP calling this method.
 *  @param props  A set of properties, or null, if we are to load JSPWiki's default
 *                jspwiki.properties (this is the usual case).
 *
 *  @return One well-behaving WikiEngine instance.
 *///from   www  .java  2  s. c o  m
public static synchronized WikiEngine getInstance(ServletConfig config, Properties props) {
    return getInstance(config.getServletContext(), props);
}

From source file:com.ecyrd.jspwiki.WikiEngine.java

/**
 *  Gets a WikiEngine related to this servlet.  Since this method
 *  is only called from JSP pages (and JspInit()) to be specific,
 *  we throw a RuntimeException if things don't work.
 *
 *  @param config The ServletConfig object for this servlet.
 *
 *  @return A WikiEngine instance.//  w w  w  .java2  s  .  co  m
 *  @throws InternalWikiException in case something fails.  This
 *          is a RuntimeException, so be prepared for it.
 */

// FIXME: It seems that this does not work too well, jspInit()
// does not react to RuntimeExceptions, or something...

public static synchronized WikiEngine getInstance(ServletConfig config) throws InternalWikiException {
    return getInstance(config.getServletContext(), null);
}

From source file:org.hippoecm.repository.RepositoryServlet.java

private void parseInitParameters(ServletConfig config) throws ServletException {
    bindingAddress = getConfigurationParameter(REPOSITORY_BINDING_PARAM, DEFAULT_REPOSITORY_BINDING);
    repositoryConfig = getConfigurationParameter(REPOSITORY_CONFIG_PARAM, DEFAULT_REPOSITORY_CONFIG);
    storageLocation = getConfigurationParameter(REPOSITORY_DIRECTORY_PARAM, DEFAULT_REPOSITORY_DIRECTORY);
    startRemoteServer = Boolean//from   ww w. j av a 2s  . c  om
            .valueOf(getConfigurationParameter(START_REMOTE_SERVER, DEFAULT_START_REMOTE_SERVER));

    // check for absolute path
    if (!storageLocation.startsWith("/") && !storageLocation.startsWith("file:")) {
        // try to parse the relative path
        final String storagePath = config.getServletContext().getRealPath("/" + storageLocation);

        // ServletContext#getRealPath() may return null especially when unpackWARs="false".
        if (storagePath == null) {
            log.warn(
                    "Cannot determine the real path of the repository storage location, '{}'. Defaults to './{}'",
                    storageLocation, DEFAULT_REPOSITORY_DIRECTORY_UNDER_CURRENT_WORKING_DIR);
            storageLocation = DEFAULT_REPOSITORY_DIRECTORY_UNDER_CURRENT_WORKING_DIR;
        } else {
            storageLocation = storagePath;
        }
    }
}

From source file:org.wso2.carbon.identity.entitlement.filter.EntitlementCacheUpdateServlet.java

@Override
public void init(ServletConfig config) throws EntitlementCacheUpdateServletException {

    EntitlementCacheUpdateServletDataHolder.getInstance().setServletConfig(config);
    try {//w ww.j a v  a  2s.  co m
        EntitlementCacheUpdateServletDataHolder.getInstance()
                .setConfigCtx(ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null));
    } catch (AxisFault e) {
        log.error("Error while initializing Configuration Context", e);
        throw new EntitlementCacheUpdateServletException("Error while initializing Configuration Context", e);

    }

    EntitlementCacheUpdateServletDataHolder.getInstance()
            .setHttpsPort(config.getInitParameter(EntitlementConstants.HTTPS_PORT));
    EntitlementCacheUpdateServletDataHolder.getInstance()
            .setAuthentication(config.getInitParameter(EntitlementConstants.AUTHENTICATION));
    EntitlementCacheUpdateServletDataHolder.getInstance().setRemoteServiceUrl(
            config.getServletContext().getInitParameter(EntitlementConstants.REMOTE_SERVICE_URL));
    EntitlementCacheUpdateServletDataHolder.getInstance().setRemoteServiceUserName(
            config.getServletContext().getInitParameter(EntitlementConstants.USERNAME));
    EntitlementCacheUpdateServletDataHolder.getInstance().setRemoteServicePassword(
            config.getServletContext().getInitParameter(EntitlementConstants.PASSWORD));
    EntitlementCacheUpdateServletDataHolder.getInstance()
            .setAuthenticationPage(config.getInitParameter(EntitlementConstants.AUTHENTICATION_PAGE));
    EntitlementCacheUpdateServletDataHolder.getInstance()
            .setAuthenticationPageURL(config.getInitParameter(EntitlementConstants.AUTHENTICATION_PAGE_URL));

}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.RegistryService.java

@Override
public void service(ServletConfig config, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String servicePath = request.getRequestURI();
    if (request.getRequestURI().startsWith(request.getContextPath()))
        servicePath = request.getRequestURI().substring(request.getContextPath().length());

    String[] cmd = servicePath.trim().split("/+");
    if (cmd.length < 2) {
        emit404(request, response);/*w  w  w .j  a  v  a  2 s. c  o  m*/
        return;
    }
    String action = cmd[2];

    if (ACTION_ENGINE_REGISTRATION.equals(action)) {

        String eng_uri = request.getParameter("enguri");
        String pilot_uri = request.getParameter("piloturi");

        if (eng_uri == null || eng_uri.trim().isEmpty()) {

            response.getWriter().print("error");
            LOG.info("Erroneous registration: engine='" + eng_uri + "', pilot='" + pilot_uri + "'");

        } else {

            IZone assignedZone = null;
            Configuration conf = (Configuration) config.getServletContext().getAttribute("configuration");
            for (IZone zone : conf.getZoneSet()) {
                if (zone.getZoneEngineUrl() != null && eng_uri.equals(zone.getZoneEngineUrl())) {
                    assignedZone = zone;
                    break;
                }
            }

            @SuppressWarnings("unchecked")
            Map<String, IRegistrationData> regdata = (Map<String, IRegistrationData>) config.getServletContext()
                    .getAttribute("regdata");

            if (pilot_uri == null || pilot_uri.trim().isEmpty()) {
                // No sensors available, which is OK. This is a central engine.
                LOG.info("Sucessful registration: central engine='" + eng_uri + "'");
                regdata.put(eng_uri.trim(), new RegData(eng_uri, null, null, null, null, assignedZone));

                @SuppressWarnings("unchecked")
                Set<String> centralEngines = (Set<String>) config.getServletContext()
                        .getAttribute("centralEngines");
                centralEngines.add(eng_uri.trim());

            } else {
                LOG.info("Sucessful registration: engine='" + eng_uri + "', pilot='" + pilot_uri + "'");

                LOG.info("Retrieving way-point list:");
                List<IWayPoint> wayPointList = null;
                try {
                    wayPointList = WayPointQueryService.getWayPointList(pilot_uri);
                    for (IWayPoint p : wayPointList)
                        LOG.info("Waypoint: " + p);
                } catch (ParseException e) {
                    LOG.error("Error at retrieving way-point list", e);
                }

                LOG.info("Retrieving available sensors:");
                SensorProxy sensorProxy = new SensorProxy();
                sensorProxy.setPilotUrl(pilot_uri);
                Set<String> sensors = null;
                Map<String, String> pilotConfig = null;
                try {
                    sensors = sensorProxy.getAvailableSensors();

                    for (String sensor : sensors) {
                        LOG.info("Sensor: " + sensor);
                    }

                    pilotConfig = sensorProxy.getPilotConfig();
                    LOG.info("Pilot configuration: " + pilotConfig);

                } catch (ParseException e) {
                    LOG.error("Error at retrieving available sensors", e);
                }

                regdata.put(eng_uri.trim(),
                        new RegData(eng_uri, pilot_uri, wayPointList, sensors, pilotConfig, assignedZone));

            }

            response.getWriter().print("ok");

            File registryFile = (File) config.getServletContext().getAttribute("registryFile");
            RegistryPersistence.storeRegistry(registryFile, regdata);
        }
        return;

    } else {
        LOG.error("Can not handle: " + servicePath);
        emit404(request, response);
        return;
    }

}

From source file:eu.impact_project.iif.t2.client.WorkflowRunnerTest.java

/**
 * Test of doPost method, of class WorkflowRunner.
 *///from  ww w.ja v a  2s.  c o m
@Test
public void testDoPostURLFail() throws Exception {
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);
    ServletConfig config = mock(ServletConfig.class);
    ServletContext context = mock(ServletContext.class);
    RequestDispatcher dispatcher = mock(RequestDispatcher.class);
    ServletOutputStream stream = mock(ServletOutputStream.class);
    HttpSession session = mock(HttpSession.class);

    when(request.getSession(true)).thenReturn(session);

    ArrayList<Workflow> flowList = new ArrayList<>();
    Workflow flow = new Workflow();
    flow.setStringVersion("Esto es una prueba");
    flow.setWsdls("<wsdl>http://www.ua.es</wsdl>");
    flow.setUrls("http://falsa.es");

    ArrayList<WorkflowInput> flowInputs = new ArrayList<>();
    WorkflowInput input = new WorkflowInput("pru0Input");
    input.setDepth(1);
    flowInputs.add(input);

    input = new WorkflowInput("pru1Input");
    input.setDepth(0);
    flowInputs.add(input);

    flow.setInputs(flowInputs);

    flowList.add(flow);
    when(session.getAttribute("workflows")).thenReturn(flowList);

    when(config.getServletContext()).thenReturn(context);
    URL url = this.getClass().getResource("/config.properties");
    File testFile = new File(url.getFile());
    when(context.getRealPath("/")).thenReturn(testFile.getParent() + "/");

    Part[] parts = new Part[] { new StringPart("user", "user"), new StringPart("pass", "pass"),
            new StringPart("workflow0pru0Input", "prueba0"), new StringPart("workflow0pru0Input0", "prueba0.0"),
            new StringPart("workflow0pru1Input", "prueba1")

    };

    MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts,
            new PostMethod().getParams());

    ByteArrayOutputStream requestContent = new ByteArrayOutputStream();

    multipartRequestEntity.writeRequest(requestContent);

    final ByteArrayInputStream inputContent = new ByteArrayInputStream(requestContent.toByteArray());

    when(request.getInputStream()).thenReturn(new ServletInputStream() {
        @Override
        public int read() throws IOException {
            return inputContent.read();
        }
    });

    when(request.getContentType()).thenReturn(multipartRequestEntity.getContentType());

    WorkflowRunner runer = new WorkflowRunner();
    try {
        runer.init(config);
        runer.doPost(request, response);

    } catch (ServletException ex) {
        fail("Should not raise exception " + ex.toString());
    } catch (IOException ex) {
        fail("Should not raise exception " + ex.toString());
    } catch (NullPointerException ex) {
        //ok no funciona el server de taverna
    }
}

From source file:eu.impact_project.iif.t2.client.WorkflowRunnerTest.java

/**
 * Test of doPost method, of class WorkflowRunner.
 *///from  w w  w .  j  a  va 2  s  . com
@Test
public void testDoPost() throws Exception {
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);
    ServletConfig config = mock(ServletConfig.class);
    ServletContext context = mock(ServletContext.class);
    RequestDispatcher dispatcher = mock(RequestDispatcher.class);
    ServletOutputStream stream = mock(ServletOutputStream.class);
    HttpSession session = mock(HttpSession.class);

    when(request.getSession(true)).thenReturn(session);

    ArrayList<Workflow> flowList = new ArrayList<>();
    Workflow flow = new Workflow();
    flow.setStringVersion("Esto es una prueba");
    flow.setWsdls("<wsdl>http://www.ua.es</wsdl>");
    flow.setUrls("http://www.ua.es");

    ArrayList<WorkflowInput> flowInputs = new ArrayList<>();
    WorkflowInput input = new WorkflowInput("pru0Input");
    input.setDepth(1);
    flowInputs.add(input);

    input = new WorkflowInput("pru1Input");
    input.setDepth(0);
    flowInputs.add(input);

    flow.setInputs(flowInputs);

    flowList.add(flow);
    when(session.getAttribute("workflows")).thenReturn(flowList);

    when(config.getServletContext()).thenReturn(context);
    URL url = this.getClass().getResource("/config.properties");
    File testFile = new File(url.getFile());
    when(context.getRealPath("/")).thenReturn(testFile.getParent() + "/");

    Part[] parts = new Part[] { new StringPart("user", "user"), new StringPart("pass", "pass"),
            new StringPart("workflow0pru0Input", "prueba0"), new StringPart("workflow0pru0Input0", "prueba0.0"),
            new StringPart("workflow0pru1Input", "prueba1")

    };

    MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts,
            new PostMethod().getParams());

    ByteArrayOutputStream requestContent = new ByteArrayOutputStream();

    multipartRequestEntity.writeRequest(requestContent);

    final ByteArrayInputStream inputContent = new ByteArrayInputStream(requestContent.toByteArray());

    when(request.getInputStream()).thenReturn(new ServletInputStream() {
        @Override
        public int read() throws IOException {
            return inputContent.read();
        }
    });

    when(request.getContentType()).thenReturn(multipartRequestEntity.getContentType());

    WorkflowRunner runer = new WorkflowRunner();
    try {
        runer.init(config);
        runer.doPost(request, response);

    } catch (ServletException ex) {
        fail("Should not raise exception " + ex.toString());
    } catch (IOException ex) {
        fail("Should not raise exception " + ex.toString());
    } catch (NullPointerException ex) {
        //ok no funciona el server de taverna
    }
}

From source file:lucee.runtime.engine.CFMLEngineImpl.java

/**
 * loads Configuration File from System, from init Parameter from web.xml
 * @param sg/*from w  w w  .ja v  a 2  s . c om*/
 * @param configServer 
 * @param countExistingContextes 
 * @return return path to directory
 */
private Resource getConfigDirectory(ServletConfig sg, ConfigServerImpl configServer, int countExistingContextes,
        RefBoolean isCustomSetting) throws PageServletException {
    isCustomSetting.setValue(true);
    ServletContext sc = sg.getServletContext();
    String strConfig = sg.getInitParameter("configuration");
    if (StringUtil.isEmpty(strConfig))
        strConfig = sg.getInitParameter("lucee-web-directory");
    if (StringUtil.isEmpty(strConfig))
        strConfig = System.getProperty("lucee.web.dir");

    if (StringUtil.isEmpty(strConfig)) {
        isCustomSetting.setValue(false);
        strConfig = "{web-root-directory}/WEB-INF/lucee/";
    }
    // only for backward compatibility
    else if (strConfig.startsWith("/WEB-INF/lucee/"))
        strConfig = "{web-root-directory}" + strConfig;

    strConfig = StringUtil.removeQuotes(strConfig, true);

    // static path is not allowed
    if (countExistingContextes > 1 && strConfig != null && strConfig.indexOf('{') == -1) {
        String text = "static path [" + strConfig
                + "] for servlet init param [lucee-web-directory] is not allowed, path must use a web-context specific placeholder.";
        System.err.println(text);
        throw new PageServletException(new ApplicationException(text));
    }
    strConfig = SystemUtil.parsePlaceHolder(strConfig, sc, configServer.getLabels());

    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
    Resource root = frp.getResource(ReqRspUtil.getRootPath(sc));
    Resource configDir = ResourceUtil.createResource(root.getRealResource(strConfig),
            FileUtil.LEVEL_PARENT_FILE, FileUtil.TYPE_DIR);

    if (configDir == null) {
        configDir = ResourceUtil.createResource(frp.getResource(strConfig), FileUtil.LEVEL_GRAND_PARENT_FILE,
                FileUtil.TYPE_DIR);
    }
    if (configDir == null)
        throw new PageServletException(new ApplicationException("path [" + strConfig + "] is invalid"));

    if (!configDir.exists() || ResourceUtil.isEmptyDirectory(configDir, null)) {
        Resource railoRoot;
        // there is a railo directory
        if (configDir.getName().equals("lucee")
                && (railoRoot = configDir.getParentResource().getRealResource("railo")).isDirectory()) {
            try {
                copyRecursiveAndRename(railoRoot, configDir);
            } catch (IOException e) {
                try {
                    configDir.createDirectory(true);
                } catch (IOException ioe) {
                }
                return configDir;
            }
            // zip the railo-server di and delete it (optional)
            try {
                Resource p = railoRoot.getParentResource();
                CompressUtil.compress(CompressUtil.FORMAT_ZIP, railoRoot,
                        p.getRealResource("railo-web-context-old.zip"), false, -1);
                ResourceUtil.removeEL(railoRoot, true);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        } else {
            try {
                configDir.createDirectory(true);
            } catch (IOException e) {
            }
        }
    }
    return configDir;
}

From source file:org.jahia.services.atmosphere.AtmosphereServlet.java

@Override
public void init(final ServletConfig sc) throws ServletException {
    ServletConfig scFacade;/*from   ww w  .  jav a 2 s. com*/

    String asyncSupport = SettingsBean.getInstance().getAtmosphereAsyncSupport();
    // override asyncSupport only if explicitly set via jahia.properties or not set at all
    if (StringUtils.isNotEmpty(asyncSupport) || sc.getInitParameter(PROPERTY_COMET_SUPPORT) == null) {
        final String implName = StringUtils.defaultIfBlank(asyncSupport, DEFAULT_ASYNC_SUPPORT);
        scFacade = new ServletConfig() {
            @Override
            public String getInitParameter(String name) {
                return PROPERTY_COMET_SUPPORT.equals(name) ? implName : sc.getInitParameter(name);
            }

            @Override
            public Enumeration<String> getInitParameterNames() {
                ArrayList<String> names = Lists.newArrayList(PROPERTY_COMET_SUPPORT);
                CollectionUtils.addAll(names, sc.getInitParameterNames());
                return Collections.enumeration(names);
            }

            @Override
            public ServletContext getServletContext() {
                return sc.getServletContext();
            }

            @Override
            public String getServletName() {
                return sc.getServletName();
            }
        };
    } else {
        scFacade = sc;
    }

    super.init(scFacade);
}