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

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

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

WebAppContext.addBean介绍

暂无

代码示例

代码示例来源: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: 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: 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.springframework.boot/spring-boot

context.addBean(new JasperInitializer(context), true);

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/jetty

@Override
public void configure(WebAppContext context) throws Exception {
  //add a bean to the context which will call the servletcontainerinitializers when appropriate
  JettyMockitoSpringContainerStarter starter = new JettyMockitoSpringContainerStarter(context, configuration.getMockTargetBeans(), configuration.getContextBeans(), configuration);
  context.addBean(starter, true);
}

代码示例来源:origin: org.igniterealtime.openfire/xmppserver

private void createWebAppContext() {
  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: org.eclipse.jetty/jetty-quickstart

public void visitContainerInitializer (WebAppContext context, ContainerInitializer containerInitializer)
{
  if (containerInitializer == null)
    return;
  
  //add the ContainerInitializer to the list of container initializers
  List<ContainerInitializer> containerInitializers = (List<ContainerInitializer>)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
  if (containerInitializers == null)
  {
    containerInitializers = new ArrayList<ContainerInitializer>();
    context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, containerInitializers);
  }
  
  containerInitializers.add(containerInitializer);
  //Ensure a bean is set up on the context that will invoke the ContainerInitializers as the context starts
  ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER);
  if (starter == null)
  {
    starter = new ServletContainerInitializersStarter(context);
    context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter);
    context.addBean(starter, true);
  }
}

代码示例来源:origin: io.jenkins.jenkinsfile-runner/setup

/**
 * Sets up Jetty without any actual TCP port serving HTTP.
 */
@Override
protected ServletContext createWebServer() throws Exception {
  QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10);
  server = new Server(queuedThreadPool);
  WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath);
  context.setClassLoader(getClass().getClassLoader());
  context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
  context.addBean(new NoListenerConfiguration(context));
  server.setHandler(context);
  context.getSecurityHandler().setLoginService(configureUserRealm());
  context.setResourceBase(bootstrap.warDir.getPath());
  server.start();
  localPort = -1;
  setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir));
  return context.getServletContext();
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);

代码示例来源:origin: jenkinsci/jenkins-test-harness

context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);

代码示例来源:origin: jenkinsci/jenkinsfile-runner

/**
 * Sets up Jetty without any actual TCP port serving HTTP.
 */
@Override
protected ServletContext createWebServer() throws Exception {
  QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10);
  server = new Server(queuedThreadPool);
  WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath);
  context.setClassLoader(getClass().getClassLoader());
  context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
  context.addBean(new NoListenerConfiguration(context));
  server.setHandler(context);
  context.getSecurityHandler().setLoginService(configureUserRealm());
  context.setResourceBase(bootstrap.warDir.getPath());
  server.start();
  localPort = -1;
  setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir));
  return context.getServletContext();
}

代码示例来源:origin: stackoverflow.com

initializers.add(initializer);
context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
context.addBean(sciStarter, true);

代码示例来源:origin: us.springett/alpine-executable-war

context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

listener.setWebAppContext(context);
context.setAttribute(CONTAINER_INITIALIZER_LISTENER, listener);
context.addBean(listener, true);

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

starter = new ServletContainerInitializersStarter(context);
context.setAttribute(CONTAINER_INITIALIZER_STARTER, starter);
context.addBean(starter, true);

代码示例来源:origin: OpenNMS/opennms

@Override
public ContextHandler createContextHandler(final App app) throws Exception {
  final ContextHandler handler = super.createContextHandler(app);
  /*
   * Add an alias check that accepts double slashes in our resource paths.
   */
  handler.addAliasCheck(new ApproveAbsolutePathAliases());
  /*
   * Pulled from: http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html
   *
   * Configure the application to support the compilation of JSP files.
   * We need a new class loader and some stuff so that Jetty can call the
   * onStartup() methods as required.
   */
  if (handler instanceof WebAppContext) {
    WebAppContext context = (WebAppContext)handler;
    context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, jspInitializers());
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    context.addBean(new ServletContainerInitializersStarter(context), true);
  }
  return handler;
}

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

@Override
public ContextHandler createContextHandler(final App app) throws Exception {
  final ContextHandler handler = super.createContextHandler(app);
  /*
   * Add an alias check that accepts double slashes in our resource paths.
   */
  handler.addAliasCheck(new ApproveAbsolutePathAliases());
  /*
   * Pulled from: http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html
   *
   * Configure the application to support the compilation of JSP files.
   * We need a new class loader and some stuff so that Jetty can call the
   * onStartup() methods as required.
   */
  if (handler instanceof WebAppContext) {
    WebAppContext context = (WebAppContext)handler;
    context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, jspInitializers());
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    context.addBean(new ServletContainerInitializersStarter(context), true);
  }
  return handler;
}

代码示例来源:origin: jenkinsci/kubernetes-pipeline-plugin

context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);

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

starter = new ServletContainerInitializersStarter(context);
context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter);
context.addBean(starter, true);

相关文章

WebAppContext类方法