brooklyn.entity.proxying
Class EntitySpec<T extends Entity>

java.lang.Object
  extended by brooklyn.entity.proxying.EntitySpec<T>
Type Parameters:
T - The type of entity to be created
All Implemented Interfaces:
Serializable

public class EntitySpec<T extends Entity>
extends Object
implements Serializable

Gives details of an entity to be created. It describes the entity's configuration, and is reusable to create multiple entities with the same configuration. To create an EntitySpec, it is strongly encouraged to use create(Class) etc. Users who need to implement this are strongly encouraged to extend EntitySpec.

See Also:
Serialized Form

Constructor Summary
EntitySpec(Class<T> type)
           
 
Method Summary
 EntitySpec<T> addInitializer(Class<? extends EntityInitializer> initializerType)
          The supplied class must have a public no-arg constructor.
 EntitySpec<T> addInitializer(EntityInitializer initializer)
           
 EntitySpec<T> addInitializers(Collection<EntityInitializer> initializer)
           
 EntitySpec<T> additionalInterfaces(Class<?>... vals)
           
 EntitySpec<T> additionalInterfaces(Iterable<Class<?>> val)
           
 EntitySpec<T> configure(CharSequence key, Object val)
           
<V> EntitySpec<T>
configure(brooklyn.config.ConfigKey.HasConfigKey<V> key, Task<? extends V> val)
           
<V> EntitySpec<T>
configure(brooklyn.config.ConfigKey.HasConfigKey<V> key, V val)
           
<V> EntitySpec<T>
configure(brooklyn.config.ConfigKey<V> key, Task<? extends V> val)
           
<V> EntitySpec<T>
configure(brooklyn.config.ConfigKey<V> key, V val)
           
 EntitySpec<T> configure(Map<?,?> val)
           
static
<T extends Entity>
EntitySpec<T>
create(Class<T> type)
          Creates a new EntitySpec instance for an entity of the given type.
static
<T extends Entity,U extends T>
EntitySpec<T>
create(Class<T> type, Class<U> implType)
          Creates a new EntitySpec instance for an entity of the given type.
static
<T extends Entity>
EntitySpec<T>
create(EntitySpec<T> spec)
          Wraps an entity spec so its configuration can be overridden without modifying the original entity spec.
static
<T extends Entity>
EntitySpec<T>
create(Map<?,?> config, Class<T> type)
          Creates a new EntitySpec instance with the given config, for an entity of the given type.
 EntitySpec<T> displayName(String val)
           
<V> EntitySpec<T>
enricher(Enricher val)
          adds a policy to the spec
<V> EntitySpec<T>
enricher(EnricherSpec<?> val)
          adds a policy to the spec
<V> EntitySpec<T>
enrichers(Iterable<? extends Enricher> val)
          adds the supplied policies to the spec
<V> EntitySpec<T>
enricherSpecs(Iterable<? extends EnricherSpec<?>> val)
          adds the supplied policies to the spec
 Set<Class<?>> getAdditionalInterfaces()
           
 Map<brooklyn.config.ConfigKey<?>,Object> getConfig()
           
 String getDisplayName()
           
 List<Enricher> getEnrichers()
           
 List<EnricherSpec<?>> getEnricherSpecs()
           
 Map<String,?> getFlags()
           
 Class<? extends T> getImplementation()
           
 List<EntityInitializer> getInitializers()
           
 Entity getParent()
           
 List<Policy> getPolicies()
           
 List<PolicySpec<?>> getPolicySpecs()
           
 Class<T> getType()
           
 EntitySpec<T> immutable()
          "seals" this spec, preventing any future changes
 EntitySpec<T> impl(Class<? extends T> val)
           
static
<T extends Entity>
EntitySpec<T>
newInstance(Class<T> type)
           
 EntitySpec<T> parent(Entity val)
           
<V> EntitySpec<T>
policies(Iterable<? extends Policy> val)
          adds the supplied policies to the spec
<V> EntitySpec<T>
policy(Policy val)
          adds a policy to the spec
<V> EntitySpec<T>
policy(PolicySpec<?> val)
          adds a policy to the spec
<V> EntitySpec<T>
policySpecs(Iterable<? extends PolicySpec<?>> val)
          adds the supplied policies to the spec
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntitySpec

public EntitySpec(Class<T> type)
Method Detail

create

public static <T extends Entity> EntitySpec<T> create(Class<T> type)
Creates a new EntitySpec instance for an entity of the given type. The returned EntitySpec can then be customized.

Parameters:
type - An Entity interface

create

public static <T extends Entity,U extends T> EntitySpec<T> create(Class<T> type,
                                                                  Class<U> implType)
