org.apache.ojb.broker.core
Class PersistenceBrokerAbstractImpl

java.lang.Object
  extended by org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl
All Implemented Interfaces:
PersistenceBroker, PersistenceBrokerInternal, Configurable, ObjectContainer
Direct Known Subclasses:
PersistenceBrokerImpl

public abstract class PersistenceBrokerAbstractImpl
extends Object
implements PersistenceBrokerInternal

Abstract Implementation of the PersistenceBroker encapsulating the used PB-event/listener concept.

Version:
$Id: PersistenceBrokerAbstractImpl.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
See Also:
PersistenceBroker, PBLifeCycleListener, PersistenceBrokerAware, PBStateListener

Field Summary
protected  PBStateEvent AFTER_BEGIN_EVENT
           
protected  PBStateEvent AFTER_COMMIT_EVENT
           
protected  PBLifeCycleEvent AFTER_DELETE_EVENT
           
protected  PBLifeCycleEvent AFTER_LOOKUP_EVENT
           
protected  PBStateEvent AFTER_OPEN_EVENT
           
protected  PBStateEvent AFTER_ROLLBACK_EVENT
           
protected  PBLifeCycleEvent AFTER_STORE_EVENT
           
protected  PBLifeCycleEvent AFTER_UPDATE_EVENT
           
protected  PBStateEvent BEFORE_BEGIN_EVENT
           
protected  PBStateEvent BEFORE_CLOSE_EVENT
           
protected  PBStateEvent BEFORE_COMMIT_EVENT
           
protected  PBLifeCycleEvent BEFORE_DELETE_EVENT
           
protected  PBStateEvent BEFORE_ROLLBACK_EVENT
           
protected  PBLifeCycleEvent BEFORE_STORE_EVENT
           
protected  PBLifeCycleEvent BEFORE_UPDATE_EVENT
           
 
Constructor Summary
PersistenceBrokerAbstractImpl()
           
 
Method Summary
 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 configure(Configuration pConfig)
          Override if needed.
 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.
 boolean isTxCheck()
          Returns true if the development checks are enabled.
 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 removeListener(PBListener listener)
          Removes the specified listener from this broker.
 void setTxCheck(boolean txCheck)
          This setting can be helpful during development if the PersistenceBroker transaction demarcation was used (this is true in most cases).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.ojb.broker.PersistenceBrokerInternal
checkRefreshRelationships, createProxy, delete, getProxyFactory, getReferenceBroker, getRelationshipPrefetcherFactory, isManaged, setManaged, store
 
Methods inherited from interface org.apache.ojb.broker.PersistenceBroker
abortTransaction, addMtoNImplementor, beginTransaction, clearCache, close, commitTransaction, delete, deleteByQuery, deleteMtoNImplementor, getClassDescriptor, getCollectionByQuery, getCollectionByQuery, getCount, getDescriptorRepository, getIteratorByQuery, getObjectByIdentity, getObjectByQuery, getPBKey, getPKEnumerationByQuery, getReportQueryIteratorByQuery, getTopLevelClass, hasClassDescriptor, isClosed, isInTransaction, removeFromCache, retrieveAllReferences, retrieveReference, serviceBrokerHelper, serviceConnectionManager, serviceIdentity, serviceJdbcAccess, serviceObjectCache, serviceSequenceManager, serviceSqlGenerator, serviceStatementManager, store, store
 
Methods inherited from interface org.odbms.ObjectContainer
query
 

Field Detail

AFTER_OPEN_EVENT

protected final PBStateEvent AFTER_OPEN_EVENT

AFTER_BEGIN_EVENT

protected final PBStateEvent AFTER_BEGIN_EVENT

AFTER_COMMIT_EVENT

protected final PBStateEvent AFTER_COMMIT_EVENT

AFTER_ROLLBACK_EVENT

protected final PBStateEvent AFTER_ROLLBACK_EVENT

BEFORE_BEGIN_EVENT

protected final PBStateEvent BEFORE_BEGIN_EVENT

BEFORE_COMMIT_EVENT

protected final PBStateEvent BEFORE_COMMIT_EVENT

BEFORE_ROLLBACK_EVENT

protected final PBStateEvent BEFORE_ROLLBACK_EVENT

