Search in sources :

Example 1 with Builder

use of org.glassfish.internal.embedded.ScatteredArchive.Builder in project Payara by payara.

the class EmbeddedTest method setup.

@BeforeClass
public static void setup() {
    Server.Builder builder = new Server.Builder("build");
    server = builder.build();
    NetworkConfig nc = server.getHabitat().getService(NetworkConfig.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
    List<NetworkListener> listeners = nc.getNetworkListeners().getNetworkListener();
    System.out.println("Network listener size before creation " + listeners.size());
    for (NetworkListener nl : listeners) {
        System.out.println("Network listener " + nl.getPort());
    }
    try {
        http = server.createPort(8080);
        ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
        server.addContainer(b);
        EmbeddedWebContainer embedded = (EmbeddedWebContainer) b.create(server);
        embedded.bind(http, "http");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    listeners = nc.getNetworkListeners().getNetworkListener();
    System.out.println("Network listener size after creation " + listeners.size());
    Assert.assertTrue(listeners.size() == 1);
    for (NetworkListener nl : listeners) {
        System.out.println("Network listener " + nl.getPort());
    }
    Collection<NetworkListener> cnl = server.getHabitat().getAllServices(NetworkListener.class);
    System.out.println("Network listener size after creation " + cnl.size());
    for (NetworkListener nl : cnl) {
        System.out.println("Network listener " + nl.getPort());
    }
    server.addContainer(ContainerBuilder.Type.all);
}
Also used : ContainerBuilder(org.glassfish.internal.embedded.ContainerBuilder) Server(org.glassfish.internal.embedded.Server) EmbeddedWebContainer(org.glassfish.api.embedded.web.EmbeddedWebContainer) ContainerBuilder(org.glassfish.internal.embedded.ContainerBuilder) Builder(org.glassfish.internal.embedded.ScatteredArchive.Builder) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) IOException(java.io.IOException) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener) BeforeClass(org.junit.BeforeClass)

Aggregations

IOException (java.io.IOException)1 EmbeddedWebContainer (org.glassfish.api.embedded.web.EmbeddedWebContainer)1 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)1 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)1 ContainerBuilder (org.glassfish.internal.embedded.ContainerBuilder)1 Builder (org.glassfish.internal.embedded.ScatteredArchive.Builder)1 Server (org.glassfish.internal.embedded.Server)1 BeforeClass (org.junit.BeforeClass)1