Search in sources :

Example 1 with IJettyConfiguration

use of org.teknux.jettybootstrap.configuration.IJettyConfiguration in project jetty-bootstrap by teknux-org.

the class JettyBootstrap method startServer.

/**
 * Starts the Jetty Server and join the calling thread.
 *
 * @param join
 *            <code>true</code> to block the calling thread until the server stops. <code>false</code> otherwise
 * @return this instance
 * @throws JettyBootstrapException
 *             if an exception occurs during the initialization
 */
public JettyBootstrap startServer(Boolean join) throws JettyBootstrapException {
    LOG.info("Starting Server...");
    IJettyConfiguration iJettyConfiguration = getInitializedConfiguration();
    initServer(iJettyConfiguration);
    try {
        server.start();
    } catch (Exception e) {
        throw new JettyBootstrapException(e);
    }
    // display server addresses
    if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTP)) {
        LOG.info("http://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getPort());
    }
    if (iJettyConfiguration.getJettyConnectors().contains(JettyConnector.HTTPS)) {
        LOG.info("https://{}:{}", iJettyConfiguration.getHost(), iJettyConfiguration.getSslPort());
    }
    if ((join != null && join) || (join == null && iJettyConfiguration.isAutoJoinOnStart())) {
        joinServer();
    }
    return this;
}
Also used : IJettyConfiguration(org.teknux.jettybootstrap.configuration.IJettyConfiguration) JettyKeystoreException(org.teknux.jettybootstrap.keystore.JettyKeystoreException) IOException(java.io.IOException)

Example 2 with IJettyConfiguration

use of org.teknux.jettybootstrap.configuration.IJettyConfiguration in project jetty-bootstrap by teknux-org.

the class JettyConfigurationTest method cloneTest.

@Test
public void cloneTest() throws CloneNotSupportedException {
    JettyConfiguration jettyConfiguration = new JettyConfiguration();
    jettyConfiguration.setAutoJoinOnStart(true);
    jettyConfiguration.setHost("0.0.0.0");
    jettyConfiguration.setJettyConnectors(JettyConnector.HTTPS);
    IJettyConfiguration iJettyConfigurationCloned = jettyConfiguration.clone();
    jettyConfiguration.setAutoJoinOnStart(false);
    jettyConfiguration.setHost("127.0.0.1");
    jettyConfiguration.setJettyConnectors(JettyConnector.HTTP);
    Assert.assertEquals(false, jettyConfiguration.isAutoJoinOnStart());
    Assert.assertEquals("127.0.0.1", jettyConfiguration.getHost());
    Set<JettyConnector> expectedJettyConnectors = new HashSet<>();
    expectedJettyConnectors.add(JettyConnector.HTTP);
    Assert.assertEquals(expectedJettyConnectors, jettyConfiguration.getJettyConnectors());
    Assert.assertEquals(true, iJettyConfigurationCloned.isAutoJoinOnStart());
    Assert.assertEquals("0.0.0.0", iJettyConfigurationCloned.getHost());
    Set<JettyConnector> expectedJettyConnectorsCloned = new HashSet<>();
    expectedJettyConnectorsCloned.add(JettyConnector.HTTPS);
    Assert.assertEquals(expectedJettyConnectorsCloned, iJettyConfigurationCloned.getJettyConnectors());
}
Also used : IJettyConfiguration(org.teknux.jettybootstrap.configuration.IJettyConfiguration) JettyConfiguration(org.teknux.jettybootstrap.configuration.JettyConfiguration) IJettyConfiguration(org.teknux.jettybootstrap.configuration.IJettyConfiguration) JettyConnector(org.teknux.jettybootstrap.configuration.JettyConnector) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

IJettyConfiguration (org.teknux.jettybootstrap.configuration.IJettyConfiguration)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 JettyConfiguration (org.teknux.jettybootstrap.configuration.JettyConfiguration)1 JettyConnector (org.teknux.jettybootstrap.configuration.JettyConnector)1 JettyKeystoreException (org.teknux.jettybootstrap.keystore.JettyKeystoreException)1