Package org.mortbay.jetty.webapp

Examples of org.mortbay.jetty.webapp.WebAppContext


        server.stop();
    }

    public WebAppContext addWebAppContext(String warPath, String contextPath)
    {
        WebAppContext context = new WebAppContext(contexts, warPath, contextPath);

        TerracottaSessionManager sessionManager = new TestTerracottaSessionManager();
        sessionManager.setIdManager(sessionIdManager);
        sessionManager.setMaxInactiveInterval(maxInactivePeriod);
        sessionManager.setScavengePeriodMs(TimeUnit.SECONDS.toMillis(scavengePeriod));

        SessionHandler sessionHandler = new TerracottaSessionHandler(sessionManager);
        sessionManager.setSessionHandler(sessionHandler);
        context.setSessionHandler(sessionHandler);

        return context;
  }
View Full Code Here


    public void invalidateAll(String clusterId)
    {
        Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
        for (int i = 0; contexts != null && i < contexts.length; i++)
        {
            WebAppContext webAppContext = (WebAppContext)contexts[i];
            SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
            if (sessionManager instanceof AbstractSessionManager)
            {
                Session session = ((AbstractSessionManager)sessionManager).getSession(clusterId);
                if (session != null) session.invalidate();
            }
View Full Code Here

        if (basis!=null)
            return basis;
       
        if (_managed!=null && _managed instanceof WebAppContext)
        {
            WebAppContext context = (WebAppContext)_managed;
            String name = context.getWar();
            if (name!=null)
                return name;
        }
        return null;
    }
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.setWar(args[2]);
                webapp.setContextPath(URIUtil.SLASH);
                contexts.addHandler(webapp);
            }
               
            server.start();
           
View Full Code Here

   
    public void testResourceAnnotations ()
    throws Exception
    {
        Server server = new Server();
        WebAppContext wac = new WebAppContext();
        wac.setServer(server);
       
        InitialContext ic = new InitialContext();
        Context comp = (Context)ic.lookup("java:comp");
        Context env = comp.createSubcontext("env");
       
View Full Code Here

    {
        InitialContext ic = new InitialContext();
       
        Server server = new Server();
       
        WebAppContext wac = new MyWebAppContext();
        wac.setServer(server);
       
        //bind some EnvEntrys at the server level
        EnvEntry ee1 = new EnvEntry(server, "xxx/a", "100", true);
        EnvEntry ee2 = new EnvEntry(server, "yyy/b", "200", false);
        EnvEntry ee3 = new EnvEntry(server, "zzz/c", "300", false);
View Full Code Here

     * that we need for testing.
     */
    protected ServletContext createWebServer() throws Exception {
        server = new Server();

        WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
        context.setClassLoader(getClass().getClassLoader());
        context.setConfigurations(new Configuration[]{new WebXmlConfiguration(), new NoListenerConfiguration()});
        server.setHandler(context);
        context.setMimeTypes(MIME_TYPES);

        SocketConnector connector = new SocketConnector();
        connector.setHeaderBufferSize(12*1024); // use a bigger buffer as Stapler traces can get pretty large on deeply nested URL

        server.setThreadPool(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),new ThreadFactory() {
            public Thread newThread(Runnable r) {
                Thread t = new Thread(r);
                t.setName("Jetty Thread Pool");
                return t;
            }
        })));
        server.addConnector(connector);
        server.addUserRealm(configureUserRealm());
        server.start();

        localPort = connector.getLocalPort();

        return context.getServletContext();
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private WebAppContext createWebContext() {
        String webappDir = System.getProperty("webapp.dir");

        WebAppContext webCtx = new WebAppContext(webappDir == null ? "src/main/webapp" : webappDir, getContextPath());

        if (StringUtils.hasText(getContextConfigLocations())) {
            webCtx.addEventListener(new ContextLoaderListener());
            webCtx.addEventListener(new HttpSessionEventPublisher());
            webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
        }

        ServletHolder servlet = new ServletHolder();
        servlet.setName("testapp");
        servlet.setClassName(DispatcherServlet.class.getName());
        webCtx.addServlet(servlet, "*.htm");

        return webCtx;
    }
View Full Code Here

        server.setStopAtShutdown( true );

        Connector defaultConnector = getDefaultConnector();
        server.setConnectors( new Connector[] { defaultConnector } );

        WebAppContext webapp = createWebApplication();
        webapp.setServer( server );

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

        Handler[] handlers = new Handler[2];
View Full Code Here

        {
            IOUtil.close( outStream );
            IOUtil.close( inStream );
        }

        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath( "/" );
        webapp.setResourceBase( tempWebappDirectory.getAbsolutePath() );
        webapp.setAttribute( DoxiaFilter.SITE_RENDERER_KEY, siteRenderer );
         webapp.getInitParams().put( "org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false" );

        // For external reports
        project.getReporting().setOutputDirectory( tempWebappDirectory.getAbsolutePath() );
        for ( MavenReportExecution mavenReportExecution : getReports() )
        {
            mavenReportExecution.getMavenReport().setReportOutputDirectory( tempWebappDirectory );
        }

        List<MavenReportExecution> filteredReports = filterReports( getReports() );

        List localesList = siteTool.getAvailableLocales( locales );
        webapp.setAttribute( DoxiaFilter.LOCALES_LIST_KEY, localesList );

        // Default is first in the list
        Locale defaultLocale = (Locale) localesList.get( 0 );
        Locale.setDefault( defaultLocale );

        try
        {
            Map i18nDoxiaContexts = new HashMap();

            for ( Iterator it = localesList.iterator(); it.hasNext(); )
            {
                Locale locale = (Locale) it.next();

                SiteRenderingContext i18nContext = createSiteRenderingContext( locale );
                i18nContext.setInputEncoding( getInputEncoding() );
                i18nContext.setOutputEncoding( getOutputEncoding() );

                Map i18nDocuments = locateDocuments( i18nContext, filteredReports, locale );
                DoxiaBean doxiaBean;
                if ( defaultLocale.equals( locale ) )
                {
                    doxiaBean = new DoxiaBean( i18nContext, i18nDocuments, generatedSiteDirectory );
                }
                else
                {
                    doxiaBean = new DoxiaBean( i18nContext, i18nDocuments, new File( generatedSiteDirectory, locale
                        .getLanguage() ) );
                }

                i18nDoxiaContexts.put( locale.getLanguage(), doxiaBean );
                if ( defaultLocale.equals( locale ) )
                {
                    i18nDoxiaContexts.put( "default", doxiaBean );
                }

                if ( defaultLocale.equals( locale ) )
                {
                    siteRenderer.copyResources( i18nContext, new File( siteDirectory, "resources" ),
                                                tempWebappDirectory );
                }
                else
                {
                    siteRenderer.copyResources( i18nContext, new File( siteDirectory, "resources" ),
                                                new File( tempWebappDirectory, locale.getLanguage() ) );
                }
            }

            webapp.setAttribute( DoxiaFilter.I18N_DOXIA_CONTEXTS_KEY, i18nDoxiaContexts );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Unable to set up webapp", e );
        }
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.