BEFORE_CLOSE_EVENT

protected final PBStateEvent BEFORE_CLOSE_EVENT

BEFORE_STORE_EVENT

protected PBLifeCycleEvent BEFORE_STORE_EVENT

AFTER_STORE_EVENT

protected PBLifeCycleEvent AFTER_STORE_EVENT

BEFORE_DELETE_EVENT

protected PBLifeCycleEvent BEFORE_DELETE_EVENT

AFTER_DELETE_EVENT

protected PBLifeCycleEvent AFTER_DELETE_EVENT

AFTER_LOOKUP_EVENT

protected PBLifeCycleEvent AFTER_LOOKUP_EVENT

BEFORE_UPDATE_EVENT

protected PBLifeCycleEvent BEFORE_UPDATE_EVENT

AFTER_UPDATE_EVENT

protected PBLifeCycleEvent AFTER_UPDATE_EVENT
Constructor Detail

PersistenceBrokerAbstractImpl

public PersistenceBrokerAbstractImpl()
Method Detail

configure

public void configure(Configuration pConfig)
               throws ConfigurationException
Override if needed.

Specified by:
configure in interface Configurable
Parameters:
pConfig - the Configuration object used to configure current instance
Throws:
ConfigurationException
See Also:
Configurable.configure(Configuration)

isTxCheck

public boolean isTxCheck()
Returns true if the development checks are enabled.

See Also:
setTxCheck(boolean)

setTxCheck

public void setTxCheck(boolean txCheck)
This setting can be helpful during development if the PersistenceBroker transaction demarcation was used (this is true in most cases). If set 'true' on PB#store(...) and PB#delete(...) methods calls OJB check for active PB-tx and if no active tx is found a error is logged. This can help to avoid store/delete calls without a running PB-tx while development. Default setting is 'false'.

Note: When using OJB in a managed environment without OJB-caching, it's valid to use store/delete calls without a running PB-tx.

Parameters:
txCheck - Set true to enable the checks

addListener

public void addListener(PBListener listener)
                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Adds a temporary PBListener to this broker. Note that temporary listeners will be removed upon closing a broker (returning it to the pool).

Specified by:
addListener in interface PersistenceBroker
Parameters:
listener - The listener to add
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.addListener(PBListener listener)

addListener

public void addListener(PBListener listener,
                        boolean permanent)
                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Adds a temporary or permanent 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).
NOTE: Handle carefully when using this method, keep in mind you don't know which broker instance will be returned next time from the pool! To guarantee that a listener is connect to every broker, the best way is to define your own implementation of PersistenceBrokerFactoryIF or extend the default one, PersistenceBrokerFactoryDefaultImpl. There you can add the listener at creation of the PersistenceBroker instances.

Specified by:
addListener in interface PersistenceBroker
Parameters:
listener - The listener to add
permanent - Whether the listener will stay registered after closing the broker
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.addListener(PBListener listener, boolean permanent)

removeListener

public void removeListener(PBListener listener)
                    throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes the specified listener from this broker.

Specified by:
removeListener in interface PersistenceBroker
Parameters:
listener - The listener to remove
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeListener(PBListener listener)

removeAllListeners

public void removeAllListeners(boolean permanent)
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes all temporary and, if desired, permanent listeners from this broker. Use with care, because some internals rely on this mechanism.

Specified by:
removeAllListeners in interface PersistenceBroker
Parameters:
permanent - Whether the listener will stay registered after closing the broker
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeAllListeners(boolean)

removeAllListeners

public void removeAllListeners()
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes all temporary listeners from this broker. Use with care, because some internals rely on this mechanism.

Specified by:
removeAllListeners in interface PersistenceBroker
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeAllListeners()

fireBrokerEvent

public void fireBrokerEvent(PersistenceBrokerEvent event)
Description copied from interface: PersistenceBroker
Fires a broker event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire

fireBrokerEvent

public void fireBrokerEvent(PBLifeCycleEvent event)
Description copied from interface: PersistenceBroker
Fires a life cycle event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire

fireBrokerEvent

public void fireBrokerEvent(PBStateEvent event)
Description copied from interface: PersistenceBroker
Fires a state event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.