context.addListener(eventListener);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(listenerClass)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
private static HttpServer create(URI u, Servlet servlet) throws IOException { String path = u.getPath(); path = String.format("/%s", UriComponent.decodePath(u.getPath(), true) .get(1).toString()); WebappContext context = new WebappContext("GrizzlyContext", path); context.addListener(MyListener.class); ServletRegistration registration; registration = context.addServlet(servlet.getClass().getName(), servlet); registration.addMapping("/*"); HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u); context.deploy(server); return server; }
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
addListener(createEventListenerInstance(className)); } catch (Exception e) { throw new IllegalStateException(e);
@Before public void setUp() throws Exception { if (server == null) { System.out.println("Initializing an instance of Grizzly Container"); final ResourceConfig rc = new ResourceConfig(A.class, B.class); WebappContext ctx = new WebappContext() {}; ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml"); ctx.addListener("com.package.something.AServletContextListener"); server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); ctx.deploy(server); } }
@Before public void setup() throws Exception { if (server == null) { System.out.println("Initializing an instance of Grizzly Container ..."); final ResourceConfig rc = new ResourceConfig(ResourceEndpointIntegrationTest.class, ..., ..., ...); //update WebappContext ctx = new WebappContext("IntegrationTestContext"); //register your listeners from web.xml in here ctx.addListener("com.xxx.yyy.XEndpointServletContextListener"); //register your applicationContext.xml here ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml"); //ServletRegistration is needed to load the ResourceConfig rc inside ServletContainer or you will have no //Servlet-based features available ServletRegistration registration = ctx.addServlet("ServletContainer", new ServletContainer(rc)); //Initialize the Grizzly server passing it base URL server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI)); //Deploy the server using our custom context ctx.deploy(server); } }
reg.addMapping("/*"); ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml"); ctx.addListener("org.springframework.web.context.ContextLoaderListener"); ctx.addListener("org.springframework.web.context.request.RequestContextListener"); ctx.deploy(server);
context.addListener(eventListener);