org.jboss.dna.repository
Class RepositoryLibrary

java.lang.Object
  extended by org.jboss.dna.repository.RepositoryLibrary
All Implemented Interfaces:
RepositoryConnectionFactory

@ThreadSafe
public class RepositoryLibrary
extends Object
implements RepositoryConnectionFactory

A library of RepositorySource instances and the RepositoryConnectionPool used to manage the connections for each.

Author:
Randall Hauch

Constructor Summary
RepositoryLibrary()
          Create a new manager instance.
RepositoryLibrary(ExecutionContext executionContext)
          Create a new manager instance.
RepositoryLibrary(ExecutionContext executionContext, RepositoryConnectionFactory delegate)
          Create a new manager instance.
RepositoryLibrary(RepositoryConnectionFactory delegate)
          Create a new manager instance.
 
Method Summary
 boolean addSource(RepositorySource source)
          Add the supplied federated source.
 RepositoryConnection createConnection(String sourceName)
          Create a RepositoryConnection using the given RepositorySource name.
 ServiceAdministrator getAdministrator()
           
 RepositoryConnectionPool getConnectionPool(String sourceName)
          Get the connection pool managing the RepositorySource with the specified name managed by this instance.
 RepositoryConnectionFactory getDelegate()
          Get the delegate connection factory.
 ExecutionContext getExecutionContext()
           
 MimeTypeDetectors getMimeTypeDetectors()
           
 RepositorySource getSource(String sourceName)
          Get the RepositorySource with the specified name managed by this instance.
 Collection<String> getSourceNames()
          Get an unmodifiable collection of RepositorySource names.
 Collection<RepositorySource> getSources()
          Get an unmodifiable collection of RepositorySource instances managed by this instance.
 boolean isTerminated()
          Return true if this federated repository has completed its termination and no longer has any open connections.
 boolean isTerminating()
          Returns true if this federated repository is in the process of terminating after ServiceAdministrator.shutdown() has been called on the administrator, but the federated repository has connections that have not yet normally been closed.
 boolean removeSource(RepositorySource source, long timeToAwait, TimeUnit unit)
          Remove from this federated repository the supplied source (or a source with the same name as that supplied).
 RepositorySource removeSource(String name, long timeToAwait, TimeUnit unit)
          Remove from this federated repository the source with the supplied name.
 void setDelegate(RepositoryConnectionFactory delegate)
          Set the delegate connection factory.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryLibrary

public RepositoryLibrary()
Create a new manager instance.


RepositoryLibrary

public RepositoryLibrary(RepositoryConnectionFactory delegate)
Create a new manager instance.

Parameters:
delegate - the connection factory to which this instance should delegate in the event that a source is not found in this manager; may be null if there is no delegate

RepositoryLibrary

public RepositoryLibrary(ExecutionContext executionContext)
Create a new manager instance.

Parameters:
executionContext - the execution context, which can be used used by sources to create other ExecutionContext instances with different JAAS security contexts
Throws:
IllegalArgumentException - if the executionContextFactory reference is null

RepositoryLibrary

public RepositoryLibrary(ExecutionContext executionContext,
                         RepositoryConnectionFactory delegate)
Create a new manager instance.

Parameters:
executionContext - the execution context, which can be used used by sources to create other ExecutionContext instances with different JAAS security contexts
delegate - the connection factory to which this instance should delegate in the event that a source is not found in this manager; may be null if there is no delegate
Throws:
IllegalArgumentException - if the executionContextFactory reference is null
Method Detail

getExecutionContext

public ExecutionContext getExecutionContext()
Returns:
executionContextFactory

getMimeTypeDetectors

public MimeTypeDetectors getMimeTypeDetectors()
Returns:
mimeTypeDetectors

getDelegate

public RepositoryConnectionFactory getDelegate()
Get the delegate connection factory.

Returns:
the connection factory to which this instance should delegate in the event that a source is not found in this manager, or null if there is no delegate

setDelegate

public void setDelegate(RepositoryConnectionFactory delegate)
Set the delegate connection factory.

Parameters:
delegate - the connection factory to which this instance should delegate in the event that a source is not found in this manager; may be null if there is no delegate

getAdministrator

public ServiceAdministrator getAdministrator()
Returns:
administrator

isTerminating

public boolean isTerminating()
Returns true if this federated repository is in the process of terminating after ServiceAdministrator.shutdown() has been called on the administrator, but the federated repository has connections that have not yet normally been closed. This method may be useful for debugging. A return of true reported a sufficient period after shutdown may indicate that connection users have ignored or suppressed interruption, causing this repository not to properly terminate.

Returns:
true if terminating but not yet terminated, or false otherwise
See Also:
isTerminated()

isTerminated

public boolean isTerminated()
Return true if this federated repository has completed its termination and no longer has any open connections.

Returns:
true if terminated, or false otherwise
See Also:
isTerminating()

getSourceNames

public Collection<String> getSourceNames()
Get an unmodifiable collection of RepositorySource names.

Returns:
the pools

getSources

public Collection<RepositorySource> getSources()
Get an unmodifiable collection of RepositorySource instances managed by this instance.

Returns:
the pools

getSource

public RepositorySource getSource(String sourceName)
Get the RepositorySource with the specified name managed by this instance.

Parameters:
sourceName - the name of the source
Returns:
the source, or null if no such source exists in this instance

getConnectionPool

public RepositoryConnectionPool getConnectionPool(String sourceName)
Get the connection pool managing the RepositorySource with the specified name managed by this instance.

Parameters:
sourceName - the name of the source
Returns:
the pool, or null if no such pool exists in this instance

addSource

public boolean addSource(RepositorySource source)
Add the supplied federated source. This method returns false if the source is null.

Parameters:
source - the source to add
Returns:
true if the source is added, or false if the reference is null or if there is already an existing source with the supplied name.

removeSource

public boolean removeSource(RepositorySource source,
                            long timeToAwait,
                            TimeUnit unit)
                     throws InterruptedException
Remove from this federated repository the supplied source (or a source with the same name as that supplied). This call shuts down the connections in the source in an orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further connections from being used.

This method can safely be called while the federation repository is in use.

Parameters:
source - the source to be removed
timeToAwait - the amount of time to wait while all of the source's connections are closed, or non-positive if the call should not wait at all
unit - the time unit to be used for timeToAwait
Returns:
true if the source was removed, or false if the source was not a source for this repository.
Throws:
InterruptedException - if the thread is interrupted while awaiting closing of the connections

removeSource

public RepositorySource removeSource(String name,
                                     long timeToAwait,
                                     TimeUnit unit)
                              throws InterruptedException
Remove from this federated repository the source with the supplied name. This call shuts down the connections in the source in an orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further connections from being used.

Parameters:
name - the name of the source to be removed
timeToAwait - the amount of time to wait while all of the source's connections are closed, or non-positive if the call should not wait at all
unit - the time unit to be used for timeToAwait
Returns:
the source with the supplied name that was removed, or null if no existing source matching the supplied name could be found
Throws:
InterruptedException - if the thread is interrupted while awaiting closing of the connections

createConnection

public RepositoryConnection createConnection(String sourceName)
Create a RepositoryConnection using the given RepositorySource name.

Specified by:
createConnection in interface RepositoryConnectionFactory
Parameters:
sourceName - the name of the source from which a connection should be obtained
Returns:
the source, or null if no such source could be found (or created)
See Also:
RepositoryConnectionFactory.createConnection(java.lang.String)


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.