本文整理了Java中org.apache.catalina.Context.getServletContext()
方法的一些代码示例,展示了Context.getServletContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getServletContext()
方法的具体详情如下:
包路径:org.apache.catalina.Context
类名称:Context
方法名:getServletContext
[英]Return the servlet context for which this Context is a facade.
[中]返回此上下文为其外观的servlet上下文。
代码示例来源:origin: spring-projects/spring-framework
@Override
public ServletContext getServletContext() {
return this.context.getServletContext();
}
代码示例来源:origin: apache/incubator-dubbo
Tomcat.addServlet(context, "dispatcher", new DispatcherServlet());
context.addServletMapping("/*", "dispatcher");
ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());
代码示例来源:origin: apache/incubator-dubbo
Tomcat.addServlet(context, "dispatcher", new DispatcherServlet());
context.addServletMapping("/*", "dispatcher");
ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());
代码示例来源:origin: OryxProject/oryx
getServingLayer().getContext().getServletContext().getAttribute(OryxResource.INPUT_PRODUCER_KEY);
代码示例来源:origin: OryxProject/oryx
@Test
public void testKMeansServingModel() throws Exception {
Map<String,Object> overlayConfig = new HashMap<>();
overlayConfig.put("oryx.serving.application-resources",
"\"com.cloudera.oryx.app.serving," +
"com.cloudera.oryx.app.serving.clustering," +
"com.cloudera.oryx.app.serving.kmeans\"");
overlayConfig.put("oryx.serving.model-manager-class",
KMeansServingModelManager.class.getName());
overlayConfig.put("oryx.input-schema.feature-names", "[\"x\",\"y\"]");
overlayConfig.put("oryx.input-schema.categorical-features", "[]");
Config config = ConfigUtils.overlayOn(overlayConfig, getConfig());
startMessaging();
startServer(config);
startUpdateTopics(new MockKMeansModelGenerator(), 10);
// Let updates finish
sleepSeconds(5);
KMeansServingModelManager manager = (KMeansServingModelManager)
getServingLayer().getContext().getServletContext().getAttribute(OryxResource.MODEL_MANAGER_KEY);
assertNotNull("Manager must initialize in web context", manager);
KMeansServingModel model = manager.getModel();
log.debug("{}", model);
assertNotNull(model);
assertEquals(3, model.getNumClusters());
assertCluster(model.getCluster(0), 0, new double[] { 9.0, 9.0 }, 9);
assertCluster(model.getCluster(1), 1, new double[] { 7.0, 7.0 }, 7);
assertCluster(model.getCluster(2), 2, new double[] { 8.0, 8.0 }, 8);
}
代码示例来源:origin: OryxProject/oryx
@Test
public void testALSServingModel() throws Exception {
Map<String,Object> overlayConfig = new HashMap<>();
overlayConfig.put("oryx.serving.application-resources",
"\"com.cloudera.oryx.app.serving,com.cloudera.oryx.app.serving.als\"");
overlayConfig.put("oryx.serving.model-manager-class", ALSServingModelManager.class.getName());
Config config = ConfigUtils.overlayOn(overlayConfig, getConfig());
startMessaging();
startServer(config);
startUpdateTopics(new MockALSModelUpdateGenerator(), 10);
// Let updates finish
sleepSeconds(5);
ALSServingModelManager manager = (ALSServingModelManager)
getServingLayer().getContext().getServletContext().getAttribute(OryxResource.MODEL_MANAGER_KEY);
assertNotNull("Manager must initialize in web context", manager);
ALSServingModel model = manager.getModel();
log.debug("{}", model);
assertNotNull(model);
assertEquals(2, model.getFeatures());
assertTrue(model.isImplicit());
assertContainsSame(MockALSModelUpdateGenerator.Y.keySet(), model.getAllItemIDs());
assertNotNull(model.getYTYSolver());
MockALSModelUpdateGenerator.X.forEach((id, vector) -> assertArrayEquals(vector, model.getUserVector(id)));
MockALSModelUpdateGenerator.Y.forEach((id, vector) -> assertArrayEquals(vector, model.getItemVector(id)));
MockALSModelUpdateGenerator.A.forEach((id, expected) -> assertContainsSame(expected, model.getKnownItems(id)));
}
代码示例来源:origin: psi-probe/psi-probe
/**
* Exclude from total.
*
* @param ctx the ctx
* @return true, if successful
*/
private boolean excludeFromTotal(Context ctx) {
return isSelfIgnored() && getServletContext().equals(ctx.getServletContext());
}
代码示例来源:origin: OryxProject/oryx
getServingLayer().getContext().getServletContext().getAttribute(OryxResource.MODEL_MANAGER_KEY);
代码示例来源:origin: psi-probe/psi-probe
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String attrName = ServletRequestUtils.getStringParameter(request, "attr");
context.getServletContext().removeAttribute(attrName);
return new ModelAndView(new RedirectView(
request.getContextPath() + getViewName() + "?" + request.getQueryString()));
}
代码示例来源:origin: psi-probe/psi-probe
/**
* Gets the application attributes.
*
* @param context the context
* @return the application attributes
*/
public static List<Attribute> getApplicationAttributes(Context context) {
List<Attribute> attrs = new ArrayList<>();
ServletContext servletCtx = context.getServletContext();
for (String attrName : Collections.list(servletCtx.getAttributeNames())) {
Object attrValue = servletCtx.getAttribute(attrName);
Attribute attr = new Attribute();
attr.setName(attrName);
attr.setValue(attrValue);
attr.setType(ClassUtils.getQualifiedName(attrValue.getClass()));
attrs.add(attr);
}
return attrs;
}
代码示例来源:origin: psi-probe/psi-probe
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
if (downloadTarget == null) {
throw new RuntimeException("Download target is not set for " + getClass().getName());
}
String xmlPath;
if (TARGET_WEB_XML.equals(downloadTarget)) {
ServletContext sctx = context.getServletContext();
xmlPath = sctx.getRealPath("/WEB-INF/web.xml");
} else if (TARGET_CONTEXT_XML.equals(downloadTarget)) {
xmlPath = this.getContainerWrapper().getTomcatContainer().getConfigFile(context).getPath();
} else {
throw new RuntimeException("Unknown download target " + getDownloadTarget());
}
if (xmlPath != null) {
File xmlFile = new File(xmlPath);
if (xmlFile.exists()) {
Utils.sendFile(request, response, xmlFile);
} else {
logger.debug("File {} of {} application does not exists.", xmlPath, contextName);
}
} else {
logger.debug("Cannot determine path to {} file of {} application.", getDownloadTarget(),
contextName);
}
return null;
}
代码示例来源:origin: psi-probe/psi-probe
ServletContext servletCtx = context.getServletContext();
for (String paramName : Collections.list(servletCtx.getInitParameterNames())) {
ApplicationParam param = new ApplicationParam();
代码示例来源:origin: psi-probe/psi-probe
ServletContext servletCtx = context.getServletContext();
for (String paramName : Collections.list(servletCtx.getInitParameterNames())) {
ApplicationParam param = new ApplicationParam();
代码示例来源:origin: psi-probe/psi-probe
ServletContext servletCtx = context.getServletContext();
for (String paramName : Collections.list(servletCtx.getInitParameterNames())) {
ApplicationParam param = new ApplicationParam();
代码示例来源:origin: psi-probe/psi-probe
ServletContext servletCtx = context.getServletContext();
for (String paramName : Collections.list(servletCtx.getInitParameterNames())) {
ApplicationParam param = new ApplicationParam();
代码示例来源:origin: psi-probe/psi-probe
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String encoding = opt.getJavaEncoding();
String content = null;
if (jspName != null) {
String servletName =
getContainerWrapper().getTomcatContainer().getServletFileNameForJsp(context, jspName);
if (servletName != null) {
File servletFile = new File(servletName);
if (servletFile.exists()) {
try (InputStream fis = Files.newInputStream(servletFile.toPath())) {
content = Utils.highlightStream(jspName, fis, "java", encoding);
}
}
}
}
return new ModelAndView(getViewName(), "content", content);
}
代码示例来源:origin: psi-probe/psi-probe
@Override
public String getServletFileNameForJsp(Context context, String jspName) {
String servletName = null;
ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
if (servletConfig != null) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
JspCompilationContext jcctx = createJspCompilationContext(jspName, opt, sctx, jrctx, null);
servletName = jcctx.getServletJavaFileName();
} else {
logger.error(NO_JSP_SERVLET, context.getName());
}
return servletName;
}
代码示例来源:origin: psi-probe/psi-probe
if (servletConfig != null) {
synchronized (servletConfig) {
ServletContext sctx = context.getServletContext();
Options opt = new EmbeddedServletOptions(servletConfig, sctx);
代码示例来源:origin: psi-probe/psi-probe
new Log4J2WebLoggerContextUtilsAccessor(classLoader);
Log4J2LoggerContextAccessor loggerContextAccessor =
webLoggerContextUtilsAccessor.getWebLoggerContext(ctx.getServletContext());
List<Object> loggerContexts = getLoggerContexts(classLoader);
Object loggerConfig = null;
代码示例来源:origin: pippo-java/pippo
context.getServletContext().setAttribute(PIPPO_APPLICATION, getApplication());
内容来源于网络,如有侵权,请联系作者删除!