org.eclipse.jetty.webapp.WebAppContext.getServletContext()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.getServletContext()方法的一些代码示例,展示了WebAppContext.getServletContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.getServletContext()方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:getServletContext

WebAppContext.getServletContext介绍

暂无

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot

private void setExtendedListenerTypes(boolean extended) {
  try {
    this.context.getServletContext().setExtendedListenerTypes(extended);
  }
  catch (NoSuchMethodError ex) {
    // Not available on Jetty 8
  }
}

代码示例来源:origin: org.springframework.boot/spring-boot

private void setExtendedListenerTypes(WebAppContext context, boolean extended) {
  try {
    context.getServletContext().setExtendedListenerTypes(extended);
  }
  catch (NoSuchMethodError ex) {
    // Not available on Jetty 8
  }
}

代码示例来源:origin: apache/hbase

private static WebAppContext createWebAppContext(String name,
  Configuration conf, AccessControlList adminsAcl, final String appDir) {
 WebAppContext ctx = new WebAppContext();
 ctx.setDisplayName(name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + name);
 ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
 // for org.apache.hadoop.metrics.MetricsServlet
 ctx.getServletContext().setAttribute(
  org.apache.hadoop.http.HttpServer2.CONF_CONTEXT_ATTRIBUTE, conf);
 ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
 addNoCacheFilter(ctx);
 return ctx;
}

代码示例来源:origin: apache/hive

/**
 * Create the web context for the application of specified name
 */
WebAppContext createWebAppContext(Builder b) {
 WebAppContext ctx = new WebAppContext();
 setContextAttributes(ctx.getServletContext(), b.contextAttrs);
 ctx.setDisplayName(b.name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + b.name);
 return ctx;
}

代码示例来源:origin: org.springframework.boot/spring-boot

private void callInitializers(WebAppContext context) throws ServletException {
  try {
    setExtendedListenerTypes(context, true);
    for (ServletContextInitializer initializer : this.initializers) {
      initializer.onStartup(context.getServletContext());
    }
  }
  finally {
    setExtendedListenerTypes(context, false);
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

private HttpServer2(final Builder b) throws IOException {
 final String appDir = getWebAppsPath(b.name);
 this.webServer = new Server();
 this.adminsAcl = b.adminsAcl;
 this.handlers = new HandlerCollection();
 this.webAppContext = createWebAppContext(b, adminsAcl, appDir);
 this.xFrameOptionIsEnabled = b.xFrameEnabled;
 this.xFrameOption = b.xFrameOption;
 try {
  this.secretProvider =
    constructSecretProvider(b, webAppContext.getServletContext());
  this.webAppContext.getServletContext().setAttribute
    (AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE,
     secretProvider);
 } catch(IOException e) {
  throw e;
 } catch (Exception e) {
  throw new IOException(e);
 }
 this.findPort = b.findPort;
 this.portRanges = b.portRanges;
 initializeWebServer(b.name, b.hostName, b.conf, b.pathSpecs);
}

代码示例来源:origin: org.springframework.boot/spring-boot

try {
  setExtendedListenerTypes(true);
  this.initializer.onStartup(null, this.context.getServletContext());

代码示例来源: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

public void visitTagLib(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
{
  //Additive across web.xml and web-fragment.xml
  String uri = node.getString("taglib-uri", false, true);
  String location = node.getString("taglib-location", false, true);
  context.setResourceAlias(uri, location);
  JspConfig config = (JspConfig)context.getServletContext().getJspConfigDescriptor();
  if (config == null)
  {
    config = new JspConfig();
    context.getServletContext().setJspConfigDescriptor(config);
  }
  TagLib tl = new TagLib();
  tl.setTaglibLocation(location);
  tl.setTaglibURI(uri);
  config.addTaglibDescriptor(tl);
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

@Override
public void dump(Appendable out, String indent) throws IOException
{
  List<String> system_classes=null;
  if (_systemClasses!=null)
  {
    system_classes=new ArrayList<>(_systemClasses);
    Collections.sort(system_classes);
  }
  
  List<String> server_classes=null;
  if (_serverClasses!=null)
  {
    server_classes=new ArrayList<>(_serverClasses);
    Collections.sort(server_classes);
  }
  
  dumpObjects(out,indent,
    new ClassLoaderDump(getClassLoader()),
    new DumpableCollection("Systemclasses "+this,system_classes),
    new DumpableCollection("Serverclasses "+this,server_classes),
    new DumpableCollection("Configurations "+this,_configurations),
    new DumpableCollection("Handler attributes "+this,((AttributesMap)getAttributes()).getAttributeEntrySet()),
    new DumpableCollection("Context attributes "+this,((Context)getServletContext()).getAttributeEntrySet()),
    new DumpableCollection("Initparams "+this,getInitParams().entrySet())
    );
}

代码示例来源: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.getServletContext().setEffectiveMajorVersion(_webXmlRoot.getMajorVersion());
context.getServletContext().setEffectiveMinorVersion(_webXmlRoot.getMinorVersion());

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

public void visitJspConfig(WebAppContext context, Descriptor descriptor, XmlParser.Node node)
  JspConfig config = (JspConfig)context.getServletContext().getJspConfigDescriptor();
  if (config == null)
    context.getServletContext().setJspConfigDescriptor(config);

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

context.getServletContext().setEffectiveMajorVersion(context.getMetaData().getWebXml().getMajorVersion());
context.getServletContext().setEffectiveMinorVersion(context.getMetaData().getWebXml().getMinorVersion());

代码示例来源:origin: apache/nifi

ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(webApiContext.getServletContext());
flowService = ctx.getBean("flowService", FlowService.class);

代码示例来源:origin: opensourceBIM/BIMserver

Jsr356Impl.setServletContext(configureContext, context.getServletContext());
  Jsr356Impl.setAdditionalWebSocketConfigurator(new AdditionalWebSocketConfigurator() {
    @Override
context.addServlet(servletHolder, "/*");
context.getServletContext().setAttribute("bimserver", bimServer);
if (context.getResourceBase() == null) {
  if (resourceBase == null) {

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-server

@Override
  public void lifeCycleStarting(LifeCycle arg0) {
    // WebAppInitializer initializer = new WebAppInitializer();
    try {
      Context servletContext = webAppContext.getServletContext();
      // servletContext.setExtendedListenerTypes(true);
      initializer.onStartup(servletContext);
    } catch (ServletException e) {
      throw new RuntimeException(e);
    }
  }
});

代码示例来源:origin: restx/restx

@Override
  public void lifeCycleStarting(LifeCycle event) {
    ctx.getServletContext().setInitParameter("restx.baseServerUri", baseUrl());
    ctx.getServletContext().setInitParameter("restx.serverId", getServerId());
  }
});

代码示例来源:origin: restx/restx

@Override
  public void lifeCycleStarting(LifeCycle event) {
    ctx.getServletContext().setInitParameter("restx.baseServerUri", baseUrl());
    ctx.getServletContext().setInitParameter("restx.serverId", getServerId());
  }
});

代码示例来源:origin: org.apache.hive/hive-common

/**
 * Create the web context for the application of specified name
 */
WebAppContext createWebAppContext(Builder b) {
 WebAppContext ctx = new WebAppContext();
 setContextAttributes(ctx.getServletContext(), b.contextAttrs);
 ctx.setDisplayName(b.name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + b.name);
 return ctx;
}

相关文章

微信公众号

最新文章

更多

WebAppContext类方法