Example usage for javax.servlet ServletContext setAttribute

List of usage examples for javax.servlet ServletContext setAttribute

Introduction

In this page you can find the example usage for javax.servlet ServletContext setAttribute.

Prototype

public void setAttribute(String name, Object object);

Source Link

Document

Binds an object to a given attribute name in this ServletContext.

Usage

From source file:com.ikon.servlet.admin.RepositoryViewServlet.java

/**
 * List node properties and children/* w  ww .  j  av a2  s. c om*/
 */
private void list(Session session, String path, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, javax.jcr.PathNotFoundException, RepositoryException {
    log.debug("list({}, {}, {}, {})", new Object[] { session, path, request, response });
    String stats = WebUtils.getString(request, "stats");
    String uuid = WebUtils.getString(request, "uuid");
    ServletContext sc = getServletContext();
    ContentInfo ci = null;
    Node node = null;

    // Respository stats calculation
    if (!stats.equals("")) {
        if (stats.equals("0")) {
            request.getSession().removeAttribute("stats");
        } else {
            request.getSession().setAttribute("stats", true);
        }
    }

    // Handle path or uuid
    if (!path.equals("")) {
        if (path.equals("/")) {
            node = session.getRootNode();
        } else {
            node = session.getRootNode().getNode(path.substring(1));
        }
    } else if (!uuid.equals("")) {
        node = session.getNodeByUUID(uuid);
        path = node.getPath();
    } else {
        node = session.getRootNode();
    }

    if (request.getSession().getAttribute("stats") != null && node.isNodeType(Folder.TYPE)) {
        try {
            ci = OKMFolder.getInstance().getContentInfo(null, node.getPath());
        } catch (AccessDeniedException e) {
            log.warn(e.getMessage(), e);
        } catch (com.ikon.core.RepositoryException e) {
            log.warn(e.getMessage(), e);
        } catch (PathNotFoundException e) {
            log.warn(e.getMessage(), e);
        } catch (DatabaseException e) {
            log.warn(e.getMessage(), e);
        }
    }

    // Activity log
    if (node.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
        UserActivity.log(session.getUserID(), "ADMIN_REPOSITORY_LIST", node.getUUID(), node.getPath(), null);
    } else {
        UserActivity.log(session.getUserID(), "ADMIN_REPOSITORY_LIST", ((NodeImpl) node).getId().toString(),
                node.getPath(), null);
    }

    sc.setAttribute("contentInfo", ci);
    sc.setAttribute("node", node);
    sc.setAttribute("isFolder", node.isNodeType(Folder.TYPE));
    sc.setAttribute("isDocument", node.isNodeType(Document.TYPE));
    sc.setAttribute("isDocumentContent", node.isNodeType(Document.CONTENT_TYPE));
    sc.setAttribute("isScripting", node.isNodeType(Scripting.TYPE));
    sc.setAttribute("holdsLock", node.holdsLock());
    sc.setAttribute("breadcrumb", createBreadcrumb(node.getPath()));
    sc.setAttribute("properties", getProperties(node));
    sc.setAttribute("children", getChildren(node));
    sc.getRequestDispatcher("/admin/repository_list.jsp").forward(request, response);
    log.debug("list: void");
}

From source file:com.openkm.servlet.admin.RepositoryViewServlet.java

/**
 * List node properties and children//from w  w w  .j a  v a2  s .  com
 */
private void list(Session session, String path, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, javax.jcr.PathNotFoundException, RepositoryException {
    log.debug("list({}, {}, {}, {})", new Object[] { session, path, request, response });
    String stats = WebUtils.getString(request, "stats");
    String uuid = WebUtils.getString(request, "uuid");
    ServletContext sc = getServletContext();
    ContentInfo ci = null;
    Node node = null;

    // Respository stats calculation
    if (!stats.equals("")) {
        if (stats.equals("0")) {
            request.getSession().removeAttribute("stats");
        } else {
            request.getSession().setAttribute("stats", true);
        }
    }

    // Handle path or uuid
    if (!path.equals("")) {
        if (path.equals("/")) {
            node = session.getRootNode();
        } else {
            node = session.getRootNode().getNode(path.substring(1));
        }
    } else if (!uuid.equals("")) {
        node = session.getNodeByUUID(uuid);
        path = node.getPath();
    } else {
        node = session.getRootNode();
    }

    if (request.getSession().getAttribute("stats") != null && node.isNodeType(Folder.TYPE)) {
        try {
            ci = OKMFolder.getInstance().getContentInfo(null, node.getPath());
        } catch (AccessDeniedException e) {
            log.warn(e.getMessage(), e);
        } catch (com.openkm.core.RepositoryException e) {
            log.warn(e.getMessage(), e);
        } catch (PathNotFoundException e) {
            log.warn(e.getMessage(), e);
        } catch (DatabaseException e) {
            log.warn(e.getMessage(), e);
        }
    }

    // Activity log
    if (node.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
        UserActivity.log(session.getUserID(), "ADMIN_REPOSITORY_LIST", node.getUUID(), node.getPath(), null);
    } else {
        UserActivity.log(session.getUserID(), "ADMIN_REPOSITORY_LIST", ((NodeImpl) node).getId().toString(),
                node.getPath(), null);
    }

    sc.setAttribute("contentInfo", ci);
    sc.setAttribute("node", node);
    sc.setAttribute("isFolder", node.isNodeType(Folder.TYPE));
    sc.setAttribute("isDocument", node.isNodeType(Document.TYPE));
    sc.setAttribute("isDocumentContent", node.isNodeType(Document.CONTENT_TYPE));
    sc.setAttribute("isScripting", node.isNodeType(Scripting.TYPE));
    sc.setAttribute("holdsLock", node.holdsLock());
    sc.setAttribute("breadcrumb", createBreadcrumb(node.getPath()));
    sc.setAttribute("properties", getProperties(node));
    sc.setAttribute("children", getChildren(node));
    sc.getRequestDispatcher("/admin/repository_list.jsp").forward(request, response);
    log.debug("list: void");
}

From source file:org.springframework.web.context.ContextLoader.java

/**
 * Initialize Spring's web application context for the given servlet context,
 * using the application context provided at construction time, or creating a new one
 * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and
 * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params.
 * @param servletContext current servlet context
 * @return the new WebApplicationContext
 * @see #ContextLoader(WebApplicationContext)
 * @see #CONTEXT_CLASS_PARAM/*from   w ww .  j a  v  a2s.  c o m*/
 * @see #CONFIG_LOCATION_PARAM
 */
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
    if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
        throw new IllegalStateException(
                "Cannot initialize context because there is already a root application context present - "
                        + "check whether you have multiple ContextLoader* definitions in your web.xml!");
    }

    Log logger = LogFactory.getLog(ContextLoader.class);
    servletContext.log("Initializing Spring root WebApplicationContext");
    if (logger.isInfoEnabled()) {
        logger.info("Root WebApplicationContext: initialization started");
    }
    long startTime = System.currentTimeMillis();

    try {
        // Store context in local instance variable, to guarantee that
        // it is available on ServletContext shutdown.
        if (this.context == null) {
            this.context = createWebApplicationContext(servletContext);
        }
        if (this.context instanceof ConfigurableWebApplicationContext) {
            ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context;
            if (!cwac.isActive()) {
                // The context has not yet been refreshed -> provide services such as
                // setting the parent context, setting the application context id, etc
                if (cwac.getParent() == null) {
                    // The context instance was injected without an explicit parent ->
                    // determine parent for root web application context, if any.
                    ApplicationContext parent = loadParentContext(servletContext);
                    cwac.setParent(parent);
                }
                configureAndRefreshWebApplicationContext(cwac, servletContext);
            }
        }
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

        ClassLoader ccl = Thread.currentThread().getContextClassLoader();
        if (ccl == ContextLoader.class.getClassLoader()) {
            currentContext = this.context;
        } else if (ccl != null) {
            currentContextPerThread.put(ccl, this.context);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Published root WebApplicationContext as ServletContext attribute with name ["
                    + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }
        if (logger.isInfoEnabled()) {
            long elapsedTime = System.currentTimeMillis() - startTime;
            logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
        }

        return this.context;
    } catch (RuntimeException ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    } catch (Error err) {
        logger.error("Context initialization failed", err);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
        throw err;
    }
}

From source file:com.rapid.server.RapidServletContextListener.java

public static int loadThemes(ServletContext servletContext) throws Exception {

    // assume no themes
    int themeCount = 0;

    // create a list for our themes
    List<Theme> themes = new ArrayList<Theme>();

    // get the directory in which the control xml files are stored
    File dir = new File(servletContext.getRealPath("/WEB-INF/themes/"));

    // create a filter for finding .control.xml files
    FilenameFilter xmlFilenameFilter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".theme.xml");
        }//from   w  w w .  j  a v a  2s .  c o  m
    };

    // create a schema object for the xsd
    Schema schema = _schemaFactory
            .newSchema(new File(servletContext.getRealPath("/WEB-INF/schemas/") + "/theme.xsd"));
    // create a validator
    Validator validator = schema.newValidator();

    // loop the xml files in the folder
    for (File xmlFile : dir.listFiles(xmlFilenameFilter)) {

        // get a scanner to read the file
        Scanner fileScanner = new Scanner(xmlFile).useDelimiter("\\A");

        // read the xml into a string
        String xml = fileScanner.next();

        // close the scanner (and file)
        fileScanner.close();

        // validate the control xml file against the schema
        validator.validate(new StreamSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))));

        // create a theme object from the xml
        Theme theme = new Theme(xml);

        // add it to our collection
        themes.add(theme);

        // inc the template count
        themeCount++;

    }

    // sort the list of templates by name
    Collections.sort(themes, new Comparator<Theme>() {
        @Override
        public int compare(Theme t1, Theme t2) {
            return Comparators.AsciiCompare(t1.getName(), t2.getName(), false);
        }

    });

    // put the jsonControls in a context attribute (this is available via the getJsonControls method in RapidHttpServlet)
    servletContext.setAttribute("themes", themes);

    _logger.info(themeCount + " templates loaded in .template.xml files");

    return themeCount;

}

