Search in sources :

Example 1 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFromProperties.

@Test
public void testFromProperties() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty(ServerBuilder.WEB_SERVER_PORT_CFG_KEY, String.valueOf(portForServer));
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 2 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFromXml.

@Test
public void testFromXml() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    String xmlFile = BaseCase.PROPERTIES.getProperty(JETTY_MGMT_XML);
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty("jetty.http.port", String.valueOf(portForServer));
        jettyConfig.setProperty(ServerBuilder.WEB_SERVER_CONFIG_FILE_NAME_CGF_KEY, xmlFile);
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 3 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class JettyMgmtComponentTest method testFromProperties_withWebappurl.

@Test
public void testFromProperties_withWebappurl() throws Exception {
    JettyServerComponent jetty = new JettyServerComponent();
    int portForServer = PortManager.nextUnusedPort(18080);
    try {
        Properties jettyConfig = new Properties();
        jettyConfig.setProperty(ServerBuilder.WEB_SERVER_PORT_CFG_KEY, String.valueOf(portForServer));
        jettyConfig.setProperty(ServerBuilder.WEB_SERVER_WEBAPP_URL_CFG_KEY, "./webapps");
        jetty.init(jettyConfig);
        jetty.start();
        Thread.sleep(250);
        final JettyServerManager mgr = JettyServerManager.getInstance();
        Awaitility.await().atMost(MAX_STARTUP_WAIT).with().pollInterval(STARTUP_POLL).until(() -> mgr.isStarted());
    } finally {
        stopAndDestroy(jetty);
        PortManager.release(portForServer);
    }
}
Also used : Properties(java.util.Properties) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager) Test(org.junit.Test)

Example 4 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class EmbeddedConnection method removeServlet.

@Override
public void removeServlet(ServletWrapper wrapper) throws CoreException {
    try {
        JettyServerManager serverManager = JettyServerManager.getInstance();
        serverManager.stopDeployment(SERVER_ID, wrapper.getUrl());
        serverManager.removeDeployment(SERVER_ID, wrapper.getUrl());
        serverManager.removeDeployment(SERVER_ID, wrapper.getServletHolder(), wrapper.getUrl());
        log.trace("Removed {} from {}", wrapper.getServletHolder(), wrapper.getUrl());
    } catch (Exception ex) {
        throw ExceptionHelper.wrapCoreException(ex);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager)

Example 5 with JettyServerManager

use of com.adaptris.core.management.webserver.JettyServerManager in project interlok by adaptris.

the class EmbeddedConnection method addServlet.

@Override
public void addServlet(ServletWrapper wrapper) throws CoreException {
    try {
        JettyServerManager serverManager = JettyServerManager.getInstance();
        HashMap<String, Object> additionalProperties = new HashMap<String, Object>();
        additionalProperties.put(JettyServerManager.CONTEXT_PATH, wrapper.getUrl());
        additionalProperties.put(JettyServerManager.SECURITY_CONSTRAINTS, getSecurityHandler());
        serverManager.addServlet(SERVER_ID, wrapper.getServletHolder(), additionalProperties);
        serverManager.startDeployment(SERVER_ID, wrapper.getUrl());
        log.trace("Added " + wrapper.getServletHolder() + " against " + wrapper.getUrl());
    } catch (Exception ex) {
        throw ExceptionHelper.wrapCoreException(ex);
    }
}
Also used : HashMap(java.util.HashMap) CoreException(com.adaptris.core.CoreException) JettyServerManager(com.adaptris.core.management.webserver.JettyServerManager)

Aggregations

JettyServerManager (com.adaptris.core.management.webserver.JettyServerManager)9 Properties (java.util.Properties)6 Test (org.junit.Test)6 CoreException (com.adaptris.core.CoreException)2 JettyServerComponent (com.adaptris.core.management.jetty.JettyServerComponent)1 HashMap (java.util.HashMap)1