org.eclipse.jetty.deploy.App Java Examples

The following examples show how to use org.eclipse.jetty.deploy.App. 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: JettyPlusIT.java    From uavstack with Apache License 2.0 6 votes vote down vote up
/**
 * onAppInit
 * 
 * @param args
 */
public void onAppInit(Object... args) {

    App sc = (App) args[0];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT);
    InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE);
    /**
     * NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for
     * PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object
     * 
     * for example, the DataSource related injection
     */
    ic.put(InterceptConstants.CONTEXTOBJ, sc);
    ic2.put(InterceptConstants.CONTEXTOBJ, sc);
}
 
Example #2
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 #3
Source File: Jetty9Server.java    From gocd with Apache License 2.0 5 votes vote down vote up
void startHandlers() {
    WebAppProvider webAppProvider = new WebAppProvider();

    deploymentManager.addApp(new App(deploymentManager, webAppProvider, "welcomeHandler", rootHandler()));

    if (systemEnvironment.useCompressedJs()) {
        AssetsContextHandler assetsContextHandler = new AssetsContextHandler(systemEnvironment);
        deploymentManager.addApp(new App(deploymentManager, webAppProvider, "assetsHandler", assetsContextHandler));
        webAppContext.addLifeCycleListener(new AssetsContextHandlerInitializer(assetsContextHandler, webAppContext));
    }

    deploymentManager.addApp(new App(deploymentManager, webAppProvider, "realApp", webAppContext));
}
 
Example #4
Source File: Jetty9ServerTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    initMocks(this);
    when(server.getThreadPool()).thenReturn(new QueuedThreadPool(1));
    Answer<Void> setHandlerMock = invocation -> {
        serverLevelHandler = (Handler) invocation.getArguments()[0];
        serverLevelHandler.setServer((Server) invocation.getMock());
        return null;
    };
    Mockito.doAnswer(setHandlerMock).when(server).setHandler(any(Handler.class));

    appCaptor = ArgumentCaptor.forClass(App.class);
    Mockito.doNothing().when(deploymentManager).addApp(appCaptor.capture());

    when(systemEnvironment.getServerPort()).thenReturn(1234);
    when(systemEnvironment.getWebappContextPath()).thenReturn("context");
    when(systemEnvironment.getCruiseWar()).thenReturn("cruise.war");
    when(systemEnvironment.getParentLoaderPriority()).thenReturn(true);
    when(systemEnvironment.useCompressedJs()).thenReturn(true);
    when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(1000);
    when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(2000);
    when(systemEnvironment.configDir()).thenReturn(configDir = temporaryFolder.newFolder());
    when(systemEnvironment.getJettyConfigFile()).thenReturn(new File("foo"));
    when(systemEnvironment.isSessionCookieSecure()).thenReturn(false);
    when(systemEnvironment.sessionTimeoutInSeconds()).thenReturn(1234);
    when(systemEnvironment.sessionCookieMaxAgeInSeconds()).thenReturn(5678);

    when(sslSocketFactory.getSupportedCipherSuites()).thenReturn(new String[]{});
    jetty9Server = new Jetty9Server(systemEnvironment, "pwd", server, deploymentManager);
    ReflectionUtil.setStaticField(Jetty9Server.class, "JETTY_XML_LOCATION_IN_JAR", "config");
}
 
Example #5
Source File: Jetty9ServerTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
private Map<Class<? extends ContextHandler>, ContextHandler> getLoadedHandlers() throws Exception {
    Map<Class<? extends ContextHandler>, ContextHandler> handlerTypeToHandler = new HashMap<>();
    for (App app : appCaptor.getAllValues()) {
        handlerTypeToHandler.put(app.getContextHandler().getClass(), app.getContextHandler());
    }
    return handlerTypeToHandler;
}
 
Example #6
Source File: JettyAppServer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void undeploy(Archive<?> archive) {
    log.info("Undeploying archive " + archive.getName());

    App app = deployedApps.get(archive.getId());
    if (app != null) {
        deployer.requestAppGoal(app, AppLifeCycle.UNDEPLOYED);
    } else {
        log.warnf("Deployment '%s' (name=%s) not found", archive.getId(), archive.getName());
    }
}