org.eclipse.jetty.deploy.DeploymentManager Java Examples

The following examples show how to use org.eclipse.jetty.deploy.DeploymentManager. 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: AbstractJettyAppServerTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testDetectingSAML() throws Exception {
    // given
    URL webXml = AbstractJettyAppServerTest.class.getResource("/web-saml.xml");
    WebArchive archive = ShrinkWrap.create(WebArchive.class,"archive.war")
            .addAsWebInfResource(webXml, "web.xml");

    JettyAppServer server = new JettyAppServer();

    // when
    Authenticator installedAuthenticator = null;
    try {
        server.start();
        server.deploy(archive);

        installedAuthenticator = server.getServer()
                .getBean(DeploymentManager.class).getApps().iterator().next()
                .getContextHandler().getChildHandlerByClass(SecurityHandler.class).getAuthenticator();
    } finally {
        server.stop();
    }

    // assert
    Assert.assertTrue(installedAuthenticator instanceof KeycloakSamlAuthenticator);
}
 
Example #2
Source File: AbstractJettyAppServerTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testDetectingOIDC() throws Exception {
    // given
    URL webXml = AbstractJettyAppServerTest.class.getResource("/web-oidc.xml");
    WebArchive archive = ShrinkWrap.create(WebArchive.class,"archive.war")
            .addAsWebInfResource(webXml, "web.xml");

    JettyAppServer server = new JettyAppServer();

    // when
    Authenticator installedAuthenticator = null;
    try {
        server.start();
        server.deploy(archive);

        installedAuthenticator = server.getServer()
                .getBean(DeploymentManager.class).getApps().iterator().next()
                .getContextHandler().getChildHandlerByClass(SecurityHandler.class).getAuthenticator();
    } finally {
        server.stop();
    }

    // assert
    Assert.assertTrue(installedAuthenticator instanceof KeycloakJettyAuthenticator);
}
 
Example #3
Source File: Main.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private static boolean test() {
	try {
		DeploymentManager deployer = Servers.applicationServer.getBean(DeploymentManager.class);
		for (App app : deployer.getApps()) {
			System.out.println(app.getContextPath());
			if (StringUtils.equals("/x_query_assemble_designer", app.getContextPath())) {
				app.getContextHandler().stop();
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return true;
}
 
Example #4
Source File: JettyServer.java    From nifi with Apache License 2.0 4 votes vote down vote up
public JettyServer(final NiFiProperties props, final Set<Bundle> bundles) {
    final QueuedThreadPool threadPool = new QueuedThreadPool(props.getWebThreads());
    threadPool.setName("NiFi Web Server");

    // create the server
    this.server = new Server(threadPool);
    this.props = props;

    // enable the annotation based configuration to ensure the jsp container is initialized properly
    final Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());

    // configure server
    configureConnectors(server);

    // load wars from the bundle
    final Handler warHandlers = loadInitialWars(bundles);

    final HandlerList allHandlers = new HandlerList();

    // Only restrict the host header if running in HTTPS mode
    if (props.isHTTPSConfigured()) {
        // Create a handler for the host header and add it to the server
        HostHeaderHandler hostHeaderHandler = new HostHeaderHandler(props);
        logger.info("Created HostHeaderHandler [" + hostHeaderHandler.toString() + "]");

        // Add this before the WAR handlers
        allHandlers.addHandler(hostHeaderHandler);
    } else {
        logger.info("Running in HTTP mode; host headers not restricted");
    }


    final ContextHandlerCollection contextHandlers = new ContextHandlerCollection();
    contextHandlers.addHandler(warHandlers);
    allHandlers.addHandler(contextHandlers);
    server.setHandler(allHandlers);

    deploymentManager = new DeploymentManager();
    deploymentManager.setContextAttribute(CONTAINER_INCLUDE_PATTERN_KEY, CONTAINER_INCLUDE_PATTERN_VALUE);
    deploymentManager.setContexts(contextHandlers);
    server.addBean(deploymentManager);
}
 
Example #5
Source File: Jetty9Server.java    From gocd with Apache License 2.0 4 votes vote down vote up
public Jetty9Server(SystemEnvironment systemEnvironment, String password) {
    this(systemEnvironment, password, new Server(), new DeploymentManager());
}
 
Example #6
Source File: Jetty9Server.java    From gocd with Apache License 2.0 4 votes vote down vote up
Jetty9Server(SystemEnvironment systemEnvironment, String password, Server server, DeploymentManager deploymentManager) {
    super(systemEnvironment, password);
    systemEnvironment.set(SystemEnvironment.JETTY_XML_FILE_NAME, JETTY_XML);
    this.server = server;
    this.deploymentManager = deploymentManager;
}