當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。