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 configurations, and provides the logic of interacting with those connectionFactory and presenting a single unified graph.

Author:
Randall Hauch

Constructor Summary
FederatedRepository(String repositoryName, ExecutionContext context, RepositoryConnectionFactory connectionFactory, Iterable<FederatedWorkspace> workspaces)
          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.
 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
 Map<String,FederatedWorkspace> getWorkspaceConfigurations()
          Get the configuration of this repository's workspaces.
 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 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(String repositoryName,
                           ExecutionContext context,
                           RepositoryConnectionFactory connectionFactory,
                           Iterable<FederatedWorkspace> workspaces)
Create a federated repository instance.

Parameters:
repositoryName - the name of the repository
context - the execution context
connectionFactory - the factory for RepositoryConnection instances that should be used
workspaces - the workspace configurations for this repository, with the default workspace being first; may not be null
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

getWorkspaceConfigurations

public Map<String,FederatedWorkspace> getWorkspaceConfigurations()
Get the configuration of this repository's workspaces. This set of configurations (as well as each configuration) is immutable. 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 worksapce configuration at the time this method is called.


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