Brooklyn

brooklyn.entity.basic
[Java] Class ApplicationBuilder

java.lang.Object
  brooklyn.entity.basic.ApplicationBuilder

@Beta
public abstract class ApplicationBuilder

Experimental mechanism for defining/building applications. In future releases, this API will change. Its concepts will most likely be merged with a TOSCA implementation and with 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(EntitySpecs.spec(MySqlNode.class))); JBoss7Server as = addChild(EntitySpecs.spec(JBoss7Server.class) .configure(HTTP_PORT, "8080+") .configure(javaSysProp("brooklyn.example.db.url"), attributeWhenReady(db, MySqlNode.MYSQL_URL)); } }.manage();
Authors:
aled


Field Summary
protected java.util.concurrent.atomic.AtomicBoolean inManage

protected boolean managed

 
Constructor Summary
ApplicationBuilder()

ApplicationBuilder(EntitySpec appSpec)

 
Method Summary
protected java.lang.Object addChild(java.lang.Object entity)

Adds the given entity as a child of the application being built.

protected java.lang.Object addChild(EntitySpec spec)

Adds the given entity as a child of the application being built.

protected java.lang.Object addChild(java.util.Map config, java.lang.Class type)

ApplicationBuilder appDisplayName(java.lang.String val)

protected void checkDuringManage()

protected void checkNotManaged()

protected void checkPreManage()

ApplicationBuilder configure(java.util.Map config)

Configures the application instance.

protected java.lang.Object createChild(EntitySpec spec)

@deprecated since 0.5.0-rc.1 (added in 0.5.0-M2); use addChild(EntitySpec), for consistency with AbstractEntity#addChild(EntitySpec)#addChild(EntitySpec).

protected java.lang.Object createChild(java.util.Map config, java.lang.Class type)

@deprecated since 0.5.0-rc.1 (added in 0.5.0-M2); use addChild(Map, Class)

protected java.lang.Object createEntity(EntitySpec spec)

protected void doBuild()

For overriding, to create and wire together entities.

protected StartableApplication getApp()

protected ManagementContext getManagementContext()

java.lang.Class 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 BasicEntitySpec newAppSpec(java.lang.Class type)

@deprecated since 0.5.0-rc.1 (added in 0.5.0-M2)

static java.lang.Object newManagedApp(java.lang.Class type)

static java.lang.Object newManagedApp(EntitySpec spec)

static java.lang.Object newManagedApp(java.lang.Class type, ManagementContext managementContext)

static java.lang.Object newManagedApp(EntitySpec spec, ManagementContext managementContext)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

inManage

protected final java.util.concurrent.atomic.AtomicBoolean inManage


managed

protected boolean managed


 
Constructor Detail

ApplicationBuilder

public ApplicationBuilder()


ApplicationBuilder

public ApplicationBuilder(EntitySpec appSpec)


 
Method Detail

addChild

protected final java.lang.Object addChild(java.lang.Object entity)
Adds the given entity as a child of the application being built. To be called during doBuild().


addChild

protected final java.lang.Object addChild(EntitySpec spec)
Adds the given entity as a child of the application being built.


addChild

protected final java.lang.Object addChild(java.util.Map config, java.lang.Class type)


appDisplayName

public final ApplicationBuilder appDisplayName(java.lang.String val)


checkDuringManage

protected void checkDuringManage()


checkNotManaged

protected void checkNotManaged()


checkPreManage

protected void checkPreManage()


configure

public final ApplicationBuilder configure(java.util.Map config)
Configures the application instance.


createChild

protected final java.lang.Object createChild(EntitySpec spec)
deprecated:
since 0.5.0-rc.1 (added in 0.5.0-M2); use addChild(EntitySpec), for consistency with AbstractEntity#addChild(EntitySpec)#addChild(EntitySpec).


createChild

protected final java.lang.Object createChild(java.util.Map config, java.lang.Class type)
deprecated:
since 0.5.0-rc.1 (added in 0.5.0-M2); use addChild(Map, Class)


createEntity

protected final java.lang.Object createEntity(EntitySpec spec)


doBuild

protected void doBuild()
For overriding, to create and wire together entities.


getApp

protected final StartableApplication getApp()


getManagementContext

protected final ManagementContext getManagementContext()


getType

public final java.lang.Class getType()
Returns the type of the application being built.


manage

public final StartableApplication manage()
Creates a new ManagementContext, and then builds and manages the application.
See Also:
manage(ManagementContext)


manage

public final StartableApplication manage(ManagementContext managementContext)
Builds and manages the application, calling the user's doBuild() method.
throws:
IllegalStateException If already managed, or if called during doBuild(), or if multiple concurrent calls


newAppSpec

public static BasicEntitySpec newAppSpec(java.lang.Class type)
deprecated:
since 0.5.0-rc.1 (added in 0.5.0-M2)


newManagedApp

@SuppressWarnings("unchecked")
@Beta
public static java.lang.Object newManagedApp(java.lang.Class type)


newManagedApp

@SuppressWarnings("unchecked")
@Beta
public static java.lang.Object newManagedApp(EntitySpec spec)


newManagedApp

@SuppressWarnings("unchecked")
@Beta
public static java.lang.Object newManagedApp(java.lang.Class type, ManagementContext managementContext)


newManagedApp

@SuppressWarnings("unchecked")
@Beta
public static java.lang.Object newManagedApp(EntitySpec spec, ManagementContext managementContext)


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.