当前位置: 首页>>代码示例>>Java>>正文


Java ServletConfig.getServletContext方法代码示例

本文整理汇总了Java中javax.servlet.ServletConfig.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java ServletConfig.getServletContext方法的具体用法?Java ServletConfig.getServletContext怎么用?Java ServletConfig.getServletContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.ServletConfig的用法示例。


在下文中一共展示了ServletConfig.getServletContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    ServletContext servletContext = config.getServletContext();
    logger.info("limberest context path: {}: " + servletContext.getContextPath());

    String warDeployPath = servletContext.getRealPath("/");
    logger.debug("warDeployPath: {}", warDeployPath);

    String webappContextPath = servletContext.getContextPath();
    logger.debug("webappContextPath: {}", webappContextPath);
    
    try {
        // TODO log
        new Initializer().scan();
    }
    catch (IOException ex) {
        logger.error("Unable to scan all packages", ex);
    }
}
 
开发者ID:limberest,项目名称:limberest,代码行数:22,代码来源:RestServlet.java

示例2: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("orchestrates backend jobs")
    .termsOfService("")
    .contact(new Contact()
      .email("[email protected]"))
    .license(new License()
      .name("LGPL 3.0")
      .url("http://www.gnu.org/licenses/lgpl-3.0.txt"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);

  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
开发者ID:deelam,项目名称:agilion,代码行数:18,代码来源:Bootstrap.java

示例3: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("RESTful API specification for the ElasTest Instrumentation Manager (EIM)")
    .termsOfService("")
    .contact(new Contact()
      .email("[email protected]"))
    .license(new License()
      .name("Apache License Version 2.0")
      .url("http://unlicense.org"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);

  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
开发者ID:elastest,项目名称:elastest-instrumentation-manager,代码行数:18,代码来源:Bootstrap.java

示例4: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("RESTful API specification for the ElasTest Instrumentation Manager (EIM)")
    .termsOfService("TBD")
    .contact(new Contact()
      .email("[email protected]"))
    .license(new License()
      .name("Apache 2.0")
      .url("http://www.apache.org/licenses/LICENSE-2.0.html"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);
  String propertiesFile = "/WEB-INF/bootstrap.properties";
  Properties.load(config.getServletContext().getResourceAsStream(propertiesFile), propertiesFile);
  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
开发者ID:elastest,项目名称:elastest-instrumentation-manager,代码行数:19,代码来源:Bootstrap.java

示例5: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    final ServletContext context = config.getServletContext();
    if (null == registry) {
        final Object registryAttr = context.getAttribute(METRICS_REGISTRY);
        if (registryAttr instanceof MetricRegistry) {
            this.registry = (MetricRegistry) registryAttr;
        } else {
            throw new ServletException("Couldn't find a MetricRegistry instance.");
        }
    }

    filter = (MetricFilter) context.getAttribute(METRIC_FILTER);
    if (filter == null) {
        filter = MetricFilter.ALL;
    }

    this.allowedOrigin = context.getInitParameter(ALLOWED_ORIGIN);
}
 
开发者ID:dhatim,项目名称:dropwizard-prometheus,代码行数:22,代码来源:PrometheusServlet.java

示例6: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    //初始化相关类
    HelperLoader.init();
    //获取ServletContext对象,注册Servlet
    ServletContext servletContext = config.getServletContext();
    //处理JSP的Servlet
    ServletRegistration jspServlet = servletContext.getServletRegistration("jsp");
    jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
    //处理静态资源的默认Servlet
    ServletRegistration defaultServlet = servletContext.getServletRegistration("default");
    defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
开发者ID:envyandgreed,项目名称:SmartFramework,代码行数:15,代码来源:DispatcherServlet.java

示例7: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig servletConfig) throws ServletException {
	// 初始化相关Helper类
	HelperLoader.init();
	// 获取ServletContext对象(用于注册Servlet)
	ServletContext servletContext = servletConfig.getServletContext();
	// 注册处理jsp的servlet
	ServletRegistration jspServlet = servletContext
			.getServletRegistration("jsp");
	jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
	// 注册处理静态资源的默认Servlet
	ServletRegistration defaultServlet = servletContext
			.getServletRegistration("default");
	defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
开发者ID:longjiazuo,项目名称:light-framework,代码行数:16,代码来源:DispatcherServlet.java

示例8: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
public void init(final ServletConfig config) {
    try {
        this.delegate.init(config);

    } catch (final Throwable t) {
        // let the service method know initialization failed.
        this.initSuccess = false;

        /*
         * no matter what went wrong, our role is to capture this error and
         * prevent it from blocking initialization of the servlet. 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 = "SafeDispatcherServlet: \n"
            + "The Spring DispatcherServlet we wrap threw on init.\n"
            + "But for our having caught this error, the servlet would not have initialized.";

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

        // logger it to the ServletContext
        ServletContext context = config.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,代码行数:36,代码来源:SafeDispatcherServlet.java

示例9: JspServletWrapper

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
public JspServletWrapper(ServletConfig config, Options options,
        String jspUri, JspRuntimeContext rctxt) {

    this.isTagFile = false;
    this.config = config;
    this.options = options;
    this.jspUri = jspUri;
    unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
    unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
    unloadAllowed = unloadByCount || unloadByIdle ? true : false;
    ctxt = new JspCompilationContext(jspUri, options,
                                     config.getServletContext(),
                                     this, rctxt);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:JspServletWrapper.java

示例10: setServletConfig

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void setServletConfig(ServletConfig servletConfig) {
	this.servletConfig = servletConfig;
	if (servletConfig != null && this.servletContext == null) {
		this.servletContext = servletConfig.getServletContext();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:StaticWebApplicationContext.java

示例11: JspServletWrapper

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
public JspServletWrapper(ServletConfig config, Options options, String jspUri,
                     boolean isErrorPage, JspRuntimeContext rctxt)
           throws JasperException {

this.isTagFile = false;
       this.config = config;
       this.options = options;
       this.jspUri = jspUri;
       ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
				 config.getServletContext(),
				 this, rctxt);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:JspServletWrapper.java

示例12: JspServletWrapper

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
public JspServletWrapper(ServletConfig config, Options options, String jspUri, JspRuntimeContext rctxt) {

		this.isTagFile = false;
		this.config = config;
		this.options = options;
		this.jspUri = jspUri;
		unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
		unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
		unloadAllowed = unloadByCount || unloadByIdle ? true : false;
		ctxt = new JspCompilationContext(jspUri, options, config.getServletContext(), this, rctxt);
	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:JspServletWrapper.java

示例13: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
    Loader.init();//初始化框架&应用
    ServletContext sc = config.getServletContext();
    //注册JSP的Servlet
    ServletRegistration jspServlet = sc.getServletRegistration("jsp");
    jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
    //注册处理静态资源的Servlet
    ServletRegistration defaultServlet = sc.getServletRegistration("default");
    defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
开发者ID:CFshuming,项目名称:bfmvc,代码行数:12,代码来源:DispatherServlet.java

示例14: engageThread

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
/**
 * Make the current thread know what the current request is.
 * @param servletConfig The servlet configuration object used by a servlet container
 * @param request The incoming http request
 * @param response The outgoing http reply
 * @see #disengageThread()
 */
public static void engageThread(ServletConfig servletConfig, HttpServletRequest request, HttpServletResponse response) {
    try {
        WebContext ec = new DefaultWebContext(request, response, servletConfig,
                servletConfig.getServletContext());
        engageThread(ec);
    } catch (Exception ex) {
        log.fatal("Failed to create an ExecutionContext", ex);
    }
}
 
开发者ID:devefx,项目名称:validator-web,代码行数:17,代码来源:WebContextThreadStack.java

示例15: init

import javax.servlet.ServletConfig; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
  Info info = new Info()
    .title("Swagger Server")
    .description("Create invoices, check payment and forward coins.")
    .termsOfService("")
    .contact(new Contact()
      .email(""))
    .license(new License()
      .name("")
      .url("http://unlicense.org"));

  ServletContext context = config.getServletContext();
  Swagger swagger = new Swagger().info(info);


  HashMap<String, String> params = new HashMap<>();
  //Build parameter Hashmap
  final Enumeration initParameterNames = config.getInitParameterNames();
  while(initParameterNames.hasMoreElements()){
    Object key = initParameterNames.nextElement();

    if(key instanceof String){
      params.put((String)key,config.getInitParameter((String)key));
    }
  }



  Bitcoin bitcoin = Bitcoin.getInstance();
  bitcoin.addParams(params);
  bitcoin.start();

  new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
 
开发者ID:IUNO-TDM,项目名称:PaymentService,代码行数:36,代码来源:Bootstrap.java


注:本文中的javax.servlet.ServletConfig.getServletContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。