public class Swarm extends Object
main(...)
if an application does not provide one.
This simply constructs a default container, starts it and performs a default deployment. Typically only useful for barren WAR applications.
If providing their own main(...)
, then the following needs to be known:
java.util.logging
may only follow the initial constructor
of new Swarm()
.If using this class either directly or implicit as a main(...)
, certain
command-line facilities are available. If used directly, the user should pass the
String...args
from his own main(...)
to the constructor of this
class if these command-line facilities are desired.
Many internal aspects of the runtime container may be configured using the Java APIs for various fractions, XML configuration files, YAML configuration files, and Java system properties.
Configuration ordering works as follows: Fractions configured through an XML configuration file takes precedence over the same fraction configured through the Java API. YAML or system properties may override portions or attributes of fractions defined either way. A system property override binds more strongly than YAML configuration.
Modifier and Type | Field and Description |
---|---|
static String |
APPLICATION_MODULE_NAME |
static Swarm |
INSTANCE |
Constructor and Description |
---|
Swarm()
Construct a new, un-started container.
|
Swarm(boolean debugBootstrap)
Construct a new, un-started container.
|
Swarm(boolean debugBootstrap,
Properties properties,
Map<String,String> environment,
String... args) |
Swarm(boolean debug,
Properties properties,
String... args) |
Swarm(boolean debugBootstrap,
String... args)
Construct a new, un-started container, configured using command-line arguments.
|
Swarm(Properties properties,
Map<String,String> environment,
String... args) |
Swarm(Properties properties,
String... args) |
Swarm(String... args)
Construct a new, un-started container, configured using command-line arguments.
|
Modifier and Type | Method and Description |
---|---|
static List<JavaArchive> |
allArtifacts()
Retrieve all dependency artifacts for the user's project.
|
static JavaArchive |
artifact(String gav)
Retrieve an artifact that was part of the original build using a
full or simplified Maven GAV specifier.
|
static JavaArchive |
artifact(String gav,
String asName)
Retrieve an artifact that was part of the original build using a
full or simplified Maven GAV specifier, returning an archive with a
specified name.
|
Swarm |
component(Class<?> cls) |
ConfigView |
configView()
Retrieve the configuration view.
|
<any> |
createDefaultDeployment()
Retrieve the default ShrinkWrap deployment.
|
Swarm |
deploy()
Perform a default deployment.
|
Swarm |
deploy(<any> deployment)
Deploy an archive.
|
Swarm |
fraction(Fraction fraction)
Add a fraction to the container.
|
CommandLine |
getCommandLine()
Retrieve the parsed command-line from this instance.
|
static void |
main(String... args)
Main entry-point if a user does not specify a custom
main(...) -containing class. |
Swarm |
outboundSocketBinding(String socketBindingGroup,
OutboundSocketBinding binding)
Add an outbound socket-binding to the container.
|
void |
setArgs(String... args)
Pass the effective command-line arguments to this instance.
|
Swarm |
socketBinding(String socketBindingGroup,
SocketBinding binding)
Add an inbound socket-binding to the container.
|
StageConfig |
stageConfig()
Deprecated.
|
Swarm |
start()
Start the container.
|
Swarm |
start(<any> deployment)
Start the container with a deployment.
|
Swarm |
stop()
Stop the container, first undeploying all deployments.
|
static void |
stopMain() |
Swarm |
withConfig(URL url) |
Swarm |
withProfile(String name) |
Swarm |
withProperty(String name,
String value) |
Swarm |
withXmlConfig(URL url)
Specify an XML configuration file (in usual WildFly
standalone.xml ) format. |
public static Swarm INSTANCE
public static final String APPLICATION_MODULE_NAME
public Swarm() throws Exception
Exception
- If an error occurs performing classloading and initialization magic.public Swarm(boolean debugBootstrap) throws Exception
debugBootstrap
- - flag to indicate if the module layer should be put into bootstrap debug mode. Same as
the jboss-module -debuglog mode which enables trace logging to System.out during the
initial bootstrap of the module layer.Exception
- If an error occurs performing classloading and initialization magic.public Swarm(String... args) throws Exception
args
- The command-line arguments argumentsException
- If an error occurs performing classloading and initialization magic.public Swarm(boolean debugBootstrap, String... args) throws Exception
debugBootstrap
- - flag to indicate if the module layer should be put into bootstrap debug mode. Same as
the jboss-module -debuglog mode which enables trace logging to System.out during the
initial bootstrap of the module layer.args
- The command-line arguments argumentsException
- If an error occurs performing classloading and initialization magic.public Swarm(Properties properties, String... args) throws Exception
Exception
public Swarm(boolean debug, Properties properties, String... args) throws Exception
Exception
public Swarm(Properties properties, Map<String,String> environment, String... args) throws Exception
Exception
public CommandLine getCommandLine()
This method is only applicable if the String...args
was passed through
the constructor or setArgs(String...)
was called to provide the command-line
arguments.
public void setArgs(String... args)
args
- The arguments.public Swarm withXmlConfig(URL url)
standalone.xml
) format.
Usage of an XML configuration file is not exclusive with other configuration methods.
url
- The URL of the XML configuration file.withConfig(URL)
public Swarm withConfig(URL url) throws IOException
IOException
public Swarm fraction(Fraction fraction)
fraction
- The fraction to add.public Swarm outboundSocketBinding(String socketBindingGroup, OutboundSocketBinding binding)
In the event the specified socketBindingGroup
does not exist, the socket-binding
will be completely ignored.
socketBindingGroup
- The name of the socket-binding group to attach a binding to.binding
- The outbound socket-binding to add.public Swarm socketBinding(String socketBindingGroup, SocketBinding binding)
In the even the specified socketBindingGroup
does no exist, the socket-binding
will be completely ignored.
socketBindingGroup
- The name of the socket-binding group to attach a binding to.binding
- The inbound socket-binding to add.public Swarm start() throws Exception
This is a blocking call, which guarateens that when it returns without error, the container is fully started.
Exception
- if an error occurs.public Swarm start(<any> deployment) throws Exception
Effectively calls start().deploy(deployment)
public Swarm stop() throws Exception
Exception
- If an error occurs.public Swarm deploy() throws IllegalStateException, DeploymentException
For regular uberjars, it is effectively a short-cut for deploy(swarm.createDefaultDeployment())
,
deploying the baked-in deployment.
For hollow uberjars, it deploys whatever deployments were passed through the command-line, as none are baked-in.
DeploymentException
- if an error occurs.IllegalStateException
- if the container has not already been started.Swarm(String...)
,
setArgs(String...)
,
#deploy(Archive)
,
createDefaultDeployment()
public Swarm deploy(<any> deployment) throws Exception
deployment
- The ShrinkWrap archive to deploy.DeploymentException
- if an error occurs.Exception
public <any> createDefaultDeployment() throws Exception
Exception
public static void main(String... args) throws Exception
main(...)
-containing class.
The default behaviour of this main(...)
is to start the container entirely
with defaults and deploy the default deployment.
args
- The command-line arguments from the invocation.Exception
- if an error occurs.public static JavaArchive artifact(String gav) throws Exception
The following formats of GAVs are supported:
Only artifacts that were compiled with the user's project with
a scope of compile
are available through lookup.
In the variants that include a version
parameter, it may be
replaced by a literal asterisk in order to avoid hard-coding versions
into the application.
gav
- The Maven GAV.JavaArchive
.Exception
- If the specified artifact is not locatable.public static JavaArchive artifact(String gav, String asName) throws Exception
gav
- The Maven GAV.JavaArchive
with the specified name.Exception
- If the specified artifact is not locatable.artifact(String)
public static List<JavaArchive> allArtifacts() throws Exception
JavaArchive
objects.Exception
public ConfigView configView()
@Deprecated public StageConfig stageConfig()
ConfigView
through a deprecated interface.configView()
Copyright © 2019 JBoss by Red Hat. All rights reserved.