public WebAppContext getWebAppContext( Context context, ContextHandlerCollection parent ) throws Exception { WebAppContext webapp = new WebAppContext( parent, getWarPath(), getContextPath() ); // Put all our custom attribute into the servlet context if ( getContextAttributes() != null ) { for ( Iterator<Object> i = getContextAttributes().keySet().iterator(); i.hasNext(); ) { String attributeKey = (String) i.next(); webapp.setAttribute( attributeKey, getContextAttributes().getProperty( attributeKey ) ); } } // Put the container for the application into the servlet context PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); webapp.setAttribute( PlexusConstants.PLEXUS_KEY, container ); webapp.setClassLoader( container.getContainerRealm() ); return webapp; } }
webAppContext.setClassLoader( container.getContainerRealm() ); webAppContext.setClassLoader( classLoader ); webAppContext.setParentLoaderPriority( false );
public void lifeCycleStarting( LifeCycle lifecycle ) { if ( lifecycle instanceof ContextHandlerCollection ) { Logger logger = Log.getLogger( getClass().getName() ); Handler[] childHandlers = ((ContextHandlerCollection) lifecycle).getChildHandlers(); if ( childHandlers != null && childHandlers.length > 0 ) { for ( Handler child : childHandlers ) { if ( child instanceof WebAppContext ) { WebAppContext webapp = (WebAppContext) child; if ( logger != null ) { logger.info( "Injecting Plexus container for: {} (context path: {})", webapp.getDisplayName(), webapp.getContextPath() ); } PlexusContainer container = PlexusContainerHolder.get(); webapp.setAttribute( PlexusConstants.PLEXUS_KEY, container ); webapp.setClassLoader( container.getContainerRealm() ); } } } } }
context.setClassLoader(cl);
/** * Prepares a webapp hosting environment to get {@link ServletContext} * implementation 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(); server.addConnector(connector); server.addUserRealm(configureUserRealm()); server.start(); localPort = connector.getLocalPort(); return context.getServletContext(); }
/** * Prepares a webapp hosting environment to get {@link ServletContext} implementation * 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(); server.addConnector(connector); server.addUserRealm(configureUserRealm()); server.start(); localPort = connector.getLocalPort(); return context.getServletContext(); }
/** * Prepares a webapp hosting environment to get {@link ServletContext} implementation * 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(); server.addConnector(connector); server.addUserRealm(configureUserRealm()); server.start(); localPort = connector.getLocalPort(); return context.getServletContext(); }
private void createContext() { webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.setBaseResource(serverRoot); webAppContext.setClassLoader(getClassLoader()); org.mortbay.jetty.servlet.ServletHolder defaultServletHolder = new org.mortbay.jetty.servlet.ServletHolder(new DefaultServlet()); //defaultServletHolder.setInitParameter("aliases", Boolean.FALSE.toString()); webAppContext.addServlet(defaultServletHolder, "/"); webAppContext.addEventListener(new HttpSessionListener() { public void sessionDestroyed(HttpSessionEvent se) { session = null; } public void sessionCreated(HttpSessionEvent se) { session = se.getSession(); } }); }
private void prepareWebapp(final File file, final File repository, final File tmp) { webapp.setContextPath("/"); webapp.setWar(file.getPath()); webapp.setClassLoader(JackrabbitMain.class.getClassLoader()); // we use a modified web.xml which has some servlets remove (which produce random empty directories) final URL res = getResource("/jcrweb.xml"); if (res != null) { webapp.setDescriptor(res.toString()); } webapp.setExtractWAR(false); webapp.setTempDirectory(tmp); final ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class); servlet.setInitOrder(1); servlet.setInitParameter("repository.home", repository.getAbsolutePath()); final String conf = command.getOptionValue("conf"); if (conf != null) { servlet.setInitParameter("repository.config", conf); } webapp.addServlet(servlet, "/repository.properties"); }
private void prepareWebapp(final File file, final File repository, final File tmp) { webapp.setContextPath("/"); webapp.setWar(file.getPath()); webapp.setClassLoader(JackrabbitMain.class.getClassLoader()); // we use a modified web.xml which has some servlets remove (which produce random empty directories) final URL res = getResource("/jcrweb.xml"); if (res != null) { webapp.setDescriptor(res.toString()); } webapp.setExtractWAR(false); webapp.setTempDirectory(tmp); final ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class); servlet.setInitOrder(1); servlet.setInitParameter("repository.home", repository.getAbsolutePath()); final String conf = command.getOptionValue("conf"); if (conf != null) { servlet.setInitParameter("repository.config", conf); } webapp.addServlet(servlet, "/repository.properties"); }
setClassLoader(classLoader); _ownClassLoader=true;
wac.setClassLoader(Utils.createWebAppClassLoader(bundle, Server.class));
wac.setClassLoader(Utils.createWebAppClassLoader(bundle, Server.class));