org.apache.openjpa.kernel
Class DelegatingBrokerFactory

java.lang.Object
  extended by org.apache.openjpa.kernel.DelegatingBrokerFactory
All Implemented Interfaces:
Serializable, BrokerFactory, Closeable

public class DelegatingBrokerFactory
extends Object
implements BrokerFactory

Delegating broker factory that can also perform exception translation for use in facades.

Since:
0.4.0
Author:
Abe White
See Also:
Serialized Form

Constructor Summary
DelegatingBrokerFactory(BrokerFactory factory)
          Constructor; supply delegate.
DelegatingBrokerFactory(BrokerFactory factory, RuntimeExceptionTranslator trans)
          Constructor; supply delegate and exception translator.
 
Method Summary
 void addLifecycleListener(Object listener, Class[] classes)
          Register a listener for lifecycle-related events on the specified classes.
 void close()
          Close the factory.
 boolean equals(Object other)
           
 OpenJPAConfiguration getConfiguration()
          Return the configuration for this factory.
 BrokerFactory getDelegate()
          Return the direct delegate.
 BrokerFactory getInnermostDelegate()
          Return the native delegate.
 Properties getProperties()
          Return properties describing this runtime.
 Object getUserObject(Object key)
          Get the value for the specified key from the map of user objects.
 int hashCode()
           
 boolean isClosed()
          Returns true if this broker factory is closed.
 void lock()
          Synchronizes on an internal lock.
 Broker newBroker()
          Return a broker with default settings.
 Broker newBroker(String user, String pass, boolean managed, int connRetainMode, boolean findExisting)
          Return a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.
 Object putUserObject(Object key, Object val)
          Put the specified key-value pair into the map of user objects.
 void removeLifecycleListener(Object listener)
          Remove a listener for lifecycle-related events.
protected  RuntimeException translate(RuntimeException re)
          Translate the OpenJPA exception.
 void unlock()
          Release the internal lock.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingBrokerFactory

public DelegatingBrokerFactory(BrokerFactory factory)
Constructor; supply delegate.


DelegatingBrokerFactory

public DelegatingBrokerFactory(BrokerFactory factory,
                               RuntimeExceptionTranslator trans)
Constructor; supply delegate and exception translator.

Method Detail

getDelegate

public BrokerFactory getDelegate()
Return the direct delegate.


getInnermostDelegate

public BrokerFactory getInnermostDelegate()
Return the native delegate.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

translate

protected RuntimeException translate(RuntimeException re)
Translate the OpenJPA exception.


getConfiguration

public OpenJPAConfiguration getConfiguration()
Description copied from interface: BrokerFactory
Return the configuration for this factory.

Specified by:
getConfiguration in interface BrokerFactory

getProperties

public Properties getProperties()
Description copied from interface: BrokerFactory
Return properties describing this runtime.

Specified by:
getProperties in interface BrokerFactory

putUserObject

public Object putUserObject(Object key,
                            Object val)
Description copied from interface: BrokerFactory
Put the specified key-value pair into the map of user objects.

Specified by:
putUserObject in interface BrokerFactory

getUserObject

public Object getUserObject(Object key)
Description copied from interface: BrokerFactory
Get the value for the specified key from the map of user objects.

Specified by:
getUserObject in interface BrokerFactory

newBroker

public Broker newBroker()
Description copied from interface: BrokerFactory
Return a broker with default settings.

Specified by:
newBroker in interface BrokerFactory

newBroker

public Broker newBroker(String user,
                        String pass,
                        boolean managed,
                        int connRetainMode,
                        boolean findExisting)
Description copied from interface: BrokerFactory
Return a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.

Specified by:
newBroker in interface BrokerFactory

addLifecycleListener

public void addLifecycleListener(Object listener,
                                 Class[] classes)
Description copied from interface: BrokerFactory
Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener. The listener will be passed on to all new brokers.

Specified by:
addLifecycleListener in interface BrokerFactory

removeLifecycleListener

public void removeLifecycleListener(Object listener)
Description copied from interface: BrokerFactory
Remove a listener for lifecycle-related events.

Specified by:
removeLifecycleListener in interface BrokerFactory

close

public void close()
Description copied from interface: BrokerFactory
Close the factory.

Specified by:
close in interface BrokerFactory
Specified by:
close in interface Closeable

isClosed

public boolean isClosed()
Description copied from interface: BrokerFactory
Returns true if this broker factory is closed.

Specified by:
isClosed in interface BrokerFactory

lock

public void lock()
Description copied from interface: BrokerFactory
Synchronizes on an internal lock.

Specified by:
lock in interface BrokerFactory

unlock

public void unlock()
Description copied from interface: BrokerFactory
Release the internal lock.

Specified by:
unlock in interface BrokerFactory


Copyright © 2006 Apache Software Foundation. All Rights Reserved.