If you want a pure java config, then you can create a
RepositoryConfiguration class and use a bean method like this one;
@Bean
public Repository getRepository(String oakMongoRepositoryUri) throws
ContentException {
try {
LOG.info("setting up oak with mongodb at uri: {}",
oakMongoRepositoryUri);
MongoClientURI uri = new MongoClientURI(oakMongoRepositoryUri);
mongoClient = new MongoClient(uri);
DB db = mongoClient.getDB(oakMongoRepositoryDB);
documentNodeStore = new
DocumentMK.Builder().setMongoDB(db).getNodeStore();
NodeStore nodeStore = documentNodeStore;
LuceneIndexProvider luceneIndexProvider = new
LuceneIndexProvider();
oakRepository = new Jcr(new Oak(nodeStore))
.with(new LuceneLocalInitialContent())
.with((QueryIndexProvider) luceneIndexProvider)
.with((Observer) luceneIndexProvider)
.with(new LuceneIndexEditorProvider())
.withAsyncIndexing("async", 5)
.withFastQueryResultSize(true)
.withAtomicCounter()
.with(AggregateIndexProvider.wrap(new
LuceneIndexProvider()))
.createRepository();
return oakRepository;
} catch (Exception e) {
LOG.error("unable to configure OAK repository; ", e);
throw new ContentException("unable to configure OAK repository;
", e);
}
}
Where LuceneLocalInitialContent is a separate class that configures default
index.
On 6 April 2017 at 19:04, techie2k <[email protected]> wrote:
> Without using sling/felix, is there a way to get ContentRepository object
> for Oak(using MongoDB as document store) in spring based web application?
>
> Currently using ceateRepository, everytime I *cannot *call following code
> on
> server(Tomcat) restart:
>
> *Jcr jcr = new Jcr(new Oak(documentNodeStore)).with(
> getSecurityProvider());
> Repository repository = jcr.createRepository();*
>
> Is there any factory class available, so that I pass mongodb connection
> params and get repository object?
>
>
>
>
>
> --
> View this message in context: http://jackrabbit.510166.n4.
> nabble.com/ContentRepository-handle-tp4666696.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
--
-Tor