本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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() + "*");
}
示例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() + "*");
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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() + "*");
}
示例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);
}
}
示例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);
}