@Beta
public abstract class ApplicationBuilder
extends java.lang.Object
EntitySpec
.
For building an application. Users can sub-class and override doBuild(), putting the logic for
creating and wiring together entities in there.
The builder is mutable; a given instance should be used to build only a single application.
Once manage()
has been called, the application will be built and no additional configuration
should be performed through this builder.
Example (simplified) code for sub-classing is:
app = new ApplicationBuilder() {
//@Override
public void doBuild() {
MySqlNode db = addChild(EntitySpec.create(MySqlNode.class)));
JBoss7Server as = addChild(EntitySpec.create(JBoss7Server.class)
.configure(HTTP_PORT, "8080+")
.configure(javaSysProp("brooklyn.example.db.url"), attributeWhenReady(db, MySqlNode.MYSQL_URL));
}
}.manage();
Constructor and Description |
---|
ApplicationBuilder() |
ApplicationBuilder(EntitySpec<? extends StartableApplication> appSpec) |
Modifier and Type | Method and Description |
---|---|
ApplicationBuilder |
appDisplayName(java.lang.String val) |
ApplicationBuilder |
configure(java.util.Map<?,?> config)
Configures the application instance.
|
java.lang.Class<? extends StartableApplication> |
getType()
Returns the type of the application being built.
|
StartableApplication |
manage()
Creates a new
ManagementContext , and then builds and manages the application. |
StartableApplication |
manage(ManagementContext managementContext)
Builds and manages the application, calling the user's
doBuild() method. |
static <T extends StartableApplication> |
newManagedApp(java.lang.Class<T> type)
Deprecated.
|
static <T extends StartableApplication> |
newManagedApp(java.lang.Class<T> type,
ManagementContext managementContext) |
static <T extends StartableApplication> |
newManagedApp(EntitySpec<T> spec)
Deprecated.
|
static <T extends StartableApplication> |
newManagedApp(EntitySpec<T> spec,
ManagementContext managementContext) |
public ApplicationBuilder()
public ApplicationBuilder(EntitySpec<? extends StartableApplication> appSpec)
@Beta @Deprecated public static <T extends StartableApplication> T newManagedApp(java.lang.Class<T> type)
@Beta @Deprecated public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec)
@Beta public static <T extends StartableApplication> T newManagedApp(java.lang.Class<T> type, ManagementContext managementContext)
@Beta public static <T extends StartableApplication> T newManagedApp(EntitySpec<T> spec, ManagementContext managementContext)
public final ApplicationBuilder appDisplayName(java.lang.String val)
public final java.lang.Class<? extends StartableApplication> getType()
public final ApplicationBuilder configure(java.util.Map<?,?> config)
public final StartableApplication manage()
ManagementContext
, and then builds and manages the application.manage(ManagementContext)
public final StartableApplication manage(ManagementContext managementContext)
doBuild()
method.java.lang.IllegalStateException
- If already managed, or if called during doBuild()
, or if
multiple concurrent calls