當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContextEvent.getServletContext方法代碼示例

本文整理匯總了Java中javax.servlet.ServletContextEvent.getServletContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContextEvent.getServletContext方法的具體用法?Java ServletContextEvent.getServletContext怎麽用?Java ServletContextEvent.getServletContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.ServletContextEvent的用法示例。


在下文中一共展示了ServletContextEvent.getServletContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent e) {
	LOG.info("Creating Smaph context.");
	ServletContext context = e.getServletContext();
	context.setAttribute("nif-parser", new TurtleNIFDocumentParser());
	context.setAttribute("nif-creator", new TurtleNIFDocumentCreator());
	String watGcubeToken = context.getInitParameter(WAT_GCUBE_TOKEN);
	SmaphBuilder.initialize(watGcubeToken);
	try {
		context.setAttribute("wikipedia-api", new WikipediaInterfaceWAT.WikipediaInterfaceWATBuilder().gcubeToken(watGcubeToken).build());
	} catch (URISyntaxException e1) {
		e1.printStackTrace();
	}
	
	context.setAttribute("wiki-to-freebase", WikipediaToFreebase.open(context.getInitParameter(FREEBASE_DIR)));
	context.setAttribute("entity-to-anchors", EntityToAnchors.fromDB(context.getInitParameter(ENTITY_TO_ANCHORS_DB)));
}
 
開發者ID:marcocor,項目名稱:smaph,代碼行數:18,代碼來源:SmaphContextListener.java

