ProgramixGenericLib v5.0.1

com.programix.da2
Class AggregateDASource

java.lang.Object
  extended by com.programix.da2.AggregateDASource
All Implemented Interfaces:
DASource

public class AggregateDASource
extends Object
implements DASource

Used to combine multiple DASource's into one aggregate DASource. When a DA is requested, the DASource's are queried via DASource.isAvailable(Class) in the order that they were appended and the first to return true is used.

Author:
Paul Hyde

Constructor Summary
AggregateDASource()
           
 
Method Summary
 void appendDA(GenericDA da)
          Wraps the specified GenericDA as a DASource and appends it.
 void appendSource(DASource daSource)
           
<T extends GenericDA>
T
getDA(Class<T> daInterfaceType)
          Searches for an implementation of the specified interface type.
 boolean isAvailable(Class<? extends GenericDA> daInterfaceType)
          Searches for an implementation of the specified interface type and returns true if one is available.
 void shutdown()
          This should be called when the DASource is no longer needed to clean up any potential resources being used behind the scenes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregateDASource

public AggregateDASource()
Method Detail

appendSource

public void appendSource(DASource daSource)

appendDA

public void appendDA(GenericDA da)
Wraps the specified GenericDA as a DASource and appends it.


getDA

public <T extends GenericDA> T getDA(Class<T> daInterfaceType)
                          throws DAException
Description copied from interface: DASource
Searches for an implementation of the specified interface type.

Specified by:
getDA in interface DASource
Parameters:
daInterfaceType - the interface type for which an implementation is desired.
Returns:
an implementation of the specified type.
Throws:
DAException - if either no implementation can be found or if there is trouble creating/accessing the implementation.

isAvailable

public boolean isAvailable(Class<? extends GenericDA> daInterfaceType)
                    throws DAException
Description copied from interface: DASource
Searches for an implementation of the specified interface type and returns true if one is available. If this method returns true, then calling DASource.getDA(Class) with the same parameter is virtually guaranteed to succeed (barring a communication breakdown, a call to shutdown, or similar unforeseen problems).

Specified by:
isAvailable in interface DASource
Parameters:
daInterfaceType - the interface type for which an implementation is desired.
Returns:
true if an implementation is available, false if not.
Throws:
DAException - if a determination can not be made (perhaps because of a communication error or other similar kinds of problems that prevent a definitive answer from being found).

shutdown

public void shutdown()
Description copied from interface: DASource
This should be called when the DASource is no longer needed to clean up any potential resources being used behind the scenes. Some implementations may have nothing to do when shutdown, but other implementations might have important deallocation duties to perform.

If there are any "cached" instances of GenericDA that this source is holding, those are individually shutdown by calling this method.

No other methods should be called after this method. Calling other methods after calling this method results in undefined behavior (many times, a ShutdownDAException will be thrown when attempting to invoke those other methods, but there is no requirement that all methods do this).

Calling shutdown() more than one time must be allowed and shutdown() must not complain. Also note that shutdown() never throws any exceptions—it just makes its best effort of close down everything. Implementations must assure that this remains true.

Specified by:
shutdown in interface DASource

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.