当前位置: 首页>>代码示例>>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;未经允许,请勿转载。