context.setDisplayName("JettyContext"); context.setContextPath(path); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); ServletHolder holder; if (c != null) {
ctx.setConfigurations(new Configuration[]{ new WebInfConfiguration(), new WebXmlConfiguration(),
Configuration[] configurations = getWebAppContextConfigurations(context, initializersToUse); context.setConfigurations(configurations); context.setThrowUnavailableOnStartupException(true); configureSession(context);
public class JettyServer { private static final Logger LOGGER = LoggerFactory.getLogger(JettyServer.class); public static void main(final String[] args) throws Exception { LOGGER.debug("Starting jetty server"); int port = 8083; LOGGER.debug("Setting the port to {}", port); final Server server = new Server(port); final WebAppContext root = new WebAppContext(); root.setContextPath("/"); root.setResourceBase("."); EnvConfiguration envConfiguration = new EnvConfiguration(); envConfiguration.setJettyEnvXml(JettyServer.class.getResource("/WEB-INF/jetty-env.xml").toURI().toURL()); //Adding the actual classes instead of just the class names root.setConfigurations(new Configuration[]{envConfiguration, new PlusConfiguration(), new WebXmlConfiguration()}); root.setDescriptor(JettyServer.class.getResource("/WEB-INF/web.xml").toString()); server.setHandler(root); server.start(); server.join(); } }
public static void main(String[] args) throws Exception { String jetty_home = ".."; int appli_port = 8080; Server server = new Server(appli_port); ProtectionDomain protectionDomain = Loader.class.getProtectionDomain(); URL location = protectionDomain.getCodeSource().getLocation(); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setWar(location.toExternalForm()); // setup JNDI EnvConfiguration envConfiguration = new EnvConfiguration(); URL url = new File("path to jetty-env.xml").toURI().toURL(); envConfiguration.setJettyEnvXml(url); webapp.setConfigurations(new Configuration[] {new WebInfConfiguration(), envConfiguration, new WebXmlConfiguration()}); server.setHandler(webapp); server.start(); server.join(); }
public Map<Class<?>, Object> add(List<Class<?>> mockTargetBeans, List<Class<?>> defaultContextBeans, URL url) throws Exception { WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath(url.getPath()); MockitoSpringApplicationListener mockitoSpringConfiguration = new MockitoSpringApplicationListener(); mockitoSpringConfiguration.setContextBeans(defaultContextBeans); mockitoSpringConfiguration.setMockTargetBeans(mockTargetBeans); JettyMockitoSpringConfiguration configuration = new JettyMockitoSpringConfiguration(mockitoSpringConfiguration); webAppContext.setConfigurations(new org.eclipse.jetty.webapp.Configuration[] { configuration }); webAppContext.setParentLoaderPriority(true); Server server = new Server(url.getPort()); server.setHandler(webAppContext); servers.add(server); server.start(); return mockitoSpringConfiguration.getAll(); }
context.setWar("src/main/webapp"); context.getMetaData().addContainerResource(new FileResource(new File("./target/classes").toURI())); context.setConfigurations(new Configuration[]{ new WebXmlConfiguration(), new AnnotationConfiguration()
WebAppContext myWebAppContext= new WebAppContext(); myWebAppContext.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebInfConfiguration(), new WebXmlConfiguration(), new FragmentConfiguration(), new EnvConfiguration(), new PlusConfiguration(), new JettyWebXmlConfiguration() });
/** * Sets up Jetty without any actual TCP port serving HTTP. */ @Override protected ServletContext createWebServer() throws Exception { QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10); server = new Server(queuedThreadPool); WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath); context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.getSecurityHandler().setLoginService(configureUserRealm()); context.setResourceBase(bootstrap.warDir.getPath()); server.start(); localPort = -1; setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir)); return context.getServletContext(); }
public class EmbedMe { public static void main(String[] args) throws Exception { int port = 8080; Server server = new Server(port); String wardir = "target/sample-webapp-1-SNAPSHOT"; WebAppContext context = new WebAppContext(); context.setResourceBase(wardir); context.setDescriptor(wardir + "WEB-INF/web.xml"); context.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebXmlConfiguration(), new WebInfConfiguration(), new TagLibConfiguration(), new PlusConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new EnvConfiguration() }); context.setContextPath("/"); context.setParentLoaderPriority(true); server.setHandler(context); server.start(); server.join(); } }
/** * Sets up Jetty without any actual TCP port serving HTTP. */ @Override protected ServletContext createWebServer() throws Exception { QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10); server = new Server(queuedThreadPool); WebAppContext context = new WebAppContext(bootstrap.warDir.getPath(), contextPath); context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context); context.getSecurityHandler().setLoginService(configureUserRealm()); context.setResourceBase(bootstrap.warDir.getPath()); server.start(); localPort = -1; setPluginManager(new PluginManagerImpl(context.getServletContext(), bootstrap.pluginsDir)); return context.getServletContext(); }
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context);
context.setResourceBase(explodedWarDir.getPath()); context.setClassLoader(getClass().getClassLoader()); context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context);
webapp.setConfigurations(new Configuration[] { new SelfConfiguration() });
private WebAppContext createWebAppContext(String contextPath, Map<String, List<Injector<?>>> injectors, List<URL> locations, ClassLoader parentClassLoader) throws IOException { WebAppContext context; if (locations.size() == 1) { context = new ManagedWebAppContext(locations.get(0).toExternalForm(), contextPath); } else { context = new ManagedWebAppContext(null, contextPath); // add the resource paths String[] paths = new String[locations.size()]; for (int i = 0; i < locations.size(); i++) { URL location = locations.get(i); paths[i] = (location.toExternalForm()); } ResourceCollection resources = new ResourceCollection(paths); context.setBaseResource(resources); } context.setParentLoaderPriority(true); InjectingDecorator decorator = new InjectingDecorator(injectors); context.getObjectFactory().addDecorator(decorator); WebAppClassLoader webAppClassLoader = new WebAppClassLoader(parentClassLoader, context); context.setClassLoader(webAppClassLoader); // don't extract the war since this has already been done by the WAR classpath processor context.setExtractWAR(false); Configuration[] configurations = createConfigurations(); context.setConfigurations(configurations); return context; }
private WebAppContext createWebAppContext(String contextPath, Map<String, List<Injector<?>>> injectors, List<URL> locations, ClassLoader parentClassLoader) throws IOException { WebAppContext context; if (locations.size() == 1) { context = new ManagedWebAppContext(locations.get(0).toExternalForm(), contextPath); } else { context = new ManagedWebAppContext(null, contextPath); // add the resource paths String[] paths = new String[locations.size()]; for (int i = 0; i < locations.size(); i++) { URL location = locations.get(i); paths[i] = (location.toExternalForm()); } ResourceCollection resources = new ResourceCollection(paths); context.setBaseResource(resources); } context.setParentLoaderPriority(true); InjectingDecorator decorator = new InjectingDecorator(injectors); context.getObjectFactory().addDecorator(decorator); WebAppClassLoader webAppClassLoader = new WebAppClassLoader(parentClassLoader, context); context.setClassLoader(webAppClassLoader); // don't extract the war since this has already been done by the WAR classpath processor context.setExtractWAR(false); Configuration[] configurations = createConfigurations(); context.setConfigurations(configurations); return context; }
webAppContext.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new AnnotationConfiguration() });
webAppContext.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(), new AnnotationConfiguration() });
protected void run() { server = new Server(port); try { final WebAppContext context = new WebAppContext(); context.setContextPath(contextPath); context.setConfigurations(new Configuration[] { new WebXmlConfiguration(), new AnnotationConfiguration() }); for (final Resource resource: resources) { context.getMetaData().addContainerResource(resource); } configureContext(context); server.setHandler(context); configureServer(server); server.start(); } catch (final Exception ex) { ex.printStackTrace(); fail(ex.getMessage()); } }
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()}); context.addBean(new NoListenerConfiguration(context)); server.setHandler(context);