Java Code Examples for org.wildfly.swarm.container.Container#deploy()

The following examples show how to use org.wildfly.swarm.container.Container#deploy() . 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: App.java    From drools-workshop with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Container container = new Container();

    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.as(TopologyArchive.class).advertise("restaurantService");
    deployment.setContextRoot("/api");
    deployment.addPackages(true, "org.jboss.shrinkwrap.api");
    deployment.addAsLibrary(container.createDefaultDeployment());
    deployment.addAllDependencies();
    container.start();
    container.deploy(deployment);

    Topology lookup = Topology.lookup();
    lookup.addListener(new TopologyListener() {
        @Override
        public void onChange(Topology tplg) {
            System.out.println(">>> Delivery Service: The Topology Has Changed!");
            printTopology(lookup);
        }
    });
    
    printTopology(lookup);

}
 
Example 2
Source File: App.java    From drools-workshop with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Container container = new Container();

    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.as(TopologyArchive.class).advertise("deliveryService");
    deployment.setContextRoot("/api");
    deployment.addPackages(true, "org.jboss.shrinkwrap.api");
    deployment.addAsLibrary(container.createDefaultDeployment());
    deployment.addAllDependencies();
    container.start();
    container.deploy(deployment);
    
    Topology lookup = Topology.lookup();
    lookup.addListener(new TopologyListener() {
        @Override
        public void onChange(Topology tplg) {
            System.out.println(">>> Delivery Service: The Topology Has Changed!");
            printTopology(lookup);
        }
    });
    
    printTopology(lookup);
    
}
 
Example 3
Source File: App.java    From drools-workshop with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Container container = new Container();

    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.as(TopologyArchive.class).advertise("foodService");
    deployment.setContextRoot("/api");
    deployment.addPackages(true, "org.jboss.shrinkwrap.api");
    deployment.addAsLibrary(container.createDefaultDeployment());
    deployment.addAllDependencies();
    container.start();
    container.deploy(deployment);
    
    Topology lookup = Topology.lookup();
    lookup.addListener(new TopologyListener() {
        @Override
        public void onChange(Topology tplg) {
            System.out.println(">>> Delivery Service: The Topology Has Changed!");
            printTopology(lookup);
        }
    });
    
    printTopology(lookup);
    
}
 
Example 4
Source File: App.java    From drools-workshop with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Container container = new Container();

    container.start();

    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.setContextRoot("/api");
    deployment.addResource(ShoppingCartService.class);
    deployment.addResource(ShoppingCartServiceImpl.class);
    deployment.addClass(HttpStatusExceptionHandler.class);
    deployment.addClass(BusinessException.class);
    deployment.addAllDependencies();
    container.deploy(deployment);
}
 
Example 5
Source File: App.java    From drools-workshop with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Container container = new Container();

    container.start();

    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.setContextRoot("/cep");
    deployment.addResource(TransactionEventService.class);
    deployment.addResource(TransactionEventServiceImpl.class);
    deployment.addClass(HttpStatusExceptionHandler.class);
    deployment.addClass(BusinessException.class);
    deployment.addAllDependencies();
    container.deploy(deployment);
}
 
Example 6
Source File: StaticContentDeploymentTest.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticContent() throws Exception {
    Container container = newContainer();
    container.start();
    try {
        WARArchive deployment = ShrinkWrap.create(WARArchive.class);
        deployment.staticContent();
        container.deploy(deployment);
        assertBasicStaticContentWorks("");
        assertFileChangesReflected("");
    } finally {
        container.stop();
    }
}
 
Example 7
Source File: StaticContentDeploymentTest.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticContentWithContext() throws Exception {
    Container container = newContainer();
    container.start();
    try {
        WARArchive deployment = ShrinkWrap.create(WARArchive.class);
        deployment.setContextRoot("/static");
        deployment.staticContent();
        container.deploy(deployment);
        assertBasicStaticContentWorks("static");
        assertFileChangesReflected("static");
    } finally {
        container.stop();
    }
}
 
Example 8
Source File: StaticContentDeploymentTest.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticContentWithBase() throws Exception {
    Container container = newContainer();
    container.start();
    try {
        WARArchive deployment = ShrinkWrap.create(WARArchive.class);
        deployment.staticContent("foo");
        container.deploy(deployment);
        assertContains("", "This is foo/index.html.");
        assertContains("index.html", "This is foo/index.html.");
    } finally {
        container.stop();
    }
}
 
Example 9
Source File: Main.java    From wildfly-samples with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
        Container container = new Container();
        container.start();

        // Create a JDBC driver deployment using maven groupId:artifactId
        // The version is resolved from your pom.xml's <dependency>
        DriverDeployment driverDeployment = new DriverDeployment(container, "com.h2database:h2", "h2");
        container.deploy(driverDeployment);

        // Create a DS deployment
        DatasourceDeployment dsDeployment = new DatasourceDeployment(container, new Datasource("ExampleDS")
                .connectionURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
                .driver("h2")
                .authentication("sa", "sa")
        );
        container.deploy(dsDeployment);

        WarDeployment deployment = new DefaultWarDeployment(container);
        deployment.getArchive().addClass(Employee.class);
        deployment.getArchive().addClass(MyApplication.class);
        deployment.getArchive().addClass(MyResource.class);
//        deployment.getArchive().addPackage(Main.class.getPackage());
//        deployment.getArchive()
//                .addAsResource("META-INF/persistence.xml")
//                .addAsResource("META-INF/load.sql");
        deployment.getArchive().addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", Main.class.getClassLoader()), "classes/META-INF/persistence.xml");
        deployment.getArchive().addAsWebInfResource(new ClassLoaderAsset("META-INF/load.sql", Main.class.getClassLoader()), "classes/META-INF/load.sql");

        container.deploy(deployment);
    }
 
Example 10
Source File: Swarm.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
public static void simpleMain(String... args) throws Exception {
    Container container = new Container().start();
    container.deploy();
}
 
Example 11
Source File: Swarm.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
public static void factoryMain(ContainerFactory factory, String... args) throws Exception {
    Container container = factory.newContainer(args).start();
    container.deploy();
}