Creates a new EntitySpec instance for an entity of the given type. The returned EntitySpec can then be customized.

Parameters:
type - An Entity interface
implType - An Entity implementation, which implements the type interface

create

public static <T extends Entity> EntitySpec<T> create(Map<?,?> config,
                                                      Class<T> type)
Creates a new EntitySpec instance with the given config, for an entity of the given type. This is primarily for groovy code; equivalent to EntitySpec.create(type).configure(config).

Parameters:
config - The spec's configuration (see configure(Map)).
type - An Entity interface

create

public static <T extends Entity> EntitySpec<T> create(EntitySpec<T> spec)
Wraps an entity spec so its configuration can be overridden without modifying the original entity spec.


newInstance

public static <T extends Entity> EntitySpec<T> newInstance(Class<T> type)

getType

public Class<T> getType()
Returns:
The type of the entity

getDisplayName

public String getDisplayName()
Returns:
The display name of the entity

getImplementation

@Nullable
public Class<? extends T> getImplementation()
Returns:
The implementation of the entity; if not null. this overrides any defaults or other configuration
See Also:
on the entity interface classes for how defaults are defined., for how implementations can be defined globally

getAdditionalInterfaces

public Set<Class<?>> getAdditionalInterfaces()
Returns:
Additional interfaces (other than just getType()) that this entity implements; important for when accessing entity through a proxy to determine which interfaces the proxy exposes.

getInitializers

public List<EntityInitializer> getInitializers()
Returns:
EntityInitializer objects which customize the entity to be created

getParent

public Entity getParent()
Returns:
The entity's parent

getFlags

public Map<String,?> getFlags()
Returns:
Read-only construction flags
See Also:
declarations on the entity type

getConfig

public Map<brooklyn.config.ConfigKey<?>,Object> getConfig()
Returns:
Read-only configuration values

getPolicySpecs

public List<PolicySpec<?>> getPolicySpecs()

getPolicies

public List<Policy> getPolicies()

getEnricherSpecs

public List<EnricherSpec<?>> getEnricherSpecs()

getEnrichers

public List<Enricher> getEnrichers()

displayName

public EntitySpec<T> displayName(String val)

impl

public EntitySpec<T> impl(Class<? extends T> val)

additionalInterfaces

public EntitySpec<T> additionalInterfaces(Class<?>... vals)

additionalInterfaces

public EntitySpec<T> additionalInterfaces(Iterable<Class<?>> val)

addInitializer

public EntitySpec<T> addInitializer(EntityInitializer initializer)

addInitializers

public EntitySpec<T> addInitializers(Collection<EntityInitializer> initializer)

addInitializer

public EntitySpec<T> addInitializer(Class<? extends EntityInitializer> initializerType)
The supplied class must have a public no-arg constructor.


parent

public EntitySpec<T> parent(Entity val)

configure

public EntitySpec<T> configure(Map<?,?> val)

configure

public EntitySpec<T> configure(CharSequence key,
                               Object val)

configure

public <V> EntitySpec<T> configure(brooklyn.config.ConfigKey<V> key,
                                   V val)

configure

public <V> EntitySpec<T> configure(brooklyn.config.ConfigKey<V> key,
                                   Task<? extends V> val)

configure

public <V> EntitySpec<T> configure(brooklyn.config.ConfigKey.HasConfigKey<V> key,
                                   V val)

configure

public <V> EntitySpec<T> configure(brooklyn.config.ConfigKey.HasConfigKey<V> key,
                                   Task<? extends V> val)

policy

public <V> EntitySpec<T> policy(Policy val)
adds a policy to the spec


policy

public <V> EntitySpec<T> policy(PolicySpec<?> val)
adds a policy to the spec


policySpecs

public <V> EntitySpec<T> policySpecs(Iterable<? extends PolicySpec<?>> val)
adds the supplied policies to the spec


policies

public <V> EntitySpec<T> policies(Iterable<? extends Policy> val)
adds the supplied policies to the spec


enricher

public <V> EntitySpec<T> enricher(Enricher val)
adds a policy to the spec


enricher

public <V> EntitySpec<T> enricher(EnricherSpec<?> val)
adds a policy to the spec


enricherSpecs

public <V> EntitySpec<T> enricherSpecs(Iterable<? extends EnricherSpec<?>> val)
adds the supplied policies to the spec


enrichers

public <V> EntitySpec<T> enrichers(Iterable<? extends Enricher> val)
adds the supplied policies to the spec


immutable

public EntitySpec<T> immutable()
"seals" this spec, preventing any future changes


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.