org.jboss.dna.connector.federation
Class FederatedRepository

java.lang.Object
  extended by org.jboss.dna.connector.federation.FederatedRepository

@ThreadSafe
public class FederatedRepository
extends Object

The component that represents a single federated repository. The federated repository uses a set of federated connectionFactory as designated by name through the configuration, and provides the logic of interacting with those connectionFactory and presenting a single unified graph.

Author:
Randall Hauch

Constructor Summary
FederatedRepository(ExecutionContext context, RepositoryConnectionFactory connectionFactory, FederatedRepositoryConfig config)
          Create a federated repository instance.
 
Method Summary
 boolean addListener(RepositorySourceListener listener)
          Add a listener that is to receive notifications to changes to content within this repository.
 boolean awaitTermination(long timeout, TimeUnit unit)
          Utility method called by the administrator.
 RepositoryConnection createConnection(RepositorySource source, String username, Object credentials)
          Authenticate the supplied username with the supplied credentials, and return whether authentication was successful.
 FederatedRepositoryConfig getConfiguration()
          Get the configuration of this repository.
 ExecutionContext getExecutionContext()
           
 List<RepositorySourceListener> getListeners()
          Get the list of listeners, which is the actual list used by the repository.
 String getName()
          Get the name of this repository
 boolean isRunning()
          Return true if this federated repository is running and ready for connections.
 boolean isTerminated()
          Return true if this federated repository has completed its termination and no longer has any open connections.
 boolean removeListener(RepositorySourceListener listener)
          Remove the supplied listener.
 void setConfiguration(FederatedRepositoryConfig config)
          Set the configuration for this repository.
 void shutdown()
          Utility method called by the administrator.
 void start()
          Utility method called by the administrator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FederatedRepository

public FederatedRepository(ExecutionContext context,
                           RepositoryConnectionFactory connectionFactory,
                           FederatedRepositoryConfig config)
Create a federated repository instance.

Parameters:
context - the execution context
connectionFactory - the factory for RepositoryConnection instances that should be used
config - the configuration for this repository
Throws:
IllegalArgumentException - if any of the parameters are null, or if the name is blank
Method Detail

getName

public String getName()
Get the name of this repository

Returns:
name

getExecutionContext

public ExecutionContext getExecutionContext()
Returns:
the execution context

start

public void start()
Utility method called by the administrator.


isRunning

public boolean isRunning()
Return true if this federated repository is running and ready for connections.

Returns:
true if running, or false otherwise

shutdown

public void shutdown()
Utility method called by the administrator.


awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Utility method called by the administrator.

Parameters:
timeout -
unit -
Returns:
true if all connections open at the time this method is called were closed in the supplied time, or false if the timeout occurred before all the connections were closed
Throws:
InterruptedException

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

addListener

public boolean addListener(RepositorySourceListener listener)
Add a listener that is to receive notifications to changes to content within this repository. This method does nothing if the supplied listener is null.

Parameters:
listener - the new listener
Returns:
true if the listener was added, or false if the listener was not added (if reference is null, or if non-null listener is already an existing listener)

removeListener

public boolean removeListener(RepositorySourceListener listener)
Remove the supplied listener. This method does nothing if the supplied listener is null.

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

Parameters:
listener - the listener to remove
Returns:
true if the listener was removed, or false if the listener was not registered

getListeners

public List<RepositorySourceListener> getListeners()
Get the list of listeners, which is the actual list used by the repository.

Returns:
the listeners

createConnection

public RepositoryConnection createConnection(RepositorySource source,
                                             String username,
                                             Object credentials)
Authenticate the supplied username with the supplied credentials, and return whether authentication was successful.

Parameters:
source - the RepositorySource that should be affiliated with the resulting connection
username - the username
credentials - the credentials
Returns:
the repository connection if authentication succeeded, or null otherwise

getConfiguration

public FederatedRepositoryConfig getConfiguration()
Get the configuration of this repository. This configuration is immutable and may be changed as needed. Therefore, when using a configuration and needing a consistent configuration, maintain a reference to the configuration during that time (as the actual configuration may be replaced at any time).

Returns:
the repository's configuration at the time this method is called.

setConfiguration

public void setConfiguration(FederatedRepositoryConfig config)
Set the configuration for this repository. The configuration is immutable and therefore may be replaced using this method. All interaction with the configuration is done in a thread-safe and concurrent manner, and as such only valid configurations should be used.

Parameters:
config - the new configuration
Throws:
IllegalArgumentException - if the configuration is null


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