当前位置: 首页>>代码示例>>Java>>正文


Java ServletContextHandler.setAttribute方法代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.ServletContextHandler.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextHandler.setAttribute方法的具体用法?Java ServletContextHandler.setAttribute怎么用?Java ServletContextHandler.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.servlet.ServletContextHandler的用法示例。


在下文中一共展示了ServletContextHandler.setAttribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void start(int listenPort, String dbname) throws Exception {
    if (Objects.nonNull(server) && server.isRunning()) {
        LOG.info("ineternal webui already running at port [" + listenPort + "].");
        throw new Exception("already running at port[" + listenPort + "]");
    }
    // remove old connectors
    Connector[] oldConnectors = server.getConnectors();
    if (Objects.nonNull(oldConnectors)) {
        for (Connector oldc : oldConnectors) {
            server.removeConnector(oldc);
        }
    }
    // add new connector
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(listenPort);
    server.setConnectors(new Connector[] { connector });
    // set dbname
    ServletContextHandler contextHandler = (ServletContextHandler) server.getHandler();
    contextHandler.setAttribute("dbname", dbname);
    server.start();
    LOG.info("internal webui server started with listening port [" + listenPort + "].");
}
 
开发者ID:SecureSkyTechnology,项目名称:burpextender-proxyhistory-webui,代码行数:23,代码来源:WebUIApp.java

示例2: addServlet

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void addServlet(String path, ServletHolder servletHolder, boolean requiresAuthentication) {
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(path);
    context.addServlet(servletHolder, MATCH_ALL);
    context.setAttribute(WebService.ATTRIBUTE_PULSAR_NAME, pulsar);

    if (requiresAuthentication && pulsar.getConfiguration().isAuthenticationEnabled()) {
        FilterHolder filter = new FilterHolder(new AuthenticationFilter(pulsar));
        context.addFilter(filter, MATCH_ALL, EnumSet.allOf(DispatcherType.class));
    }

    FilterHolder responseFilter = new FilterHolder(new ResponseHandlerFilter(pulsar));
    context.addFilter(responseFilter, MATCH_ALL, EnumSet.allOf(DispatcherType.class));

    handlers.add(context);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:17,代码来源:WebService.java

示例3: initTracing

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingFeature =
        new ServerTracingDynamicFeature.Builder(mockTracer)
            .withOperationNameProvider(HTTPMethodOperationName.newBuilder())
            .withDecorators(Collections.singletonList(ServerSpanDecorator.STANDARD_TAGS))
            .withSkipPattern("/health")
        .build();
    // TODO clarify dispatcher types
    context.addFilter(new FilterHolder(new SpanFinishingFilter(mockTracer)), "/*",
        EnumSet.of(
            DispatcherType.REQUEST,
            DispatcherType.FORWARD,
            // TODO CXF does not call AsyncListener#onComplete() without this (it calls only onStartAsync)
            DispatcherType.ASYNC,
            DispatcherType.ERROR,
            DispatcherType.INCLUDE));

    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingFeature);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:24,代码来源:AbstractJettyTest.java

