org.norther.tammi.root.db
Class DefaultBeanRepositoryClient

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.root.db.DefaultRepositoryClient
          extended by org.norther.tammi.root.db.DefaultMultiRepositoryClient
              extended by org.norther.tammi.root.db.DefaultBeanRepositoryClient
All Implemented Interfaces:
Serializable, Cloneable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, BeanRepositoryClient, MultiRepositoryClient, RepositoryClient
Direct Known Subclasses:
DefaultBeanRepositoryFilter

public class DefaultBeanRepositoryClient
extends DefaultMultiRepositoryClient
implements BeanRepositoryClient

A default implementation of BeanRepositoryClient.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.root.db.DefaultRepositoryClient
AUTHENTICATED_SIGNATURE, DEFAULT_PERSISTER, KEY_SIGNATURE
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.root.db.BeanRepositoryClient
NULL_PK, ROOT_PK
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultBeanRepositoryClient()
          Constructs a new repository client.
 
Method Summary
 boolean add1NForeignReferences(Object node, String className, String fkField, Object[] fks, Persister persister)
          Adds foreign references to 1:n relations in a tree.
 boolean add1NNullReferences(String className, String fkField, Object[] fks, Persister persister)
          Adds null references to 1:n relations in a tree.
 boolean add1NObjectReferences(Object node, String relField, String fkField, Object[] fks, Persister persister)
          Adds object references to 1:n relations in a tree formed by nodes of the same class.
 boolean addAttributeValues(Object node, String field, Persister persister, List result)
          Adds nested attribute values in a tree to a list.
 boolean addTo1NRelationMap(Object node, String fkField, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map.
 boolean addTo1NRelationMap(Object node, String relField, String fkField, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a 1:n tree to a map.
 boolean addToAttributeChain(Object node, String relField, String valueField, Persister persister, List list)
          Adds attribute values of a chain of referenced objects in a tree into a list, the attribute of the end object at the lowest index.
 boolean addToAttributeMap(Object node, String relField, String valueField, Persister persister, ConcurrentMap map)
          Adds attribute values of referenced nodes in a tree into a map.
 boolean addToIdentityList(Collection vars, int index, String[] nameFields, Persister persister, OrderedSet list)
          Adds a collection of variables as enumerated identities to an ordered set.
 boolean addToIdentityList(Variable var, int index, String[] nameFields, Persister persister, OrderedSet list)
          Adds the specified variable as an enumerated identity to an ordered set.
 boolean addToIdentityTree(Collection roots, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds a collection of root variables to an ordered map.
 boolean addToIdentityTree(Collection vars, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chains of the selected variables to an ordered map.
 boolean addToIdentityTree(Identity[] ids, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chains of the selected identities to an ordered map.
 boolean addToIdentityTree(Identity id, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chain of the selected identity to an ordered map.
 boolean addToIdentityTree(Variable root, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the specified root variable to an ordered map.
 boolean addToIdentityTree(Variable var, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Adds the variable chain of the selected variable to an ordered map.
 boolean addToMNRelationMap(Object node, String indirection, String fkField1, String fkField2, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a m:n tree to a map.
 boolean addToMNRelationMap(Object node, String relField, String indirection, String fkField1, String fkField2, DBCriteria criteria, Persister persister, ConcurrentMap map)
          Adds referenced objects fulfilling the specified criteria in a m:n tree to a map.
 boolean addToRelationChain(Object node, String relField, Persister persister, List list)
          Adds a chain of referenced objects in a tree to a list, the end variable at the lowest index.
 boolean addToRelationMap(Object node, String relField, Persister persister, ConcurrentMap map)
          Adds referenced objects in a tree to a map.
 boolean addToVariableChain(Variable var, String relField, Collection filter, Persister persister, List list)
          Adds a chain of referenced variables in a tree to a list, the end variable at the lowest index.
 void collapseInIdentityTree(Identity id, Persister persister, OrderedMap tree)
          Collapses the specified identity in the ordered map representing an identity tree.
 Introspector createIntrospector()
          Creates a variable introspector.
 Variable createVariable(Class clazz)
          Creates a new variable instance of the specified class.
 Variable createVariable(String type)
          Creates a new variable MBean instance of the specified type.
 void delete1NRelationTree(Object node, String relField, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its subtree from a tree in 1:n relations.
 void deleteMNRelationTree(Object node, String relField, String indirection, String fkField1, String fkField2, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its subtree from a tree in m:n relations.
 void deleteObject(Object node, List predeps, List postdeps, Persister persister)
          Deletes the specified object and its dependencies.
 void expandInIdentityTree(Identity id, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Expands the specified identity in the ordered map representing an identity tree.
 VariableAttributeInfo getAttributeInfo(Variable node, String field, Persister persister)
          Gets a nested attribute info in a tree.
 Object getAttributeValue(Object node, String field, Persister persister)
          Gets a nested attribute value in a tree.
 List getAttributeValues(Object node, String field, Persister persister)
          Gets a list of nested attribute values in a tree.
 Object getEndReference(Object node, String relField, Persister persister)
          Gets the end node in a tree.
 Object getKeyAttributeValue(Object node, Persister persister)
          Gets the primary key attribute value.
 Object[] getKeyAttributeValues(Object node, Persister persister)
          Gets an array of primary key attribute values.
 Object getNextReference(Object node, int index, String relField, Persister persister)
          Gets the indexed node in a tree.
 Object getNextReference(Object node, String relField, Persister persister)
          Gets the next referenced node in a tree.
 List getNextReferences(Object node, String relField, Persister persister)
          Gets a list of referenced nodes in a tree.
 int getReferenceDepth(Object node, String relField, Persister persister)
          Gets the depth of a node in a tree.
protected  ResourceMap getResourceMap()
          Gets the referent of the resource map MBean.
 Object getRootReference(Object node, String relField, Persister persister)
          Gets the root node in a tree.
 List getRootReferences(Object node, String relField, Persister persister)
          Gets a list of root nodes in a tree.
protected  VariableRegistry getVariableRegistry()
          Gets the referent of the variable registry MBean.
 ObjectName getVariableRegistryName()
          Gets the the variable registry to be applied by contexts of this filter.
 boolean isLocalizedBeans()
          Gets the localized beans flag.
 boolean isNullPK(Object pk)
          Checks whether the specified pk is a null key.
 boolean isRelatedTo(Object node, String relField, Object xpk, Persister persister)
          Checks whether the specified key is related to the specified node.
 boolean isRootPK(Object pk)
          Checks whether the specified pk is a root key.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 Collection queryAllObjects(String className, DBCriteria criteria, String[] sortFields, Persister persister)
          Queries all objects fulfilling the specified criteria, and may sort them by optional sort fields.
 Collection queryTreeObjects(String className, Object pk, String relField, DBCriteria criteria, String[] sortFields, Persister persister)
          Queries objects on the next level in a relation tree fulfilling the specified criteria, and may sort them by optional sort fields.
 boolean restoreIdentityTree(List enums, int depth, String parentField, String childField, String[] nameFields, Persister persister, OrderedMap tree)
          Restores the specified enumerated identities to an ordered map.
 void setAttributeValue(Object node, String field, Object value, boolean forced, Persister persister)
          Sets a nested attribute value in a tree with a forced option.
 void setAttributeValue(Object node, String field, Object value, Persister persister)
          Sets a nested attribute value in a tree.
 void setKeyAttributeValue(Object node, Object value, Persister persister)
          Sets the primary key attribute value.
 void setKeyAttributeValues(Object node, Object[] values, Persister persister)
          Sets an array of primary key attribute values.
 void setLocalizedBeans(boolean flag)
          Sets the localized beans flag.
 Object[] setMNForeignReferences(Object node, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister)
          Sets foreign references in m:n relations in a tree.
 Object[] setMNObjectReferences(Object node, String relField, String indirection, String fkField1, String fkField2, Object[] fks, Persister persister)
          Sets object references in m:n relations in a tree formed by nodes of the same class.
 void setVariableRegistryName(ObjectName registry)
          Sets the variable registry to be applied by contexts this filter.
 Collection sortObjects(Collection objects, String[] sortFields, Persister persister)
          Sorts a collection of objects with the specified fields.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.root.db.DefaultMultiRepositoryClient
acquirePersister, acquirePersister, acquirePersister, clearConnections, connectionKeySet, containsConnection, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnection, getConnection, getConnection, getConnection, getConnectionAlias, getConnectionKey, getConnectionUsername, getPersisterClassName, getResourceKey, isConnectionAuthenticated, removeConnection, setAuthenticationConnection, setConnection, setConnection, setConnectionAlias, setConnectionAuthenticated, setConnectionKey, setConnectionPassword, setConnectionUsername, setPersisterClassName, setResourceKey
 
Methods inherited from class org.norther.tammi.root.db.DefaultRepositoryClient
acquirePersister, acquirePersister, acquirePersister, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnectionUsername, getPersister, getPersisterClassName, isConnectionAuthenticated, setAuthenticationConnection, setConnectionAuthenticated, setConnectionPassword, setConnectionUsername, setPersisterClassName
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.root.db.MultiRepositoryClient
acquirePersister, acquirePersister, acquirePersister, clearConnections, connectionKeySet, containsConnection, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnectionAlias, getConnectionUsername, getPersisterClassName, getResourceKey, isConnectionAuthenticated, removeConnection, setAuthenticationConnection, setConnectionAlias, setConnectionAuthenticated, setConnectionPassword, setConnectionUsername, setPersisterClassName, setResourceKey
 
Methods inherited from interface org.norther.tammi.root.db.RepositoryClient
acquirePersister, acquirePersister, acquirePersister, getAuthenticatedPasswordKey, getAuthenticatedUsernameKey, getAuthenticationConnectionKey, getConnectionKey, getConnectionUsername, getPersisterClassName, isConnectionAuthenticated, setAuthenticationConnection, setConnectionAuthenticated, setConnectionKey, setConnectionPassword, setConnectionUsername, setPersisterClassName
 

Constructor Detail

DefaultBeanRepositoryClient

public DefaultBeanRepositoryClient()
Constructs a new repository client.

Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

isNullPK

public boolean isNullPK(Object pk)
Description copied from interface: BeanRepositoryClient
Checks whether the specified pk is a null key.

Specified by:
isNullPK in interface BeanRepositoryClient
Parameters:
pk - the pk to check.
Returns:
true for a null key, false otherwise.

isRootPK

public boolean isRootPK(Object pk)
Description copied from interface: BeanRepositoryClient
Checks whether the specified pk is a root key.

Specified by:
isRootPK in interface BeanRepositoryClient
Parameters:
pk - the pk to check.
Returns:
true for a root key, false otherwise.

createIntrospector

public Introspector createIntrospector()
Description copied from interface: BeanRepositoryClient
Creates a variable introspector.

Specified by:
createIntrospector in interface BeanRepositoryClient
Returns:
the introspector.

isLocalizedBeans

public boolean isLocalizedBeans()
Description copied from interface: BeanRepositoryClient
Gets the localized beans flag.

Specified by:
isLocalizedBeans in interface BeanRepositoryClient
Returns:
the localized beans flag.

setLocalizedBeans

public void setLocalizedBeans(boolean flag)
Description copied from interface: BeanRepositoryClient
Sets the localized beans flag.

Specified by:
setLocalizedBeans in interface BeanRepositoryClient
Parameters:
flag - the localized beans flag.

getVariableRegistryName

public ObjectName getVariableRegistryName()
Description copied from interface: BeanRepositoryClient
Gets the the variable registry to be applied by contexts of this filter.

Specified by:
getVariableRegistryName in interface BeanRepositoryClient
Returns:
the object name of the variable registry or a query.

setVariableRegistryName

public void setVariableRegistryName(ObjectName registry)
Description copied from interface: BeanRepositoryClient
Sets the variable registry to be applied by contexts this filter. If it is not set, the default one will be used.

Specified by:
setVariableRegistryName in interface BeanRepositoryClient
Parameters:
registry - the object name of the variable registry or a query.

createVariable

public Variable createVariable(String type)
                        throws ConstructionException
Description copied from interface: BeanRepositoryClient
Creates a new variable MBean instance of the specified type.

Specified by:
createVariable in interface BeanRepositoryClient
Parameters:
type - the type of the variable.
Returns:
the variable MBean instance.
Throws:
ConstructionException - if construction fails.

createVariable

public Variable createVariable(Class clazz)
                        throws ConstructionException
Description copied from interface: BeanRepositoryClient
Creates a new variable instance of the specified class.

Specified by:
createVariable in interface BeanRepositoryClient
Parameters:
clazz - the class of the variable.
Returns:
the variable MBean instance.
Throws:
ConstructionException - if construction fails.

getKeyAttributeValue

public Object getKeyAttributeValue(Object node,
                                   Persister persister)
                            throws AttributeNotFoundException
Description copied from interface: BeanRepositoryClient
Gets the primary key attribute value.

Specified by:
getKeyAttributeValue in interface BeanRepositoryClient
Parameters:
node - the node object.
persister - the persister.
Returns:
the primary key attribute value or null.
Throws:
AttributeNotFoundException - for a missing field.

setKeyAttributeValue

public void setKeyAttributeValue(Object node,
                                 Object value,
                                 Persister persister)
                          throws AttributeNotFoundException,
                                 InvalidAttributeValueException
Description copied from interface: BeanRepositoryClient
Sets the primary key attribute value.

Specified by:
setKeyAttributeValue in interface BeanRepositoryClient
Parameters:
node - the node object.
value - the primary key attribute value.
persister - the persister.
Throws:
AttributeNotFoundException - for a missing field.
InvalidAttributeValueException - if the value is invalid.

getKeyAttributeValues

public Object[] getKeyAttributeValues(Object node,
                                      Persister persister)
                               throws AttributeNotFoundException
Description copied from interface: BeanRepositoryClient
Gets an array of primary key attribute values.

Specified by:
getKeyAttributeValues in interface BeanRepositoryClient
Parameters:
node - the node object.
persister - the persister.
Returns:
an array of primary key attribute values or null.
Throws:
AttributeNotFoundException - for a missing field.

setKeyAttributeValues

public void setKeyAttributeValues(Object node,
                                  Object[] values,
                                  Persister persister)
                           throws InvalidAttributeValueException,
                                  AttributeNotFoundException
Description copied from interface: BeanRepositoryClient
Sets an array of primary key attribute values.

Specified by:
setKeyAttributeValues in interface BeanRepositoryClient
Parameters:
node - the node object.
values - an array of primary key values.
persister - the persister.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - for a missing field.

getAttributeInfo

public VariableAttributeInfo getAttributeInfo(Variable node,
                                              String field,
                                              Persister persister)
                                       throws AttributeNotFoundException
Description copied from interface: BeanRepositoryClient
Gets a nested attribute info in a tree.

Specified by:
getAttributeInfo in interface BeanRepositoryClient
Parameters:
node - the node variable.
field - the attribute field(s).
persister - the persister.
Returns:
the attribute info or null.
Throws:
AttributeNotFoundException - for a missing field.

getAttributeValue

public Object getAttributeValue(Object node,
                                String field,
                                Persister persister)
                         throws AttributeNotFoundException
Description copied from interface: BeanRepositoryClient
Gets a nested attribute value in a tree.

Specified by:
getAttributeValue in interface BeanRepositoryClient
Parameters:
node - the node object.
field - the attribute field(s).
persister - the persister.
Returns:
the attribute value or null.
Throws:
AttributeNotFoundException - for a missing field.

setAttributeValue

public void setAttributeValue(Object node,
                              String field,