|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PersistenceBroker
PersistenceBroker declares a protocol for persisting arbitrary objects. A typical implementation might wrap an RDBMS access layer.
PersistenceBrokerImpl
,
PersistenceBrokerBean
Method Summary | |
---|---|
void |
abortTransaction()
Aborts and closes the current transaction. |
void |
addListener(PBListener listener)
Adds a temporary PBListener to this broker. |
void |
addListener(PBListener listener,
boolean permanent)
Adds a temporary or permanent PBListener to this broker,
depending on the parameter value. |
void |
addMtoNImplementor(MtoNImplementor m2nImpl)
Stores the given m:n implementor int the underlying persistence system. |
void |
beginTransaction()
Begins a transaction against the underlying RDBMS. |
void |
clearCache()
Clears the broker's internal cache. |
boolean |
close()
Closes this broker so that no further requests may be made on it. |
void |
commitTransaction()
Commits and closes the current transaction. |
void |
delete(java.lang.Object obj)
Deletes the given object's persistent representation in the underlying persistence system. |
void |
deleteByQuery(Query query)
Deletes all objects matching the given query, from the underlying persistence system. |
void |
deleteMtoNImplementor(MtoNImplementor m2nImpl)
Deletes an m:n implementor which defines the relationship between two persistent objects. |
void |
fireBrokerEvent(PBLifeCycleEvent event)
Fires a life cycle event to inform all registered PBListener instances. |
void |
fireBrokerEvent(PBStateEvent event)
Fires a state event to inform all registered PBListener instances. |
void |
fireBrokerEvent(PersistenceBrokerEvent event)
Fires a broker event to inform all registered PBListener instances. |
ClassDescriptor |
getClassDescriptor(java.lang.Class clazz)
Returns the class descriptor for the given persistence capable class. |
ManageableCollection |
getCollectionByQuery(java.lang.Class collectionClass,
Query query)
Retrieves the persistent objects matching the given query. |
java.util.Collection |
getCollectionByQuery(Query query)
Retrieves the persistent objects matching the given query. |
int |
getCount(Query query)
Returns the number of elements that the given query will return. |
DescriptorRepository |
getDescriptorRepository()
Returns the metadata descriptor repository associated with this broker. |
java.util.Iterator |
getIteratorByQuery(Query query)
Retrieves the persistent objects matching the given query and returns them as an iterator which may, depending on the configured collection type, be reloading the objects from the database upon calling Iterator.next() . |
java.lang.Object |
getObjectByIdentity(Identity id)
Retrieve a persistent object from the underlying datastore by its identity. |
java.lang.Object |
getObjectByQuery(Query query)
Retrieve the (first) persistent object from the underlying datastore that matches the given query. |
PBKey |
getPBKey()
Get the PBKey for this broker. |
java.util.Enumeration |
getPKEnumerationByQuery(java.lang.Class pkClass,
Query query)
Returns an enumeration of objects representing the primary keys for the objects that match the given query. |
java.util.Iterator |
getReportQueryIteratorByQuery(Query query)
Retrieves the rows (as Object[] instances) matching the given query and
returns them as an iterator which may, depending on the configured collection type, be reloading
the objects from the database upon calling Iterator.next() . |
java.lang.Class |
getTopLevelClass(java.lang.Class clazz)
Returns the top level class (most abstract class in terms of extents) from which the given class extends. |
boolean |
hasClassDescriptor(java.lang.Class clazz)
Determines whether the given class is persistence capable and thus has an associated class descriptor in the metadata. |
boolean |
isClosed()
Determines whether this broker is closed. |
boolean |
isInTransaction()
Determines whether there is currently a transaction in progress. |
void |
removeAllListeners()
Removes all temporary listeners from this broker. |
void |
removeAllListeners(boolean permanent)
Removes all temporary and, if desired, permanent listeners from this broker. |
void |
removeFromCache(java.lang.Object objectOrIdentity)
Removes the given object or, if it is an instance of Identity ,
the object identified by it, from the broker's internal cache. |
void |
removeListener(PBListener listener)
Removes the specified listener from this broker. |
void |
retrieveAllReferences(java.lang.Object obj)
Retrieve all references and collections of the given object irrespective of the metadata settings defined for them. |
void |
retrieveReference(java.lang.Object obj,
java.lang.String attrName)
Retrieve the specified reference or collection attribute for the given persistent object. |
BrokerHelper |
serviceBrokerHelper()
Returns the BrokerHelper instance associated with this broker, which
makes some additional helper methods available. |
ConnectionManagerIF |
serviceConnectionManager()
Returns the ConnectionManagerIF instance associated with this broker. |
IdentityFactory |
serviceIdentity()
Return the IdentityFactory instance associated with this broker. |
JdbcAccess |
serviceJdbcAccess()
Returns the JdbcAccess instance associated with this broker. |
ObjectCache |
serviceObjectCache()
Returns the ObjectCache instance associated
with this broker. |
SequenceManager |
serviceSequenceManager()
Returns the SequenceManager instance associated with this broker. |
org.apache.ojb.broker.accesslayer.sql.SqlGenerator |
serviceSqlGenerator()
Returns the SqlGenerator instance associated with this broker. |
StatementManagerIF |
serviceStatementManager()
Returns the StatementManagerIF instance associated with this broker. |
void |
store(java.lang.Object obj)
Make the given object persistent in the underlying persistence system. |
void |
store(java.lang.Object obj,
ObjectModification modification)
Makes the given object persistent in the underlying persistence system. |
Methods inherited from interface org.apache.ojb.broker.util.configuration.Configurable |
---|
configure |
Methods inherited from interface org.odbms.ObjectContainer |
---|
query |
Method Detail |
---|
StatementManagerIF serviceStatementManager()
StatementManagerIF
instance associated with this broker.
ConnectionManagerIF serviceConnectionManager()
ConnectionManagerIF
instance associated with this broker.
org.apache.ojb.broker.accesslayer.sql.SqlGenerator serviceSqlGenerator()
SqlGenerator
instance associated with this broker.
JdbcAccess serviceJdbcAccess()
JdbcAccess
instance associated with this broker.
SequenceManager serviceSequenceManager()
SequenceManager
instance associated with this broker.
BrokerHelper serviceBrokerHelper()
BrokerHelper
instance associated with this broker, which
makes some additional helper methods available.
ObjectCache serviceObjectCache()
ObjectCache
instance associated
with this broker.
IdentityFactory serviceIdentity()
IdentityFactory
instance associated with this broker.
void fireBrokerEvent(PersistenceBrokerEvent event)
PBListener
instances.
event
- The event to firevoid fireBrokerEvent(PBLifeCycleEvent event)
PBListener
instances.
event
- The event to firevoid fireBrokerEvent(PBStateEvent event)
PBListener
instances.
event
- The event to firevoid removeAllListeners() throws PersistenceBrokerException
PersistenceBrokerException
removeListener(PBListener)
void removeAllListeners(boolean permanent) throws PersistenceBrokerException
permanent
- Whether the listener will stay registered after closing
the broker
PersistenceBrokerException
removeListener(PBListener)
void addListener(PBListener listener) throws PersistenceBrokerException
PBListener
to this broker.
Note that temporary listeners will be removed upon closing a broker (returning
it to the pool).
listener
- The listener to add
PersistenceBrokerException
addListener(PBListener, boolean)
void addListener(PBListener listener, boolean permanent) throws PersistenceBrokerException
PBListener
to this broker,
depending on the parameter value. Note that temporary listeners will be removed upon
closing a broker (returning it to the pool).
PersistenceBrokerFactoryIF
or extend the default
one, PersistenceBrokerFactoryDefaultImpl
. There you
can add the listener at creation of the PersistenceBroker
instances.
listener
- The listener to addpermanent
- Whether the listener will stay registered after closing
the broker
PersistenceBrokerException
void removeListener(PBListener listener) throws PersistenceBrokerException
listener
- The listener to remove
PersistenceBrokerException
void abortTransaction() throws TransactionNotInProgressException
TransactionNotInProgressException
- If no transaction is currently in progressvoid beginTransaction() throws TransactionInProgressException, TransactionAbortedException
TransactionInProgressException
- If there is already a transaction in progress
TransactionAbortedException
void commitTransaction() throws TransactionNotInProgressException, TransactionAbortedException
TransactionNotInProgressException
- If there is no transaction currently in progress
TransactionAbortedException
- If the transaction cannot be committedboolean isInTransaction() throws PersistenceBrokerException
true
if there is a transaction in progress
PersistenceBrokerException
boolean close()
true
if the broker was successfully closedboolean isClosed()
DescriptorRepository getDescriptorRepository()
PBKey getPBKey()
PBKey
for this broker.
ClassDescriptor getClassDescriptor(java.lang.Class clazz) throws PersistenceBrokerException
clazz
- The target class
PersistenceBrokerException
- If the class is not persistence capable, i.e.
if no metadata was defined for this class and hence its class descriptor
was not foundboolean hasClassDescriptor(java.lang.Class clazz)
clazz
- The target class
true
if a class descriptor was foundjava.lang.Class getTopLevelClass(java.lang.Class clazz) throws PersistenceBrokerException
clazz
- The class to get the top level class for
PersistenceBrokerException
- If the class is not persistence capable,
if no metadata was defined for this classvoid clearCache() throws PersistenceBrokerException
PersistenceBrokerException
void removeFromCache(java.lang.Object objectOrIdentity) throws PersistenceBrokerException
Identity
,
the object identified by it, from the broker's internal cache. Note that the removal is
not recursive. This means, objects referenced by the removed object will not be
automatically removed from the cache by this operation.
objectOrIdentity
- The object to be removed from the cache or its identity
PersistenceBrokerException
void store(java.lang.Object obj, ObjectModification modification) throws PersistenceBrokerException
obj
- The object to storemodification
- Specifies what operation to perform (for generating optimized SQL)
PersistenceBrokerException
void store(java.lang.Object obj) throws PersistenceBrokerException
obj
- The object to store
PersistenceBrokerException
void delete(java.lang.Object obj) throws PersistenceBrokerException
obj
- The object to delete
PersistenceBrokerException
void deleteMtoNImplementor(MtoNImplementor m2nImpl) throws PersistenceBrokerException
m2nImpl
- The m:n implementor to delete
PersistenceBrokerException
void addMtoNImplementor(MtoNImplementor m2nImpl) throws PersistenceBrokerException
m2nImpl
- The m:n implementor to delete
PersistenceBrokerException
void deleteByQuery(Query query) throws PersistenceBrokerException
query
- The query determining the objects to delete
PersistenceBrokerException
void retrieveAllReferences(java.lang.Object obj) throws PersistenceBrokerException
obj
- The persistent object
PersistenceBrokerException
void retrieveReference(java.lang.Object obj, java.lang.String attrName) throws PersistenceBrokerException
obj
- The persistent objectattrName
- The name of the attribute to retrieve
PersistenceBrokerException
int getCount(Query query) throws PersistenceBrokerException
query
- The query
PersistenceBrokerException
java.util.Collection getCollectionByQuery(Query query) throws PersistenceBrokerException
query
- The query
PersistenceBrokerException
ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query) throws PersistenceBrokerException
collectionClass
- The collection type which needs to implement
ManageableCollection
query
- The query
PersistenceBrokerException
java.util.Iterator getIteratorByQuery(Query query) throws PersistenceBrokerException
Iterator.next()
. Note that if the Query has no criteria
ALL persistent objects of the class targeted by the query will be returned.
query
- The query
PersistenceBrokerException
java.util.Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
Object[]
instances) matching the given query and
returns them as an iterator which may, depending on the configured collection type, be reloading
the objects from the database upon calling Iterator.next()
.
query
- The report query
PersistenceBrokerException
java.lang.Object getObjectByIdentity(Identity id) throws PersistenceBrokerException
getObjectByQuery(Query)
instead, as this method is mainly
intended to be used for internal handling of materialization by OID (e.g. in Proxies).
id
- The persistent object's id
PersistenceBrokerException
java.lang.Object getObjectByQuery(Query query) throws PersistenceBrokerException
query
- The query
PersistenceBrokerException
java.util.Enumeration getPKEnumerationByQuery(java.lang.Class pkClass, Query query) throws PersistenceBrokerException
pkClass
- The class to use for the primary keysquery
- The query
PersistenceBrokerException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |