brooklyn.entity.proxying
Interface EntityTypeRegistry


public interface EntityTypeRegistry

A registry of the entity implementations to be used when creating an entity of a given type. A given implementation can only be associated with one entity type interface.


Method Summary
<T extends Entity>
Class<? super T>
getEntityTypeOf(Class<T> type)
          Returns the interface of this entity implementation.
<T extends Entity>
Class<? extends T>
getImplementedBy(Class<T> type)
          Returns the implementation to be used for the given entity type.
<T extends Entity>
EntityTypeRegistry
registerImplementation(Class<T> type, Class<? extends T> implClazz)
          Registers the implementation to use for a given entity type.
 

Method Detail

getImplementedBy

<T extends Entity> Class<? extends T> getImplementedBy(Class<T> type)
Returns the implementation to be used for the given entity type.

Type Parameters:
D -
Parameters:
entity - the DriverDependentEntity to create the EntityDriver for.
location - the Location where the DriverDependentEntity is running.
Returns:
the creates EntityDriver.
Throws:
IllegalArgumentException - If no implementation registered, and the given interface is not annotated with ImplementedBy
IllegalStateException - If the given type is not an interface, or if the implementation class is not a concrete class implementing it

getEntityTypeOf

<T extends Entity> Class<? super T> getEntityTypeOf(Class<T> type)
Returns the interface of this entity implementation. E.g. for use as the fully qualified name in entity.getEntityType().getName().

Throws:
IllegalArgumentException - If no interface is registered against this implementation, and no super-type of the class is annotated with ImplementedBy to point at the given class

registerImplementation

<T extends Entity> EntityTypeRegistry registerImplementation(Class<T> type,
                                                             Class<? extends T> implClazz)
Registers the implementation to use for a given entity type. The implementation must be a non-abstract class implementing the given type, and must have a no-argument constructor.

Throws:
IllegalArgumentException - If this implementation has already been registered for a different type
IllegalStateException - If the implClazz is not a concrete class, or does not implement type


Copyright © 2013. All Rights Reserved.