From source file:net.ontopia.topicmaps.webed.impl.utils.TagUtils.java

protected static VelocityEngine getVelocityEngine(ServletContext scontext) {
    VelocityEngine vengine = (VelocityEngine) scontext.getAttribute(Constants.SCTXT_VELOCITY_ENGINE);

    if (vengine == null) {

        // create a new velocity engine
        vengine = new VelocityEngine();

        // --- try to get properties from an own file
        String relPath = scontext.getInitParameter(Constants.SCTXT_VELOPROPS_PATH);
        if (relPath != null) {
            String velocityPropPath = scontext.getRealPath(relPath);
            log.info("Initialising velocity from property file: " + velocityPropPath);
            // load in properties
            Properties props = new Properties();
            try {
                props.load(new java.io.FileInputStream(velocityPropPath));
            } catch (java.io.IOException ioe) {
                throw new OntopiaRuntimeException(ioe);
            }/*from   www.  jav  a2 s .  c o  m*/
            // pre-cat the real directory
            String path = props.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH, null);
            if (path != null) {
                path = scontext.getRealPath(path);
                props.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
            } else {
                // no directory set, use default loader (classpath) for default templates
                props.setProperty("resource.loader", "class");
                props.setProperty("class.resource.loader.class",
                        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
                props.setProperty("class.resource.loader.cache", "true");
            }
            try {
                vengine.init(props);
            } catch (Exception e) {
                throw new OntopiaRuntimeException(e);
            }
        } else {
            log.info("Initializing velocity with default properties.");
            // use class resource loaders
            Properties props = new Properties();
            props.setProperty("resource.loader", "class");
            props.setProperty("class.resource.loader.class",
                    "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
            props.setProperty("class.resource.loader.cache", "true");
            // use log4j logging system
            props.setProperty("runtime.log.system", "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
            props.setProperty("runtime.log.logsystem.log4j.category", "net.ontopia.velocity");
            props.setProperty("runtime.log", "velocity.log");
            try {
                vengine.init(props);
            } catch (Exception e) {
                throw new OntopiaRuntimeException(e);
            }
        }

        // add velocity engine to servlet context
        scontext.setAttribute(Constants.SCTXT_VELOCITY_ENGINE, vengine);
    }
    return vengine;
}

From source file:org.wso2.carbon.protobuf.listener.ProtobufServletContainerInitializer.java

@Override
public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException {

    if (classes == null || classes.size() == 0) {
        return;//from   w  w w.j  a  v a2 s.  c o m
    }
    // adding a listener to remove services when wars are undeployed
    servletContext.addListener(new ProtobufServletContextListener());
    // keeps track of PB services in a PB war
    // Please note that, a PB war can contain many PB services
    List<ProtobufServiceData> serviceList = new ArrayList<ProtobufServiceData>();
    // servlet to display proto files (like WSDL files)
    ServletRegistration.Dynamic dynamic = servletContext.addServlet("ProtoBufServlet", ProtobufServlet.class);

    for (Class<?> clazz : classes) {
        // Getting binary service registry
        ProtobufRegistry binaryServiceRegistry = (ProtobufRegistry) PrivilegedCarbonContext
                .getThreadLocalCarbonContext().getOSGiService(ProtobufRegistry.class);
        // Is it a blocking service or not
        boolean blocking = clazz.getAnnotation(ProtobufService.class).blocking();
        Method reflectiveMethod = null;
        Object serviceObj = null;
        String serviceName;
        String serviceType;
        try {
            if (blocking) {
                // getting newReflectiveBlocking method which will return a
                // blocking service
                reflectiveMethod = clazz.getInterfaces()[0].getDeclaringClass()
                        .getMethod("newReflectiveBlockingService", clazz.getInterfaces()[0]);
                // Since it is a static method, we pass null
                serviceObj = reflectiveMethod.invoke(null, clazz.newInstance());
                BlockingService blockingService = (BlockingService) serviceObj;
                // register service into Binary Service Registry
                serviceName = binaryServiceRegistry.registerBlockingService(blockingService);
                serviceType = "BlockingService";
                // keeps PB service information in a bean
                // we need these when removing the services from Binary
                // Service Registry
                // we are using these beans instances inside our destroyer
                serviceList.add(new ProtobufServiceData(serviceName, serviceType));
                servletContext.setAttribute("services", serviceList);
                dynamic.addMapping("/");
            } else {
                // getting newReflectiveService which will return a non
                // blocking service
                reflectiveMethod = clazz.getInterfaces()[0].getDeclaringClass()
                        .getMethod("newReflectiveService", clazz.getInterfaces()[0]);
                // Since it is a static method, we pass null
                serviceObj = reflectiveMethod.invoke(null, clazz.newInstance());
                Service service = (Service) serviceObj;
                // register service into Binary Service Registry
                serviceName = binaryServiceRegistry.registerService(service);
                serviceType = "NonBlockingService";
                // keeps PB service information in a bean
                // we need these information to remove the service from
                // Binary Service Registry later
                // we are using these bean instances in our destroyer
                serviceList.add(new ProtobufServiceData(serviceName, serviceType));
                servletContext.setAttribute("services", serviceList);
                dynamic.addMapping("/");
            }
        } catch (InvocationTargetException e) {
            String msg = "InvocationTargetException" + e.getLocalizedMessage();
            log.error(msg, e);
        } catch (NoSuchMethodException e) {
            String msg = "NoSuchMethodException" + e.getLocalizedMessage();
            log.error(msg, e);
        } catch (InstantiationException e) {
            String msg = "InstantiationException" + e.getLocalizedMessage();
            log.error(msg, e);
        } catch (IllegalAccessException e) {
            String msg = "IllegalAccessException" + e.getLocalizedMessage();
            log.error(msg, e);
        }
    }
}

From source file:org.apache.click.ClickServlet.java

/**
 * Initialize the Click application <tt>ConfigService</tt> instance and bind
 * it as a ServletContext attribute using the key
 * "<tt>org.apache.click.service.ConfigService</tt>".
 * <p/>//from  w ww.  j a  v  a 2  s .c  om
 * This method will use the configuration service class specified by the
 * {@link #CONFIG_SERVICE_CLASS} parameter, otherwise it will create a
 * {@link org.apache.click.service.XmlConfigService} instance.
 *
 * @param servletContext the servlet context to retrieve the
 * {@link #CONFIG_SERVICE_CLASS} from
 * @throws RuntimeException if the configuration service cannot be
 * initialized
 */
void initConfigService(ServletContext servletContext) {

    if (configService != null) {
        try {

            // Note this order is very important as components need to lookup
            // the configService out of the ServletContext while the service
            // is being initialized.
            servletContext.setAttribute(ConfigService.CONTEXT_NAME, configService);

            // Initialize the ConfigService instance
            configService.onInit(servletContext);

        } catch (Exception e) {

            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            } else {
                throw new RuntimeException(e);
            }
        }
    }
}

From source file:com.dhcc.framework.web.context.DhccContextLoader.java

/**
 * Initialize Spring's web application context for the given servlet context,
 * using the application context provided at construction time, or creating a new one
 * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and
 * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params.
 * @param servletContext current servlet context
 * @return the new WebApplicationContext
 * @see #ContextLoader(WebApplicationContext)
 * @see #CONTEXT_CLASS_PARAM/*from  w w  w . ja  va  2 s  .c o  m*/
 * @see #CONFIG_LOCATION_PARAM
 */
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
    if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
        throw new IllegalStateException(
                "Cannot initialize context because there is already a root application context present - "
                        + "check whether you have multiple ContextLoader* definitions in your web.xml!");
    }

    Log logger = LogFactory.getLog(DhccContextLoader.class);
    servletContext.log("Initializing Spring root WebApplicationContext");
    if (logger.isInfoEnabled()) {
        logger.info("Root WebApplicationContext: initialization started");
    }
    long startTime = System.currentTimeMillis();

    try {
        // Store context in local instance variable, to guarantee that
        // it is available on ServletContext shutdown.
        if (this.context == null) {
            this.context = createWebApplicationContext(servletContext);
        }
        if (this.context instanceof ConfigurableWebApplicationContext) {
            ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context;
            if (!cwac.isActive()) {
                // The context has not yet been refreshed -> provide services such as
                // setting the parent context, setting the application context id, etc
                if (cwac.getParent() == null) {
                    // The context instance was injected without an explicit parent ->
                    // determine parent for root web application context, if any.
                    ApplicationContext parent = loadParentContext(servletContext);
                    cwac.setParent(parent);
                }
                configureAndRefreshWebApplicationContext(cwac, servletContext);
            }
        }
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

        ClassLoader ccl = Thread.currentThread().getContextClassLoader();
        if (ccl == DhccContextLoader.class.getClassLoader()) {
            currentContext = this.context;
        } else if (ccl != null) {
            currentContextPerThread.put(ccl, this.context);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Published root WebApplicationContext as ServletContext attribute with name ["
                    + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }
        if (logger.isInfoEnabled()) {
            long elapsedTime = System.currentTimeMillis() - startTime;
            logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
        }

        return this.context;
    } catch (RuntimeException ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    } catch (Error err) {
        logger.error("Context initialization failed", err);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
        throw err;
    }
}

