|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.repository.RepositoryLibrary
@ThreadSafe public class RepositoryLibrary
A library of RepositorySource
instances and the RepositoryConnectionPool
used to manage the connections for
each.
Nested Class Summary | |
---|---|
protected class |
RepositoryLibrary.Administrator
The administrative component for this service. |
Constructor Summary | |
---|---|
RepositoryLibrary(RepositorySource configurationSource,
String configurationWorkspaceName,
Path pathToSourcesConfigurationRoot,
ExecutionContext context,
ObservationBus observationBus)
Create a new manager instance. |
Method Summary | |
---|---|
boolean |
addSource(RepositorySource source)
Add the supplied source. |
boolean |
addSource(RepositorySource source,
boolean replaceIfExisting)
Add the supplied source. |
protected boolean |
awaitTermination(long timeout,
TimeUnit unit)
Utility method called by the administrator. |
RepositoryConnection |
createConnection(String sourceName)
Create a RepositoryConnection using the given RepositorySource name. |
org.modeshape.repository.service.ServiceAdministrator |
getAdministrator()
|
protected RepositorySource |
getConfigurationSource()
|
protected String |
getConfigurationWorkspaceName()
|
RepositoryConnectionPool |
getConnectionPool(String sourceName)
Get the connection pool managing the RepositorySource with the specified name managed by this instance. |
ExecutionContext |
getExecutionContext()
|
protected Path |
getPathToConfigurationRoot()
Get the path to the top-level of the configuration root. |
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 library has completed its termination and no longer has any open connections. |
boolean |
isTerminating()
Returns true if this library is in the process of terminating after ServiceAdministrator.shutdown() has been called
on the administrator , but the library has connections that have not yet normally been
closed . |
boolean |
register(Observer observer)
Register the supplied observer. |
boolean |
removeSource(RepositorySource source,
long timeToAwait,
TimeUnit unit)
Remove from this library the supplied source (or a source with the same name as that supplied). |
RepositorySource |
removeSource(String name)
Remove from this library the source with the supplied name. |
RepositorySource |
removeSource(String name,
long timeToAwait,
TimeUnit unit)
Remove from this library the source with the supplied name. |
protected void |
shutdown()
Utility method called by the administrator. |
protected void |
start()
Utility method called by the administrator. |
boolean |
unregister(Observer observer)
Unregister the supplied observer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RepositoryLibrary(RepositorySource configurationSource, String configurationWorkspaceName, Path pathToSourcesConfigurationRoot, ExecutionContext context, ObservationBus observationBus)
configurationSource
- the RepositorySource
that is the configuration repositoryconfigurationWorkspaceName
- the name of the workspace in the RepositorySource
that is the configuration
repository, or null if the default workspace of the source should be used (if there is one)pathToSourcesConfigurationRoot
- the path of the node in the configuration source repository that should be treated by
this service as the root of the service's configurationcontext
- the execution context in which this service should runobservationBus
- the ObservationBus
instance that should be used for changes in the sources
IllegalArgumentException
- if any of the configurationSource
,
pathToSourcesConfigurationRoot
, observationBus
, or context
references are
nullMethod Detail |
---|
protected Path getPathToConfigurationRoot()
protected RepositorySource getConfigurationSource()
protected String getConfigurationWorkspaceName()
public boolean register(Observer observer)
This can be used to register observers for all of the repository sources managed by this library. The supplied observer will receive all of the changes originating from these sources.
register
in interface Observable
observer
- the observer to be added; may be null
Observable.register(org.modeshape.graph.observe.Observer)
public boolean unregister(Observer observer)
This can be used to unregister observers for all of the repository sources managed by this library.
unregister
in interface Observable
observer
- the observer to be removed; may not be null
Observable.unregister(org.modeshape.graph.observe.Observer)
public ExecutionContext getExecutionContext()
public org.modeshape.repository.service.ServiceAdministrator getAdministrator()
protected void start()
protected void shutdown()
protected boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
timeout
- unit
-
InterruptedException
public boolean isTerminating()
ServiceAdministrator.shutdown()
has been called
on the administrator
, but the library 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.
isTerminated()
public boolean isTerminated()
isTerminating()
public Collection<String> getSourceNames()
RepositorySource
names.
public Collection<RepositorySource> getSources()
RepositorySource
instances managed by this instance.
public RepositorySource getSource(String sourceName)
sourceName
- the name of the source
public RepositoryConnectionPool getConnectionPool(String sourceName)
RepositorySource
with the specified name managed by this instance.
sourceName
- the name of the source
public boolean addSource(RepositorySource source)
source
- the source to add
public boolean addSource(RepositorySource source, boolean replaceIfExisting)
If a source with the same name already exists, it will be replaced only if replaceIfExisting
is true. If this
is the case, then the existing source will be removed from the connection pool, and that pool will be
shutdown
(allowing any in-use connections to be used and finished normally).
source
- the source to addreplaceIfExisting
- true if an existing source should be replaced, or false if this method should return false if
there is already an existing source with the supplied name.
public boolean removeSource(RepositorySource source, long timeToAwait, TimeUnit unit) throws InterruptedException
This method can safely be called while the federation repository is in use.
source
- the source to be removedtimeToAwait
- 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 allunit
- the time unit to be used for timeToAwait
InterruptedException
- if the thread is interrupted while awaiting closing of the connectionspublic RepositorySource removeSource(String name)
removeSource(name,0,TimeUnit.SECONDS)
.
name
- the name of the source to be removed
removeSource(String, long, TimeUnit)
public RepositorySource removeSource(String name, long timeToAwait, TimeUnit unit) throws InterruptedException
name
- the name of the source to be removedtimeToAwait
- 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 allunit
- the time unit to be used for timeToAwait
InterruptedException
- if the thread is interrupted while awaiting closing of the connectionsremoveSource(String)
public RepositoryConnection createConnection(String sourceName)
RepositoryConnection
using the given RepositorySource
name.
createConnection
in interface RepositoryConnectionFactory
sourceName
- the name of the source from which a connection should be obtained
RepositoryConnectionFactory.createConnection(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |