A javax.jcr.Repository
object can be obtained by:
Using the eXo Container "native" mechanism. All repositories
are kept with a single RepositoryService
component. So it can be
obtained from eXo Container as described below:
RepositoryService repositoryService = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class);
Repository repository = repositoryService.getRepository("repository");
Using the eXo Container "native" mechanism with a thread local saved "current" repository (especially if you plan to use a single repository which covers more than 90% of usecases).
// set current repository at initial time
RepositoryService repositoryService = (RepositoryService) container.getComponentInstanceOfType(RepositoryService.class);
repositoryService.setCurrentRepositoryName("repository");
....
// retrieve and use this repository
Repository repository = repositoryService.getCurrentRepository();
Using JNDI as specified in JSR-170. You should use this way to configure the reference as follows.(See eXo JNDI Naming configuration).
Context ctx = new InitialContext();
Repository repository =(Repository) ctx.lookup("repository");