ModeShape Distribution 3.5.0.Final

org.modeshape.jcr
Class JcrRepositoryFactory

java.lang.Object
  extended by org.modeshape.jcr.JcrRepositoryFactory
All Implemented Interfaces:
RepositoryFactory, Repositories

@ThreadSafe
public class JcrRepositoryFactory
extends Object
implements RepositoryFactory

Service provider for the JCR2 RepositoryFactory interface. This class provides a single public method, getRepository(Map), that allows for a runtime link to a ModeShape JCR repository.

The canonical way to get a reference to this class is to use the ServiceLoader:

 String configUrl = ... ; // URL that points to your configuration file
 Map parameters = Collections.singletonMap(JcrRepositoryFactory.URL, configUrl);
 Repository repository;
 
 for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
     repository = factory.getRepository(parameters);
     if (repository != null) break;
 }
 
It is also possible to instantiate this class directly.
 RepositoryFactory repoFactory = new JcrRepositoryFactory();    
 String url = ... ; // URL that points to your configuration file
 Map params = Collections.singletonMap(JcrRepositoryFactory.URL, url);
 
 Repository repository = repoFactory.getRepository(params);]]>
 

Several URL formats are supported:

See Also:
getRepository(Map), RepositoryFactory.getRepository(Map)

Field Summary
 
Fields inherited from interface org.modeshape.jcr.api.RepositoryFactory
REPOSITORY_NAME, URL
 
Constructor Summary
JcrRepositoryFactory()
           
 
Method Summary
 Repository getRepository(Map parameters)
          Returns a reference to the appropriate repository for the given parameter map, if one exists.
 Repository getRepository(String repositoryName)
          Deprecated. 
 Set<String> getRepositoryNames()
          Deprecated. 
 Future<Boolean> shutdown()
          Deprecated. 
 boolean shutdown(long timeout, TimeUnit unit)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrRepositoryFactory

public JcrRepositoryFactory()
Method Detail

getRepository

public Repository getRepository(Map parameters)
                         throws RepositoryException
Returns a reference to the appropriate repository for the given parameter map, if one exists. Although the parameters map can have any number of entries, this method only considers the entry with the key JcrRepositoryFactory#URL.

The value of this key is treated as a URL with the format PROTOCOL://PATH[?repositoryName=REPOSITORY_NAME] where PROTOCOL is "jndi" or "file", PATH is the JNDI name of the ModeShapeEngine or the path to the configuration file, and REPOSITORY_NAME is the name of the repository to return if there is more than one JCR repository in the given ModeShapeEngine or configuration file.

Specified by:
getRepository in interface RepositoryFactory
Parameters:
parameters - a map of parameters to use to look up the repository; may be null
Returns:
the repository specified by the value of the entry with key RepositoryFactory.URL, or null if any of the following are true:

shutdown

@Deprecated
public Future<Boolean> shutdown()
Deprecated. 

Description copied from interface: RepositoryFactory
Shutdown this engine to stop all repositories created by calls to RepositoryFactory.getRepository(Map), terminate any ongoing background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. This method may be called multiple times, but only the first time has an effect.

Invoking this method does not preclude creating new Repository instances with future calls to RepositoryFactory.getRepository(Map). Any caller using this method as part of an application shutdown process should take care to cease invocations of RepositoryFactory.getRepository(Map) prior to invoking this method.

This method returns immediately, even before the repositories have been shut down. However, the caller can simply call the get() method on the returned Future to block until all repositories have shut down. Note that the Future.get(long, TimeUnit) method can be called to block for a maximum amount of time.

Returns:
a future that allows the caller to block until the engine is shutdown; any error during shutdown will be thrown when getting the repository from the future, where the exception is wrapped in a ExecutionException. The value returned from the future will always be true if the engine shutdown (or was not running), or false if the engine is still running.

shutdown

@Deprecated
public boolean shutdown(long timeout,
                                   TimeUnit unit)
                 throws InterruptedException
Deprecated. 

Description copied from interface: RepositoryFactory
Shutdown this engine to stop all repositories created by calls to RepositoryFactory.getRepository(Map), terminate any ongoing background operations (such as sequencing), and reclaim any resources that were acquired by the repositories. This method may be called multiple times, but only the first time has an effect.

This method is equivalent to calling "shutdown().get(timeout,unit)" on this method.

Invoking this method does not preclude creating new Repository instances with future calls to RepositoryFactory.getRepository(Map). Any caller using this method as part of an application shutdown process should take care to cease invocations of RepositoryFactory.getRepository(Map) prior to invoking this method.

This method returns immediately, even before the repositories have been shut down. However, the caller can simply call the get() method on the returned Future to block until all repositories have shut down. Note that the Future.get(long, TimeUnit) method can be called to block for a maximum amount of time.

Parameters:
timeout - the maximum time per engine to allow for shutdown
unit - the time unit of the timeout argument
Returns:
true if all engines completely shut down and false if the timeout elapsed before it was shut down completely
Throws:
InterruptedException - if interrupted while waiting

getRepository

@Deprecated
public Repository getRepository(String repositoryName)
                         throws RepositoryException
Deprecated. 

Description copied from interface: Repositories
Return the JCR Repository with the supplied name.

Specified by:
getRepository in interface Repositories
Parameters:
repositoryName - the name of the repository to return; may not be null
Returns:
the repository with the given name; never null
Throws:
RepositoryException - if no repository exists with the given name or there is an error communicating with the repository

getRepositoryNames

@Deprecated
public Set<String> getRepositoryNames()
Deprecated. 

Description copied from interface: Repositories
Get the names of the available repositories.

Specified by:
getRepositoryNames in interface Repositories
Returns:
the immutable set of repository names provided by this server; never null

ModeShape Distribution 3.5.0.Final

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