org.apache.ojb.broker.core
Class PersistenceBrokerFactoryBaseImpl

java.lang.Object
  extended by org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl
All Implemented Interfaces:
PersistenceBrokerFactoryIF, org.apache.ojb.broker.util.configuration.Configurable
Direct Known Subclasses:
PersistenceBrokerFactoryDefaultImpl

public class PersistenceBrokerFactoryBaseImpl
extends java.lang.Object
implements PersistenceBrokerFactoryIF

This is an base implementation of the PersistenceBrokerFactoryIF interface. Each request (PersistenceBrokerFactoryIF.createPersistenceBroker(org.apache.ojb.broker.PBKey) or PersistenceBrokerFactoryIF.defaultPersistenceBroker() call) creates a new PersistenceBroker instance. No pooling of broker instances is used.

Version:
$Id: PersistenceBrokerFactoryBaseImpl.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler, Armin Waibel
See Also:
PersistenceBrokerFactoryDefaultImpl

Constructor Summary
PersistenceBrokerFactoryBaseImpl()
           
 
Method Summary
 int activePersistenceBroker()
          Not implemented!
 void configure(org.apache.ojb.broker.util.configuration.Configuration config)
          configure an object using the Configuration pConfig
 PersistenceBrokerInternal createPersistenceBroker(PBKey pbKey)
          Always return a new created PersistenceBroker instance
 PersistenceBrokerInternal createPersistenceBroker(java.lang.String jcdAlias, java.lang.String user, java.lang.String password)
          Return a ready for action PersistenceBroker instance.
 PersistenceBrokerInternal defaultPersistenceBroker()
          Return a default broker instance, specified in configuration or set using PersistenceBrokerFactoryIF.setDefaultKey(org.apache.ojb.broker.PBKey).
 PBKey getDefaultKey()
          Get the default PBKey.
 void releaseAllInstances()
          release all broker instances pooled by the factory.
 void setDefaultKey(PBKey key)
          Set the PBKey used for convinience PersistenceBroker lookup method PersistenceBrokerFactoryIF.defaultPersistenceBroker().
 void shutdown()
          Shutdown method for OJB, kills all running processes within OJB - after shutdown OJB can no longer be used.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerFactoryBaseImpl

public PersistenceBrokerFactoryBaseImpl()
Method Detail

setDefaultKey

public void setDefaultKey(PBKey key)
Description copied from interface: PersistenceBrokerFactoryIF
Set the PBKey used for convinience PersistenceBroker lookup method PersistenceBrokerFactoryIF.defaultPersistenceBroker().
Note: It's only allowed to set the default PBKey once. All further calls will cause an exception. If a default JdbcConnectionDescriptor was declared in configuration file, OJB will set the declared PBKey as default.
This method is convenience for MetadataManager.setDefaultPBKey(org.apache.ojb.broker.PBKey).

Specified by:
setDefaultKey in interface PersistenceBrokerFactoryIF
See Also:
PersistenceBrokerFactoryIF.setDefaultKey(org.apache.ojb.broker.PBKey)

getDefaultKey

public PBKey getDefaultKey()
Description copied from interface: PersistenceBrokerFactoryIF
Get the default PBKey. This method is convenience for MetadataManager.getDefaultPBKey().

Specified by:
getDefaultKey in interface PersistenceBrokerFactoryIF
See Also:
PersistenceBrokerFactoryIF.getDefaultKey()

createPersistenceBroker

public PersistenceBrokerInternal createPersistenceBroker(PBKey pbKey)
                                                  throws PBFactoryException
Always return a new created PersistenceBroker instance

Specified by:
createPersistenceBroker in interface PersistenceBrokerFactoryIF
Parameters:
pbKey -
Returns:
Throws:
PBFactoryException

createPersistenceBroker

public PersistenceBrokerInternal createPersistenceBroker(java.lang.String jcdAlias,
                                                         java.lang.String user,
                                                         java.lang.String password)
                                                  throws PBFactoryException
Description copied from interface: PersistenceBrokerFactoryIF
Return a ready for action PersistenceBroker instance.

Specified by:
createPersistenceBroker in interface PersistenceBrokerFactoryIF
Parameters:
jcdAlias - An jcdAlias name specified in a jdbc-connection-descriptor
user - user name specified in a jdbc-connection-descriptor
password - valid password specified in a jdbc-connection-descriptor
Throws:
PBFactoryException
See Also:
PersistenceBrokerFactoryIF.createPersistenceBroker( String jcdAlias, String user, String password)

defaultPersistenceBroker

public PersistenceBrokerInternal defaultPersistenceBroker()
                                                   throws PBFactoryException
Description copied from interface: PersistenceBrokerFactoryIF
Return a default broker instance, specified in configuration or set using PersistenceBrokerFactoryIF.setDefaultKey(org.apache.ojb.broker.PBKey).

Specified by:
defaultPersistenceBroker in interface PersistenceBrokerFactoryIF
Throws:
PBFactoryException
See Also:
PersistenceBrokerFactoryIF.createPersistenceBroker(PBKey key)

configure

public void configure(org.apache.ojb.broker.util.configuration.Configuration config)
               throws org.apache.ojb.broker.util.configuration.ConfigurationException
Description copied from interface: org.apache.ojb.broker.util.configuration.Configurable
configure an object using the Configuration pConfig

Specified by:
configure in interface org.apache.ojb.broker.util.configuration.Configurable
Parameters:
config - the Configuration object used to configure current instance
Throws:
org.apache.ojb.broker.util.configuration.ConfigurationException

releaseAllInstances

public void releaseAllInstances()
Description copied from interface: PersistenceBrokerFactoryIF
release all broker instances pooled by the factory. each broker instance is closed before release.

Specified by:
releaseAllInstances in interface PersistenceBrokerFactoryIF
See Also:
PersistenceBrokerFactoryIF.releaseAllInstances()

activePersistenceBroker

public int activePersistenceBroker()
Not implemented!

Specified by:
activePersistenceBroker in interface PersistenceBrokerFactoryIF
Returns:
always 0

shutdown

public void shutdown()
Description copied from interface: PersistenceBrokerFactoryIF
Shutdown method for OJB, kills all running processes within OJB - after shutdown OJB can no longer be used.
This method is introduced to solve hot/redeployment problems (memory leaks) caused by the usage of ThreadLocal instances in OJB source and the reuse of threads by the container (e.g. servlet- or ejb-container).

Specified by:
shutdown in interface PersistenceBrokerFactoryIF


(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