Java Code Examples for org.mortbay.jetty.webapp.WebAppContext#setClassLoader()
The following examples show how to use
org.mortbay.jetty.webapp.WebAppContext#setClassLoader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example 2
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example 3
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8080 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/xdocreport-webapp" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); // JSP Servlet + Context Context jsp_ctx = new Context( servlet_contexts, "/jsp", Context.SESSIONS ); jsp_ctx.addServlet( new ServletHolder( new org.apache.jasper.servlet.JspServlet() ), "*.jsp" ); server.start(); server.join(); }
Example 4
Source File: EmbeddedServer.java From xdocreport.samples with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server( 8081 ); WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" ); ContextHandlerCollection servlet_contexts = new ContextHandlerCollection(); webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } ); server.setHandler( handlers ); server.start(); server.join(); }
Example 5
Source File: HermesClassLoaderMetaServer.java From hermes with Apache License 2.0 | 5 votes |
public void startServer() throws Exception { Server server = new Server(port); WebAppContext context = new ResourceFallbackWebAppContext(); configure(context); ClassLoader parent = new HermesClassLoader(((URLClassLoader) this.getClass().getClassLoader()).getURLs(), "com.ctrip.", "com.dianping.", "org.unidal."); context.setClassLoader(new WebAppClassLoader(parent, context)); context.addServlet(new ServletHolder(new WebModuleServlet(m_resource)), "/"); // find LoadMocksListener with HermesClassLoader Class clazz = parent.loadClass("com.ctrip.hermes.metaserver.fulltest.LoadMocksListener"); Object obj = clazz.newInstance(); Field field = clazz.getDeclaredField("port"); field.setAccessible(true); field.set(obj, port); context.addEventListener((EventListener) obj); server.addHandler(context); try { server.start(); } catch (java.net.BindException e) { log.warn("CustomClassLoaderMetaServer[localhost:{}] start fail, BindException.", port); } postConfigure(context); m_server = server; }