Package org.eclipse.jetty.servlet

Examples of org.eclipse.jetty.servlet.ServletContextHandler$Context


    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected CamelServlet createServletForConnector(Server server, Connector connector, List<Handler> handlers) throws Exception {
        ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
        context.setConnectorNames(new String[] {connector.getName()});

        if (handlers != null && !handlers.isEmpty()) {
            for (Handler handler : handlers) {
                if (handler instanceof HandlerWrapper) {
                    ((HandlerWrapper) handler).setHandler(server.getHandler());
                    server.setHandler(handler);
                } else {
                    HandlerCollection handlerCollection = new HandlerCollection();
                    handlerCollection.addHandler(server.getHandler());
                    handlerCollection.addHandler(handler);
                    server.setHandler(handlerCollection);
                }
            }
        }

        // use Jetty continuations
        CamelServlet camelServlet = new CamelContinuationServlet();
        ServletHolder holder = new ServletHolder();
        holder.setServlet(camelServlet);
        CamelContext camelContext = this.getCamelContext();
        FilterHolder filterHolder = new FilterHolder();
        filterHolder.setInitParameter("deleteFiles", "true");
        if (ObjectHelper.isNotEmpty(camelContext.getProperties().get(TMP_DIR))) {
            File file =  new File(camelContext.getProperties().get(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);
        }
        filterHolder.setFilter(new MultiPartFilter());
        //add the default MultiPartFilter filter for it
        context.addFilter(filterHolder, "/*", 0);
        context.addServlet(holder, "/*");

        return camelServlet;
    }
View Full Code Here


           
        try {
            if (resourcePath == null) {
                // Register and map the dispatcher servlet
                final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet());
                final ServletContextHandler context = new ServletContextHandler();        
                context.setContextPath(contextPath);         
                context.addEventListener(new Listener());        
                context.addEventListener(new BeanManagerResourceBindingListener());
                context.addServlet(servletHolder, "/rest/*");
                server.setHandler(context);
            } else {       
                final WebAppContext context = new WebAppContext();
                context.setContextPath(contextPath);
                context.setWar(getClass().getResource(resourcePath).toURI().getPath());
                context.setServerClasses(new String[] {
                    "org.eclipse.jetty.servlet.ServletContextHandler.Decorator"
                });
       
                HandlerCollection handlers = new HandlerCollection();
                handlers.setHandlers(new Handler[] {context, new DefaultHandler()});
View Full Code Here

    }

    protected void createContext( Server server, File repositoryDirectory )
        throws IOException
    {
        ServletContextHandler context = new ServletContextHandler();
        context.setResourceBase( repositoryDirectory.getAbsolutePath() );
        context.setContextPath( "/" );
        ServletHolder sh = new ServletHolder( DefaultServlet.class );
        context.addServlet( sh, "/" );
        server.setHandler( context );

    }
View Full Code Here

        repo.server = new Server( 0 );
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        repo.server.setHandler( contexts );

        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath( repo.context );
        context.setResourceBase( repo.root.getAbsolutePath() );
        context.setAttribute( "dirAllowed", true );
        context.setAttribute( "maxCacheSize", 0 );

        ServletHolder sh = new ServletHolder( DefaultServlet.class );
        context.addServlet( sh, "/" );

        contexts.addHandler( context );

        repo.server.start();
View Full Code Here

    {

        System.setProperty( "redback.admin.creation.file", "target/auto-admin-creation.properties" );
        this.server = new Server( 0 );

        ServletContextHandler context = new ServletContextHandler();

        context.setContextPath( "/" );

        context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() );

        ContextLoaderListener contextLoaderListener = new ContextLoaderListener();

        context.addEventListener( contextLoaderListener );

        ServletHolder sh = new ServletHolder( CXFServlet.class );

        SessionHandler sessionHandler = new SessionHandler();

        context.setSessionHandler( sessionHandler );

        context.addServlet( sh, "/" + getRestServicesPath() + "/*" );

        ServletHolder repoSh = new ServletHolder( RepositoryServlet.class );
        context.addServlet( repoSh, "/repository/*" );

        server.setHandler( context );
        this.server.start();
        Connector connector = this.server.getConnectors()[0];
        this.port = connector.getLocalPort();
View Full Code Here

        //redirect handler

        this.redirectServer = new Server( 0 );
        ServletHolder shRedirect = new ServletHolder( RedirectServlet.class );
        ServletContextHandler contextRedirect = new ServletContextHandler();

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

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

  private Server server;

  public void startServer(final Class<? extends ODataServiceFactory> factoryClass, final int fixedPort) {
    try {
      final ServletContextHandler contextHandler = createContextHandler(factoryClass);
      final InetSocketAddress isa = new InetSocketAddress(DEFAULT_HOST, fixedPort);
      server = new Server(isa);

      server.setHandler(contextHandler);
      server.start();
View Full Code Here

  }

  public void startServer(final Class<? extends ODataServiceFactory> factoryClass) {
    try {
      for (int port = PORT_MIN; port <= PORT_MAX; port += PORT_INC) {
        final ServletContextHandler contextHandler = createContextHandler(factoryClass);
        try {
          final InetSocketAddress isa = new InetSocketAddress(DEFAULT_HOST, port);
          server = new Server(isa);

          server.setHandler(contextHandler);
View Full Code Here

    if (pathSplit > 0) {
      odataServletHolder.setInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL, Integer.toString(pathSplit));
    }

    final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    contextHandler.setContextPath("/abc");
    contextHandler.addServlet(odataServletHolder, path + "/*");
    return contextHandler;
  }
View Full Code Here

        try {
            httpServer = new Server(Integer.parseInt(PORT));
            ContextHandlerCollection contexts = new ContextHandlerCollection();
            httpServer.setHandler(contexts);

            ServletContextHandler root = new ServletContextHandler(contexts, "/",
                                                                   ServletContextHandler.SESSIONS);

            CXFNonSpringServlet cxf = new CXFNonSpringServlet();
            ServletHolder servlet = new ServletHolder(cxf);
            servlet.setName("soap");
            servlet.setForcedPath("soap");
            root.addServlet(servlet, "/soap/*");

            httpServer.start();

            Bus bus = cxf.getBus();
            setBus(bus);
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.servlet.ServletContextHandler$Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.