示例2: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent sce) {

    ServletContext sc = sce.getServletContext();

    // Try and use one of the Servlet 3.0 methods that should be blocked
    try {
        servletContext = sce.getServletContext();
        sc.getEffectiveMajorVersion();
        log.append("FAIL-01");
    } catch (UnsupportedOperationException uoe) {
        log.append("PASS-01");
    } catch (Exception e) {
        log.append("FAIL-02");
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:TesterTldListener.java

示例3: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent sce) {
	// 加載配置文件
	ServletContext context = sce.getServletContext();
	loadConfig(context.getInitParameter(CONFIGURATIONS_PARAM_NAME));
	
	// 實例化bean處理器
	Optional<String> handler = getConfiguration().getBeansHandler();
	String finalClass = handler.orElse(DEFAULT_BEANS_HANDLER);
	BeansHandler beansHandler = BasicUtil.newInstance(finalClass);
	getBeansFactory().setBeansHandler(beansHandler);
	getBeansFactory().setConfiguration(getConfiguration());
	// 將所有bean對象注冊到bean容器
	getBeansFactory().register();
	loadServlets(context);
}
 
開發者ID:NymphWeb,項目名稱:nymph,代碼行數:17,代碼來源:WebXmlStarter.java

示例4: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
public void contextInitialized(final ServletContextEvent sce) {

        LOGGER.info("GOLDespQuartz Initializer Listener loaded, initializing Scheduler...");

        waitOnShutdown = Boolean.valueOf(WAIT_ON_SHUTDOWN);

        final ServletContext servletContext = sce.getServletContext();

        String configFile = servletContext.getInitParameter("quartz:config-file");
        if (configFile == null) {
            configFile = servletContext.getInitParameter("config-file");
        }

        String fileName = System.getProperty("org.quartz.properties", null);
        if ((fileName == null || 0 == fileName.length()) && (configFile != null && 0 < configFile.length())) {
            System.setProperty("org.quartz.properties", configFile);
        }

        LOGGER.info("Quartz Schedule StdSchedulerFactory: org.quartz.properties=" + System.getProperty("org.quartz.properties", null));

        SchedulerHelperFactory.instance().instantiateSchedulerFactory();
        SchedulerHelperFactory.instance().startScheduler();
    }
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:24,代碼來源:QuartzInitializerListener.java

示例5: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
/**
 * Record the fact that this web application has been initialized.
 *
 * @param event
 *            The servlet context event
 */
@Override
public void contextInitialized(ServletContextEvent event) {

    this.context = event.getServletContext();
    log("contextInitialized()");

}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:14,代碼來源:SessionListener.java

示例6: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public final void contextInitialized(ServletContextEvent sce) {
  ServletContext context = sce.getServletContext();
  context.setAttribute(OryxResource.MODEL_MANAGER_KEY,
                       new MockClassificationServingModelManager(ConfigUtils.getDefault()));
  context.setAttribute(OryxResource.INPUT_PRODUCER_KEY, new MockTopicProducer());
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:8,代碼來源:ClassificationDistributionTest.java

示例7: contextDestroyed

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextDestroyed(ServletContextEvent sce) {
    ServletContext sc = sce.getServletContext();
    Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
    if (obj instanceof WsServerContainer) {
        ((WsServerContainer) obj).destroy();
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:9,代碼來源:WsContextListener.java

示例8: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
public void contextInitialized(final ServletContextEvent sce) {
    try {
        this.delegate.contextInitialized(sce);
    } catch (final Throwable t) {
        /*
         * no matter what went wrong, our role is to capture this error and
         * prevent it from blocking initialization of the context. logging
         * overkill so that our deployer will find a record of this problem
         * even if unfamiliar with Commons Logging and properly configuring
         * it.
         */

        final String message = "SafeContextLoaderListener: \n"
            + "The Spring ContextLoaderListener we wrap threw on contextInitialized.\n"
            + "But for our having caught this error, the web application context would not have initialized.";

        // logger it via Commons Logging
        logger.error(message, t);

        // logger it to the ServletContext
        ServletContext context = sce.getServletContext();
        context.log(message, t);

        /*
         * record the error so that the application has access to later
         * display a proper error message based on the exception.
         */
        context.setAttribute(CAUGHT_THROWABLE_KEY, t);
    }
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:31,代碼來源:SafeContextLoaderListener.java

示例9: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    try {
        context.setAttribute("upTime", System.currentTimeMillis());
    } catch (Exception e) {
    }
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:12,代碼來源:ContextListener.java

示例10: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext sc = sce.getServletContext();
    // Don't trigger WebSocket initialization if a WebSocket Server
    // Container is already present
    if (sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE) == null) {
        WsSci.init(sce.getServletContext(), false);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:10,代碼來源:WsContextListener.java

示例11: contextDestroyed

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextDestroyed(ServletContextEvent sce) {
	ServletContext sc = sce.getServletContext();
	Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
	if (obj instanceof WsServerContainer) {
		((WsServerContainer) obj).destroy();
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:9,代碼來源:WsContextListener.java

示例12: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent sce) {
	ServletContext context = sce.getServletContext();
	try {
		String tangyuanResource = context.getInitParameter("tangyuan.resource");
		if (null != tangyuanResource) {
			TangYuanContainer.getInstance().start(tangyuanResource);
		}
	} catch (Throwable e) {
		log.error(null, e);
		throw new TangYuanException(e);
	}
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:14,代碼來源:TangYuanContextLoaderListener.java

示例13: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
public void contextInitialized(ServletContextEvent contextEvent)
{
	 final ServletContext context = contextEvent.getServletContext();
	 
	 try
	 {
		 LoggingUtility.init(context.getRealPath("/WEB-INF/logs"));
	 }
	 catch(Exception ex)
	 {
		 getLogger().error("Unable to initialize logging system.");
	 }
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:14,代碼來源:LoggingStartupContextListener.java

示例14: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(final ServletContextEvent event) {
    final ServletContext servletContext = event.getServletContext();
    final ApplicationContext ctx =
        WebApplicationContextUtils.getWebApplicationContext(servletContext);

    LOGGER.info("[{}] has loaded the CAS servlet application context: {}",
        servletContext.getServerInfo(), ctx);
}
 
開發者ID:yuweijun,項目名稱:cas-server-4.2.1,代碼行數:10,代碼來源:CasEnvironmentContextListener.java

示例15: contextInitialized

import javax.servlet.ServletContextEvent; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent sce) {
  log.info("ModelManagerListener initializing");
  ServletContext context = sce.getServletContext();
  init(context);

  if (!readOnly) {
    Preconditions.checkArgument(KafkaUtils.topicExists(inputTopicLockMaster, inputTopic),
                              "Topic %s does not exist; did you create it?", inputTopic);
    Preconditions.checkArgument(KafkaUtils.topicExists(updateTopicLockMaster, updateTopic),
                              "Topic %s does not exist; did you create it?", updateTopic);
    inputProducer = new TopicProducerImpl<>(inputTopicBroker, inputTopic);
    context.setAttribute(INPUT_PRODUCER_KEY, inputProducer);
  }

  KafkaConsumer<String,U> consumer = new KafkaConsumer<>(
      ConfigUtils.keyValueToProperties(
          "group.id", "OryxGroup-ServingLayer-" + UUID.randomUUID(),
          "bootstrap.servers", updateTopicBroker,
          "max.partition.fetch.bytes", maxMessageSize,
          "key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer",
          "value.deserializer", updateDecoderClass.getName(),
          // Do start from the beginning of the update queue
          "auto.offset.reset", "earliest"
      ));
  consumer.subscribe(Collections.singletonList(updateTopic));
  consumerIterator = new ConsumeDataIterator<>(consumer);

  modelManager = loadManagerInstance();
  new Thread(LoggingCallable.log(() -> {
    // Possible if it shuts down immediately; just exit
    if (modelManager == null) {
      return;
    }
    // Can we do better than a default Hadoop config? Nothing else provides it here
    Configuration hadoopConf = new Configuration();
    try {
      modelManager.consume(consumerIterator, hadoopConf);
    } catch (Throwable t) {
      log.error("Error while consuming updates", t);
      // Ideally we would shut down ServingLayer, but not clear how to plumb that through
      // without assuming this has been run from ServingLayer and not a web app deployment
      close();
    }
  }).asRunnable(), "OryxServingLayerUpdateConsumerThread").start();

  // Set the Model Manager in the Application scope
  context.setAttribute(MANAGER_KEY, modelManager);
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:50,代碼來源:ModelManagerListener.java


注:本文中的javax.servlet.ServletContextEvent.getServletContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。