public abstract class BeanManager extends Object implements Serializable
Bean Manager is used to create and remove bean instances, to find beans by their name, and to query over beans.
How, when and with what gurantees data are stored (consistency, reliability etc) in the underlying storage and published to applications are coordinated by this manager.
Bean Manager is also responsible for enforcing referential integrity between beans and making sure that links arent brooken. This is the only type of constraint that is checked, a bean manager is not concerned with schema or application validation of any kind.
A bean manager should assume that its users already are authorized users, maybe authorized through an external security mechanism.
Bean managers are free (and encouraged, but not forced) to implement support for participating in JTA transactions.
| Constructor and Description |
|---|
BeanManager() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
create(Bean bean)
Creates a new bean.
|
abstract void |
create(Collection<Bean> beans)
This is the collection variant of
create(Bean). |
abstract void |
createSingleton(Bean.BeanId singleton)
Create a singleton instance.
|
abstract Bean |
delete(Bean.BeanId id)
Delete a bean accoring to id.
|
abstract Collection<Bean> |
delete(String schemaName,
Collection<String> instanceIds)
This method deletes multiple instances of the same schema type.
|
Map<Bean.BeanId,Bean> |
getBeanToValidate(Collection<Bean> beans)
Bean Manager is responsible for fetching the beans that are to validated when changes
are made to specific bean instance.
|
abstract com.google.common.base.Optional<Bean> |
getEager(Bean.BeanId id)
Get a specific instance of a particular schema type.
|
abstract com.google.common.base.Optional<Bean> |
getLazy(Bean.BeanId id)
Get a specific instance of a particular schema type.
|
abstract com.google.common.base.Optional<Bean> |
getSingleton(String schemaName)
Get a singleton instance for a particular schema.
|
abstract Map<Bean.BeanId,Bean> |
list(String schemaName)
List all instances of a specific schema type.
|
abstract Map<Bean.BeanId,Bean> |
list(String schemaName,
Collection<String> ids)
List specific instances of a specific schema type.
|
abstract void |
merge(Bean bean)
Merges the provided properties with an already existing
instance.
|
abstract void |
merge(Collection<Bean> bean)
This is the collection variant of
merge(Bean). |
abstract BeanQuery |
newQuery(Schema schema)
Create a new query used for retrieving bean instances using flexible composition
of Criterion objects, used to narrow number of beans in the result set.
|
abstract void |
set(Bean bean)
Replace (set) an existing bean instance with provided data.
|
abstract void |
set(Collection<Bean> bean)
This is the collection variant of
set(Bean). |
public static final String PROPERTY
public abstract void create(Bean bean) throws AbortRuntimeException
If the bean have references to other beans, the bean manager make sure that referential integrity is satisfied (that provided references exist).
Initialized bean references will not be traversed and created recursively/eagerly.
bean - to createAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract void create(Collection<Bean> beans) throws AbortRuntimeException
create(Bean).beans - createAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.create(Bean)public abstract void createSingleton(Bean.BeanId singleton)
singleton - the singleton.public abstract void set(Bean bean)
Already persisted properties and bean references associated with the instance will be removed if they are missing from provided bean instances.
If the bean have references to other beans, the bean manager make sure that referential integrity is satisfied (that provided references exist).Initialized bean references not will be traversed and set recursively/eagerly.
bean - to setAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract void set(Collection<Bean> bean) throws AbortRuntimeException
set(Bean).bean - to setAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.set(Bean)public abstract void merge(Bean bean) throws AbortRuntimeException
Already persisted properties and bean references associated with the instance will be overwritten if they also exist on the provided bean. This is true for collection properties aswell.
Values not provided will remain untouched in storage, hence this method can be used to set or delete a single property.
Initialized bean references not will be traversed and merged recursively/eagerly.
bean - The Bean does not have to have its Bean Info
provided with it.AbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract void merge(Collection<Bean> bean) throws AbortRuntimeException
merge(Bean).bean - to mergeAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.merge(Bean)public abstract com.google.common.base.Optional<Bean> getEager(Bean.BeanId id) throws AbortRuntimeException
Get a specific instance of a particular schema type.
Beans will have their basic properties initialized and all references traversed and fetched eagerly.
id - to getAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract com.google.common.base.Optional<Bean> getLazy(Bean.BeanId id) throws AbortRuntimeException
Get a specific instance of a particular schema type.
Beans will have their basic properties and all references initialized, but not traversed and fetched eagerly.
id - to getAbortRuntimeExceptionpublic Map<Bean.BeanId,Bean> getBeanToValidate(Collection<Bean> beans) throws AbortRuntimeException
Bean Manager is responsible for fetching the beans that are to validated when changes are made to specific bean instance. The list should contain all the beans that are to be validated. The bean manager is free to return all or a subset of beans.
This method is optional for bean managers to implement.
beans - targeted bean.AbortRuntimeExceptionpublic abstract com.google.common.base.Optional<Bean> getSingleton(String schemaName) throws IllegalArgumentException
schemaName - The singleton schema.IllegalArgumentException - if the schema name is not a singleton.public abstract Map<Bean.BeanId,Bean> list(String schemaName) throws AbortRuntimeException
List all instances of a specific schema type.
Beans will have their basic properties initialized and all references traversed and fetched eagerly.
schemaName - the type of beans to match.AbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract Map<Bean.BeanId,Bean> list(String schemaName, Collection<String> ids) throws AbortRuntimeException
List specific instances of a specific schema type.
Beans will have their basic properties initialized and all references traversed and fetched eagerly.
schemaName - the type of beans to match.ids - ids of the beans.AbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract Bean delete(Bean.BeanId id) throws AbortRuntimeException
Delete operations are not cascading, which means that a bean's references are not deleted along with the bean itself.
A bean may be referenced by other beans and the bean manager make sure that referential integrity is not violated when the bean is deleted.
id - delete this beanAbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.public abstract Collection<Bean> delete(String schemaName, Collection<String> instanceIds) throws AbortRuntimeException
schemaName - -instanceIds - -AbortRuntimeException - is thrown when the system itself cannot
recover from a certain event and must therefore abort execution, see
Events.#delete(BeanId)public abstract BeanQuery newQuery(Schema schema)
schema - schema to queryBeanQueryBuilder.BeanQueryBuilder}Copyright © 2013. All Rights Reserved.