|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.priha.RepositoryManager
public final class RepositoryManager
This is the main API for getting yourself a Repository object, and as such, probably the only class you will need outside the basic JCR classes (unless you want to develop a RepositoryProvider, but that's a whole another story).
The simplest way of getting yourself a Priha JCR Repository is to simply call
RepositoryManager.getRepository
, which will find your "priha.properties"
file and return a ready-to-use repository. This default repository is a singleton.
Simple basic usage example which stores "some text" to the repository, and then retrieves and prints it:
Repository rep = RepositoryManager.getRepository(); Session session = rep.login(); Node nd = session.getRootNode().addNode("myfirstnode"); nd.addProperty("myfirstproperty", "some text"); session.save(); Property newp = (Property)session.getItem("/myfirstnode/myfirstproperty"); System.out.println( newp.getString() );
The workspace you get with Repository.login() depends on the configuration. It is always the first workspace defined for the first provider that is on the "priha.providers" line.
Field Summary | |
---|---|
static java.lang.String |
NS_PRIHA
The Priha Namespace. |
Method Summary | |
---|---|
static RepositoryImpl |
getRepository()
Returns a default repository object for no-pain setup. |
static RepositoryImpl |
getRepository(java.util.Properties prefs)
Returns a new repository object based on the Properties given. |
static RepositoryImpl |
getRepository(java.lang.String propertyFilename)
Returns a new repository object by locating the property file given. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String NS_PRIHA
Method Detail |
---|
public static RepositoryImpl getRepository() throws ConfigurationException
This method will search for a "priha.properties" configuration file from your classpath (and /WEB-INF/) and will use that. Failing to find one, it will use the internal defaults (from the built-in priha_default.properties), which almost certainly is not something you want - unless you just want to test Priha.
ConfigurationException
- If there is a problem with the discovered
preferences.public static RepositoryImpl getRepository(java.util.Properties prefs) throws ConfigurationException
Note that if you do get two Repositories who share the same property file, you will almost certainly hit some nasty race conditions with the repository itself. So be very, very careful.
prefs
- A Properties object containing preferences in Priha format.
ConfigurationException
- If the preferences were incorrect in some way.public static RepositoryImpl getRepository(java.lang.String propertyFilename) throws ConfigurationException
This class is somewhat lenient in how it searches the property file. It first tries the name as-is, then it tries to locate the file from the classpath root, and then it tries to search your WEB-INF library.
Note that if you do get two Repositories who share the same property file, you will almost certainly hit some nasty race conditions with the repository itself. So be very, very careful.
propertyFilename
- A name for the property file.
ConfigurationException
- If the repository cannot be configured or the
property file cannot be located.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |