JCR Configuration
SeedStack JCR add-on supports any JCR-compliant Repository Content to allow your application to interface with a repository content.
Dependencies
<dependency>
<groupId>org.seedstack.addons.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
Show version
dependencies {
compile("org.seedstack.addons.jcr:jcr:LATEST_VERSION_HERE")
}
Jackrabbit is the de-facto JCR implementation. When using Hibernate, SeedStack is able to stream results from the database without putting them all in memory (useful when retrieving for result sets).
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>LATEST_VERSION_HERE</version>
</dependency>
dependencies {
compile("org.apache.jackrabbit:jackrabbit-core:LATEST_VERSION_HERE")
}
Configuration
SeedStack is able to automatically detect the JPA classes in your project, without persistence.xml
file. You just have
to declare the JPA units:
jcr:
# Configured JCR repositories with the name of the JCR repository as key.
repositories:
myRepository:
# Type of JCR Connection
type: (JNDI_NAME|JNDI_URI|LOCAL_PATH|REMOTE_URI)
# Address to the JCR Server, it could be a local path, a remote server, or a JNDI Resource (Type must match the url)
address: (String)
# JCR Username
username: (String)
# JCR Password
password: (String)
# The fully qualified class name of the jcr factory (Optional)
repositoryFactory: (Class<? extends JcrFactory>)
# The Provider Properties
vendorProperties:
prop1: value
# Default repository to use when not specified
defaultRepository: (String)
To dump the jcr
configuration options:
mvn -q -Dargs="jcr" seedstack:config
Usage
To use the Entity Manager directly, simply inject it:
import javax.jcr.Session;
public class MyService {
@Inject
private Session myJcrSession;
@WithContentRepository
@Named("myRepository") // Optional if default repository is specified
public void doSomethingWithMyJcrRepository() {
// do something
}
}
All JCR Interactions should happen within the limits of a @WithContentRepository. Also, Sessions are automatically managed by the stack, there’s no need to close them.