org.apache.ojb.broker.core
Class PersistenceBrokerAbstractImpl

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

public abstract class PersistenceBrokerAbstractImpl
extends java.lang.Object
implements PersistenceBrokerInternal

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

Version:
$Id: PersistenceBrokerAbstractImpl.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Created by Charles on 12-Sep-2002 08:04:47, Armin Waibel
See Also:
PersistenceBroker, PBLifeCycleListener, PersistenceBrokerAware, PBStateListener

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(org.apache.ojb.broker.util.configuration.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
equals, 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
 

Constructor Detail

PersistenceBrokerAbstractImpl

public PersistenceBrokerAbstractImpl()
Method Detail

configure

public void configure(org.apache.ojb.broker.util.configuration.Configuration pConfig)
               throws org.apache.ojb.broker.util.configuration.ConfigurationException
Override if needed.

Specified by:
configure in interface org.apache.ojb.broker.util.configuration.Configurable
Parameters:
pConfig - the Configuration object used to configure current instance
Throws:
org.apache.ojb.broker.util.configuration.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


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30