Package org.mortbay.jetty.webapp

Examples of org.mortbay.jetty.webapp.WebAppContext


     */
    @SuppressWarnings("unchecked")
    @Override
    protected WebAppContext createWebAppContext(TreeLogger logger,
        File appRootDir) {
      return new WebAppContext(appRootDir.getAbsolutePath(), "/") {
        {
          // Prevent file locking on Windows; pick up file changes.
          getInitParams().put(
              "org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");

View Full Code Here


        jettyServer.setStopAtShutdown( true );

        Connector connector = ( isSSL ? getSSLConnector() : getDefaultConnector() );
        jettyServer.setConnectors( new Connector[] { connector } );

        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath( "/" );
        webapp.setResourceBase( getBasedir() + "/target/classes/" );

        webapp.setServer( jettyServer );

        if ( withAuth )
        {
            Constraint constraint = new Constraint();
            constraint.setName( Constraint.__BASIC_AUTH );
            constraint.setRoles( new String[] { "user", "admin" } );
            constraint.setAuthenticate( true );

            ConstraintMapping cm = new ConstraintMapping();
            cm.setConstraint( constraint );
            cm.setPathSpec( "/*" );

            SecurityHandler sh = new SecurityHandler();
            sh.setUserRealm( new HashUserRealm( "MyRealm", getBasedir() + "/src/test/resources/realm.properties" ) );
            sh.setConstraintMappings( new ConstraintMapping[] { cm } );

            webapp.addHandler( sh );
        }

        DefaultHandler defaultHandler = new DefaultHandler();
        defaultHandler.setServer( jettyServer );

View Full Code Here

                        String mountPoint = webappInfo.mountPoint;
                        if (mountPoint.endsWith("/*")) {
                            mountPoint = mountPoint.substring(0, mountPoint.lastIndexOf("/"));
                        }

                        WebAppContext context = new WebAppContext(location, mountPoint);
                        context.setAttribute("_serverId", webappInfo.server);
                        context.setLogUrlOnStart(true);

                         // set the session manager
                        HashSessionManager sm = new HashSessionManager();
                        context.setSessionHandler(new SessionHandler(sm));

                        // set the virtual hosts
                        if (virtualHosts != null && !virtualHosts.isEmpty()) {
                            context.setVirtualHosts((String[]) virtualHosts.toArray());
                        }

                        // set the init parameters
                        if (initParameters != null && !initParameters.isEmpty()) {
                            context.setInitParams(initParameters);
                        }

                        server.addHandler(context);
                    }
                }
View Full Code Here

            conn.setAcceptQueueSize(100);
            conn.setMaxIdleTime(1000 * 60 * 60);
            conn.setSoLingerTime(-1);
            jettyServer.setConnectors(new Connector[] { conn });

            WebAppContext wah = new WebAppContext();
            wah.setContextPath("/geoserver");
            wah.setWar("src/main/webapp");
            jettyServer.setHandler(wah);
            wah.setTempDirectory(new File("target/work"));

            String jettyConfigFile = System.getProperty("jetty.config.file");
            if (jettyConfigFile != null) {
                log.info("Loading Jetty config from file: " + jettyConfigFile);
                (new XmlConfiguration(new FileInputStream(jettyConfigFile))).configure(jettyServer);
View Full Code Here

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(port);
        server.setConnectors(new Connector[] {connector});

        WebAppContext webappcontext = new WebAppContext();
        webappcontext.setContextPath(contextPath);

        String warPath = null;
        try {
            warPath = getClass().getResource(resourcePath).toURI().getPath();
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }
       
        webappcontext.setWar(warPath);

        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});

        server.setHandler(handlers);
View Full Code Here

    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(7233);
    server.setConnectors(new Connector[] { connector });

    WebAppContext web = new WebAppContext();
    web.setContextPath("/");
    web.setWar("src/main/webapp");
    server.addHandler(web);

    try
    {
      server.start();
View Full Code Here

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(9080);
        server.setConnectors(new Connector[] {connector});

        WebAppContext webappcontext = new WebAppContext();
        String contextPath = null;
        try {
            contextPath = getClass().getResource("/jaxrs_dispatch").toURI().getPath();
        } catch (URISyntaxException e1) {
            e1.printStackTrace();
        }
        webappcontext.setContextPath("/");

        webappcontext.setWar(contextPath);

        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});

        server.setHandler(handlers);
View Full Code Here

    public static void main(String[] args) throws Exception {  
        long begin = System.currentTimeMillis();  
        Connector connector = new SelectChannelConnector();  
        connector.setPort(Integer.getInteger("jetty.port", 8080).intValue());  
 
        WebAppContext webapp = new WebAppContext("web", "/");  
        webapp.setDefaultsDescriptor("./test/runtime/webdefault.xml");  
          
        Server server = new Server();  
        server.setConnectors(new Connector[] { connector });  
        server.setHandler(webapp);  
        server.start();  
View Full Code Here

            {
                WebAppContext.addWebApplications(server, args[2], WebAppContext.WEB_DEFAULTS_XML, true, true);
            }
            else if ("-webapp".equals(args[1]))
            {
                WebAppContext webapp = new WebAppContext();
                webapp.setResourceBase(args[2]);
                webapp.setContextPath(URIUtil.SLASH);
                contexts.addHandler(webapp);
               
            }
               
            server.start();
View Full Code Here

  
                }
            }

            // create a webapp
            WebAppContext wah=null;
            if (_contexts instanceof ContextHandlerCollection &&
                WebAppContext.class.isAssignableFrom(((ContextHandlerCollection)_contexts).getContextClass()))
            {
                try
                {
                    wah=(WebAppContext)((ContextHandlerCollection)_contexts).getContextClass().newInstance();
                }
                catch (Exception e)
                {
                    throw new Error(e);
                }
            }
            else
            {
                wah=new WebAppContext();
            }
           
            // configure it
            wah.setContextPath(context);
            if (_configurationClasses!=null)
                wah.setConfigurationClasses(_configurationClasses);
            if (_defaultsDescriptor!=null)
                wah.setDefaultsDescriptor(_defaultsDescriptor);
            wah.setExtractWAR(_extract);
            wah.setWar(app.toString());
            wah.setParentLoaderPriority(_parentLoaderPriority);
            // add it
            _contexts.addHandler(wah);
            _deployed.add(wah);
           
            if (_contexts.isStarted())
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.webapp.WebAppContext

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.