本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.setAttribute()
方法的一些代码示例,展示了WebAppContext.setAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.setAttribute()
方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:setAttribute
暂无
代码示例来源:origin: apache/hbase
/**
* Set a value in the webapp context. These values are available to the jsp
* pages as "application.getAttribute(name)".
* @param name The name of the attribute
* @param value The value of the attribute
*/
public void setAttribute(String name, Object value) {
webAppContext.setAttribute(name, value);
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* Set a value in the webapp context. These values are available to the jsp
* pages as "application.getAttribute(name)".
* @param name The name of the attribute
* @param value The value of the attribute
*/
public void setAttribute(String name, Object value) {
webAppContext.setAttribute(name, value);
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
@Override
public void postConfigure(WebAppContext context) throws Exception
{
context.setAttribute(FRAGMENT_RESOURCES, null);
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
@Override
public void postConfigure(WebAppContext context) throws Exception
{
context.setAttribute(METAINF_RESOURCES, null);
context.setAttribute(METAINF_FRAGMENTS, null);
context.setAttribute(METAINF_TLDS, null);
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
/** Set temporary directory for context.
* The javax.servlet.context.tempdir attribute is also set.
* @param dir Writable temporary directory.
*/
public void setTempDirectory(File dir)
{
if (isStarted())
throw new IllegalStateException("Started");
if (dir!=null)
{
try{dir=new File(dir.getCanonicalPath());}
catch (IOException e){LOG.warn(Log.EXCEPTION,e);}
}
_tmpDir=dir;
setAttribute(TEMPDIR,_tmpDir);
}
代码示例来源:origin: yahoo/mysql_perf_analyzer
private WebAppContext createDeployedApplicationInstance(File workDirectory,
String deployedApplicationPath) {
WebAppContext deployedApplication = new WebAppContext();
deployedApplication.setContextPath(this.getContextPath());
deployedApplication.setWar(deployedApplicationPath);
deployedApplication.setAttribute("javax.servlet.context.tempdir",
workDirectory.getAbsolutePath());
deployedApplication
.setAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
deployedApplication.setAttribute(
"org.eclipse.jetty.containerInitializers", jspInitializers());
deployedApplication.setAttribute(InstanceManager.class.getName(),
new SimpleInstanceManager());
deployedApplication.addBean(new ServletContainerInitializersStarter(
deployedApplication), true);
// webapp.setClassLoader(new URLClassLoader(new
// URL[0],App.class.getClassLoader()));
deployedApplication.addServlet(jspServletHolder(), "*.jsp");
return deployedApplication;
}
代码示例来源:origin: igniterealtime/Openfire
private void createWebAppContext() {
contexts = new ContextHandlerCollection();
WebAppContext context;
// Add web-app. Check to see if we're in development mode. If so, we don't
// add the normal web-app location, but the web-app in the project directory.
boolean developmentMode = Boolean.getBoolean("developmentMode");
if( developmentMode )
{
System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode"));
context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() +
File.separator + "src" + File.separator + "web", "/");
}
else {
context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp",
"/");
}
// Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
final List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add(new ContainerInitializer(new JasperInitializer(), null));
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
// The index.html includes a redirect to the index.jsp and doesn't bypass
// the context security when in development mode
context.setWelcomeFiles(new String[]{"index.html"});
// Make sure the context initialization is done when in development mode
if( developmentMode )
{
context.addBean( new ServletContainerInitializersStarter( context ), true );
}
}
代码示例来源:origin: apache/geode
.forEach(p -> webapp.setAttribute(p.getKey(), p.getValue()));
代码示例来源:origin: apache/nifi
webappContext.setAttribute(CONTAINER_INCLUDE_PATTERN_KEY, CONTAINER_INCLUDE_PATTERN_VALUE);
代码示例来源:origin: DeemOpen/zkui
ClassList clist = ClassList.setServerDefault(server);
clist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
servletContextHandler.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*(/target/classes/|.*.jar)");
servletContextHandler.setParentLoaderPriority(true);
servletContextHandler.setInitParameter("useFileMappedBuffer", "false");
servletContextHandler.setAttribute("globalProps", globalProps);
代码示例来源:origin: org.apache.hadoop/hadoop-common
private static WebAppContext createWebAppContext(Builder b,
AccessControlList adminsAcl, final String appDir) {
WebAppContext ctx = new WebAppContext();
ctx.setDefaultsDescriptor(null);
ServletHolder holder = new ServletHolder(new DefaultServlet());
Map<String, String> params = ImmutableMap. <String, String> builder()
.put("acceptRanges", "true")
.put("dirAllowed", "false")
.put("gzip", "true")
.put("useFileMappedBuffer", "true")
.build();
holder.setInitParameters(params);
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.addServlet(holder, "/");
ctx.setDisplayName(b.name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + b.name);
String tempDirectory = b.conf.get(HTTP_TEMP_DIR_KEY);
if (tempDirectory != null && !tempDirectory.isEmpty()) {
ctx.setTempDirectory(new File(tempDirectory));
ctx.setAttribute("javax.servlet.context.tempdir", tempDirectory);
}
ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, b.conf);
ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
addNoCacheFilter(ctx);
return ctx;
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
@Override
public void preConfigure(final WebAppContext context) throws Exception
{
boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE;
if (context.getServer() != null)
{
Boolean attr = (Boolean)context.getServer().getAttribute(USE_CONTAINER_METAINF_CACHE);
if (attr != null)
useContainerCache = attr.booleanValue();
}
if (LOG.isDebugEnabled()) LOG.debug("{} = {}", USE_CONTAINER_METAINF_CACHE, useContainerCache);
//pre-emptively create empty lists for tlds, fragments and resources as context attributes
//this signals that this class has been called. This differentiates the case where this class
//has been called but finds no META-INF data from the case where this class was never called
if (context.getAttribute(METAINF_TLDS) == null)
context.setAttribute(METAINF_TLDS, new HashSet<URL>());
if (context.getAttribute(METAINF_RESOURCES) == null)
context.setAttribute(METAINF_RESOURCES, new HashSet<Resource>());
if (context.getAttribute(METAINF_FRAGMENTS) == null)
context.setAttribute(METAINF_FRAGMENTS, new HashMap<Resource, Resource>());
//always scan everything from the container's classpath
scanJars(context, context.getMetaData().getContainerResources(), useContainerCache, __allScanTypes);
//only look for fragments if web.xml is not metadata complete, or it version 3.0 or greater
List<String> scanTypes = new ArrayList<>(__allScanTypes);
if (context.getMetaData().isMetaDataComplete() || (context.getServletContext().getEffectiveMajorVersion() < 3) && !context.isConfigurationDiscovered())
scanTypes.remove(METAINF_FRAGMENTS);
scanJars(context, context.getMetaData().getWebInfJars(), false, scanTypes);
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
context.setAttribute(TEMPDIR_CONFIGURED, Boolean.TRUE); //the tmp dir was set explicitly
return;
configureTempDirectory(tmpDir, context);
context.setAttribute(WebAppContext.TEMPDIR,tmpDir);
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
context.setAttribute(METAINF_TLDS, metaInfTlds);
代码示例来源:origin: line/armeria
static WebAppContext newWebAppContext() throws MalformedURLException {
final WebAppContext handler = new WebAppContext();
handler.setContextPath("/");
handler.setBaseResource(Resource.newResource(webAppRoot()));
handler.setClassLoader(new URLClassLoader(
new URL[] {
Resource.newResource(new File(webAppRoot(),
"WEB-INF" + File.separatorChar +
"lib" + File.separatorChar +
"hello.jar")).getURI().toURL()
},
JettyService.class.getClassLoader()));
handler.addBean(new ServletContainerInitializersStarter(handler), true);
handler.setAttribute(
"org.eclipse.jetty.containerInitializers",
Collections.singletonList(new ContainerInitializer(new JettyJasperInitializer(), null)));
return handler;
}
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
context.setAttribute(METAINF_FRAGMENTS, fragments);
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
orderedLibs.add(fullname.substring(j+1,i+4));
context.setAttribute(ServletContext.ORDERED_LIBS, orderedLibs);
代码示例来源:origin: org.eclipse.jetty/jetty-webapp
context.setAttribute(METAINF_RESOURCES, dirs);
代码示例来源:origin: stackoverflow.com
webAppContext.setConfigurations(new Configuration[] {
new WebXmlConfiguration(),
new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) throws Exception {
MultiMap<String> map = new MultiMap<String>();
map.add(WebApplicationInitializer.class.getName(), MyWebApplicationInitializerImpl.class.getName());
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}
});
代码示例来源:origin: pulsarIO/realtime-analytics
public void startStandAlone() {
try {
WebAppContext context = new WebAppContext();
String baseUrl = getBaseUrl();
LOGGER.info("Metric server baseUrl: " + baseUrl);
context.setDescriptor(baseUrl + "/WEB-INF/web.xml");
context.setResourceBase(baseUrl);
context.setContextPath("/");
context.setParentLoaderPriority(true);
context.setAttribute("JetStreamRoot", applicationContext);
Server s_server = new Server(s_port);
s_server.setHandler(context);
LOGGER.info( "Metric server started, listening on port " + s_port);
s_server.start();
running.set(true);
} catch (Throwable t) {
throw CommonUtils.runtimeException(t);
}
}
内容来源于网络,如有侵权,请联系作者删除!