Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Latest commit

 

History

History
49 lines (31 loc) · 1.92 KB

jar-applications.adoc

File metadata and controls

49 lines (31 loc) · 1.92 KB

JAR Packaging

If you desire to move away from traditionally-packaged .war applications, more options are available to you with WildFly Swarm. Though a fluent API, you can fully configure the facilities brought to your application and control what gets deployed.

Writing your own main(…​)

When your application is packaged as a .jar, you can also (but are not required) to provide your own main(…​) method. In your main(…​) you can configure the container as much or as little as you require. You can also .deploy(…​) one or more deployments.

The main(…​) method should exactly match the typical requirements of a main method in Java, and is executable from your IDE.

public class Main {

  public static void main(String...args) {
    ..
  }

}

Within the main method, you can work with the org.wildfly.swarm.Swarm API to configure fractions into the system and deploy components.

The primary methods on Swarm are:

Name Description

fraction(…​)

Add an explicitly-configured fraction

start(…​)

Start the configured container

deploy(…​)

Deploy a ShrinkWrap archive

Default Configuration

When you add dependencies to your project, they automatically activate the related fraction. For instance, simply having the logging dependency adds the logging fraction to the container and initializes it.

You only need to call .fraction(new LoggingFraction()) if you want to change the configuration to be different from the default. Any fraction that has been brought in through the dependency mechanism but has not been explicitly configured will be added with its default configuration.

Deployments

Once a container is created, one or more deployments may be created using ShrinkWrap and deployed into the container. Please see the chapter on ShrinkWrap for general details on how to create deployments.