示例4: initContext

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private ServletContextHandler initContext(final String contextPath, final Set<Class<?>> classes) {
    final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(contextPath);
    context.setAttribute(ATTR_CLASSES, classes);
    context.setAttribute(ATTR_DI, dependencyInjection);
    return context;
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:8,代码来源:RestServerImpl.java

示例5: startServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override

    @Before
    public void startServer()
        throws Exception
    {
        super.startServer();

        // repo handler

        this.repoServer = new Server( 0 );

        ServletHolder shRepo = new ServletHolder( RepoServlet.class );
        ServletContextHandler contextRepo = new ServletContextHandler();

        contextRepo.setContextPath( "/" );
        contextRepo.addServlet( shRepo, "/*" );

        repoServer.setHandler( contextRepo );
        repoServer.start();
        this.repoServerPort = repoServer.getConnectors()[0].getLocalPort();

        //redirect handler

        this.redirectServer = new Server( 0 );
        ServletHolder shRedirect = new ServletHolder( RedirectServlet.class );
        ServletContextHandler contextRedirect = new ServletContextHandler();
        contextRedirect.setAttribute( "redirectToPort", Integer.toString( this.repoServerPort ) );

        contextRedirect.setContextPath( "/" );
        contextRedirect.addServlet( shRedirect, "/*" );

        redirectServer.setHandler( contextRedirect );
        redirectServer.start();
        this.redirectPort = redirectServer.getConnectors()[0].getLocalPort();
        log.info( "redirect server port {}", redirectPort );

    }
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:39,代码来源:DownloadArtifactsTest.java

示例6: enableMultipartFilter

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private void enableMultipartFilter(HttpEndpoint endpoint, Server server, String connectorKey) throws Exception {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    CamelContext camelContext = this.getCamelContext();
    FilterHolder filterHolder = new FilterHolder();
    filterHolder.setInitParameter("deleteFiles", "true");
    if (ObjectHelper.isNotEmpty(camelContext.getProperty(TMP_DIR))) {
        File file = new File(camelContext.getProperty(TMP_DIR));
        if (!file.isDirectory()) {
            throw new RuntimeCamelException(
                    "The temp file directory of camel-jetty is not exists, please recheck it with directory name :"
                            + camelContext.getProperties().get(TMP_DIR));
        }
        context.setAttribute("javax.servlet.context.tempdir", file);
    }
    // if a filter ref was provided, use it.
    Filter filter = ((JettyHttpEndpoint) endpoint).getMultipartFilter();
    if (filter == null) {
        // if no filter ref was provided, use the default filter
        filter = new MultiPartFilter();
    }
    filterHolder.setFilter(new CamelFilterWrapper(filter));
    String pathSpec = endpoint.getPath();
    if (pathSpec == null || "".equals(pathSpec)) {
        pathSpec = "/";
    }
    if (endpoint.isMatchOnUriPrefix()) {
        pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
    }
    addFilter(context, filterHolder, pathSpec);
    if (LOG.isDebugEnabled()) LOG.debug("using multipart filter implementation " + filter.getClass().getName() + " for path " + pathSpec);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:JettyHttpComponent.java

示例7: addRestResources

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public void addRestResources(String basePath, String javaPackages, WebSocketService service) {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(ObjectMapperFactory.create());
    ResourceConfig config = new ResourceConfig();
    config.packages("jersey.config.server.provider.packages", javaPackages);
    config.register(provider);
    ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
    servletHolder.setAsyncSupported(true);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(basePath);
    context.addServlet(servletHolder, "/*");
    context.setAttribute(ATTRIBUTE_PROXY_SERVICE_NAME, service);
    handlers.add(context);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:15,代码来源:ProxyServer.java

示例8: initTracing

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingBuilder =
        new ServerTracingDynamicFeature.Builder(mockTracer)
            .withOperationNameProvider(WildcardOperationName.newBuilder())
        .build();
    context.addFilter(new FilterHolder(new SpanFinishingFilter(mockTracer)),
        "/*", EnumSet.of(DispatcherType.REQUEST));

    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:16,代码来源:AbstractWildcardOperationNameTest.java

示例9: initTracing

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    Tracer serverTracer = NoopTracerFactory.create();
    ServerTracingDynamicFeature serverTracingBuilder =
            new ServerTracingDynamicFeature.Builder(serverTracer)
                    .build();

    context.setAttribute(TRACER_ATTRIBUTE, serverTracer);
    context.setAttribute(CLIENT_ATTRIBUTE, ClientBuilder.newClient());
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:14,代码来源:AbstractClientTest.java

示例10: initTracing

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override
protected void initTracing(ServletContextHandler context) {
  client.register(new Builder(mockTracer).build());

  ServerTracingDynamicFeature serverTracingBuilder =
      new ServerTracingDynamicFeature.Builder(mockTracer)
          .withOperationNameProvider(ClassNameOperationName.newBuilder())
          .build();
  context.addFilter(new FilterHolder(new SpanFinishingFilter(mockTracer)),
      "/*", EnumSet.of(DispatcherType.REQUEST));

  context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
  context.setAttribute(CLIENT_ATTRIBUTE, client);
  context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:16,代码来源:AbstractClassOperationNameTest.java

示例11: initTracing

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingBuilder =
            new ServerTracingDynamicFeature.Builder(mockTracer)
                    .build();
    context.addFilter(new FilterHolder(new SpanFinishingFilter(mockTracer)),
        "/*", EnumSet.of(DispatcherType.REQUEST));

    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder);
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:15,代码来源:AbstractServerDefaultConfigurationTest.java

示例12: enableMultipartFilter

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private void enableMultipartFilter(HttpCommonEndpoint endpoint, Server server, String connectorKey) throws Exception {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    CamelContext camelContext = this.getCamelContext();
    FilterHolder filterHolder = new FilterHolder();
    filterHolder.setInitParameter("deleteFiles", "true");
    if (ObjectHelper.isNotEmpty(camelContext.getProperty(TMP_DIR))) {
        File file = new File(camelContext.getProperty(TMP_DIR));
        if (!file.isDirectory()) {
            throw new RuntimeCamelException(
                    "The temp file directory of camel-jetty is not exists, please recheck it with directory name :"
                            + camelContext.getProperties().get(TMP_DIR));
        }
        context.setAttribute("javax.servlet.context.tempdir", file);
    }
    // if a filter ref was provided, use it.
    Filter filter = ((JettyHttpEndpoint) endpoint).getMultipartFilter();
    if (filter == null) {
        // if no filter ref was provided, use the default filter
        filter = new MultiPartFilter();
    }
    filterHolder.setFilter(new CamelFilterWrapper(filter));
    String pathSpec = endpoint.getPath();
    if (pathSpec == null || "".equals(pathSpec)) {
        pathSpec = "/";
    }
    if (endpoint.isMatchOnUriPrefix()) {
        pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
    }
    addFilter(context, filterHolder, pathSpec);
    LOG.debug("using multipart filter implementation " + filter.getClass().getName() + " for path " + pathSpec);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:JettyHttpComponent.java

示例13: initServer

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private void initServer() {
  String host = System.getProperty("ios-driver.host");
  if (host == null) {
    host = "0.0.0.0";
  }
  server = new Server(new InetSocketAddress(host, options.getPort()));

  ServletContextHandler wd = new ServletContextHandler(server, "/wd/hub", true, false);
  wd.addServlet(
      new ServletHolder(new HttpServlet() {
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
          response.setContentType("application/json;charset=UTF-8");
          response.setCharacterEncoding("UTF-8");
          response.setStatus(200);
          response.getWriter().print("{}");
          response.getWriter().close();
          p("Received /shutdown command. Shutting down.");
          new Thread() {
            @Override
            public void run() {
              try {
                IOSServer.this.stop();
              } catch (Exception e) {
                log.warning("Exception shutting down: " + e);
                Runtime.getRuntime().exit(1);
              }
            }
          }.start();
        }
      }),
      "/shutdown");
  wd.addServlet(IOSServlet.class, "/*");

  wd.getServletContext().getContextHandler().setMaxFormContentSize(500000);
  wd.setAttribute(DRIVER, driver);
  wd.setAttribute(SERVER, this);

  ServletContextHandler extra = new ServletContextHandler(server, "/", true, false);
  extra.setAttribute(DRIVER, driver);

  HandlerList handlers = new HandlerList();
  handlers.setHandlers(new Handler[] {wd, extra});
  server.setHandler(handlers);
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:47,代码来源:IOSServer.java

示例14: main

import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
/**
 * Server starter to initialize the server.
 * @param args
 */
public static void main(String[] args) {
    Server server = new Server(PORT);
    ServletContextHandler servhandler = new ServletContextHandler(ServletContextHandler.SESSIONS);

    VelocityEngine velocity = new VelocityEngine();
    velocity.init();

    servhandler.setResourceBase(DIR);
    servhandler.setContextPath("/");
    servhandler.setAttribute("templateEngine", velocity);

    servhandler.addServlet(IndexServlet.class, "/index");
    servhandler.addServlet(HotelServlet.class, "/hotel");
    servhandler.addServlet(CategoryServlet.class, "/category");
    servhandler.addServlet(CityServlet.class, "/city");
    servhandler.addServlet(PageServlet.class, "/page");
    servhandler.addServlet(HotelDetailServlet.class, "/hotelDetail");
    servhandler.addServlet(ReviewServlet.class, "/review");
    servhandler.addServlet(LikeServlet.class, "/like");
    servhandler.addServlet(ReviewModalServlet.class, "/reviewmodal");
    servhandler.addServlet(ShowLikeServlet.class, "/showlike");
    servhandler.addServlet(AttractionServlet.class, "/attraction");
    servhandler.addServlet(MyPageServlet.class, "/mypage");
    servhandler.addServlet(ClearServlet.class, "/clear");
    server.setHandler(servhandler);

    ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);
    holderPwd.setInitParameter("dirAllowed","false");
    servhandler.addServlet(holderPwd,"/");

    System.out.println("Starting server on port " + PORT + "...");

    try {
        server.start();
        server.join();

        System.out.println("Exiting...");
    }
    catch (Exception ex) {
        System.out.println("Interrupted while running server. " + ex);
        System.exit(-1);
    }
}
 
开发者ID:brianisadog,项目名称:hotelApp,代码行数:48,代码来源:JettyServer.java


注:本文中的org.eclipse.jetty.servlet.ServletContextHandler.setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。