From source file:org.apache.click.ClickServlet.java

/**
 * Destroy the application configuration service instance and remove
 * it from the ServletContext attribute.
 *
 * @param servletContext the servlet context
 * @throws RuntimeException if the configuration service cannot be
 * destroyed/*from   w  w  w  . j a  v a  2s  . c  o  m*/
 */
void destroyConfigService(ServletContext servletContext) {

    if (configService != null) {

        try {
            configService.onDestroy();

        } catch (Exception e) {

            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            } else {
                throw new RuntimeException(e);
            }
        } finally {
            servletContext.setAttribute(ConfigService.CONTEXT_NAME, null);
        }
    }
}

From source file:org.artifactory.webapp.servlet.ArtifactoryContextConfigListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    final ServletContext servletContext = event.getServletContext();

    setSessionTrackingMode(servletContext);

    final Thread initThread = new Thread("art-init") {
        boolean success = true;

        @SuppressWarnings({ "unchecked" })
        @Override//from  w  w w.ja va2  s .  co m
        public void run() {
            try {
                //Use custom logger
                String contextId = HttpUtils.getContextId(servletContext);
                //Build a partial config, since we expect the logger-context to exit in the selector cache by only contextId
                LoggerConfigInfo configInfo = new LoggerConfigInfo(contextId);
                LogbackContextSelector.bindConfig(configInfo);
                //No log field since needs to lazy initialize only after logback customization listener has run
                Logger log = getLogger();
                configure(servletContext, log);

                LogbackContextSelector.unbindConfig();
            } catch (Exception e) {
                getLogger().error(
                        "Application could not be initialized: " + ExceptionUtils.getRootCause(e).getMessage(),
                        e);
                success = false;
            } finally {
                if (success) {
                    //Run the waiting filters
                    BlockingQueue<DelayedInit> waitingFiltersQueue = (BlockingQueue<DelayedInit>) servletContext
                            .getAttribute(DelayedInit.APPLICATION_CONTEXT_LOCK_KEY);
                    List<DelayedInit> waitingInits = new ArrayList<>();
                    waitingFiltersQueue.drainTo(waitingInits);
                    for (DelayedInit filter : waitingInits) {
                        try {
                            filter.delayedInit();
                        } catch (ServletException e) {
                            getLogger().error("Could not init {}.", filter.getClass().getName(), e);
                            success = false;
                            break;
                        }
                    }
                }
                //Remove the lock and open the app to requests
                servletContext.removeAttribute(DelayedInit.APPLICATION_CONTEXT_LOCK_KEY);
            }
        }
    };
    initThread.setDaemon(true);
    servletContext.setAttribute(DelayedInit.APPLICATION_CONTEXT_LOCK_KEY,
            new LinkedBlockingQueue<DelayedInit>());
    initThread.start();
    if (Boolean.getBoolean("artifactory.init.useServletContext")) {
        try {
            getLogger().info("Waiting for servlet context initialization ...");
            initThread.join();
        } catch (InterruptedException e) {
            getLogger().error("Artifactory initialization thread got interrupted", e);
        }
    }
}