Hi,

better documentation is always welcome.

For those using a spring environment, it would be nice if there was a
version of the oak-lucene module that used jar shading to avoid
leaking the embedded lucene 4.7 classes causing potential conflicts
with other lucene versions which might be required in a project.


On 18 August 2015 at 22:22, Chetan Mehrotra <[email protected]> wrote:
> Hi,
>
> Off late I have seen quite a few queries from people trying to use Oak
> in non OSGi environment like embedding repository in a webapp deployed
> on Tomcat or just in standalone application. Our current documented
> way [1] is very limited and repository constructed in such a way does
> not expose the full power of Oak stack and user also has to know many
> internal setup details of Oak to get it working correctly.
>
> Quite a bit of setup logic in Oak is now dependent on OSGi
> configuration. Trying to setup Oak without using those would not
> provide a stable and performant setup. Instead of that if we can have
> a way to reuse all the OSGi based setup support and still enable users
> to use Oak in non OSGi env then that would provide a more stable setup
> approach.
>
> Recipe
> ======
>
> For past sometime I have been working on oak-pojosr module [2]. This
> module can now stable and can be used to setup Oak with all the OSGi
> support in a non OSGi world like webapp. For an end user the steps
> required would be
>
> 1. Create a config file for enabling various parts of Oak
>
> {
> "org.apache.felix.jaas.Configuration.factory-LoginModuleImpl": {
>     "jaas.controlFlag": "required",
>     "jaas.classname":
> "org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl",
>     "jaas.ranking": 100
> },
> ...,
> "org.apache.jackrabbit.oak.jcr.osgi.RepositoryManager": {},
> "org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService" : {
>     "mongouri" : "mongodb://${mongodb.host}:${mongodb.port}",
>     "db" : "${mongodb.name}"
> }
> }
>
> 2. Add dependency to oak-pojosr and thus include various transitive
> dependencies like Felix Connect, SCR, ConfigAdmin etc
>
> 3. Construct a repository instance
>
> import org.apache.jackrabbit.commons.JcrUtils;
>
> Map<String,String> config = new HashMap<String, String>();
> config.put("org.apache.jackrabbit.repository.home", "/path/to/repo");
> config.put("org.apache.jackrabbit.oak.repository.configFile",
>     "/path/to/oak-config.json");
>
> Repository repository = JcrUtils.getRepository(config);
>
> Thats all! This would construct a full stack Oak based on OSGi config
> with all Lucene, Solr support usable.
>
> Examples
> ========
>
> WebApp
> ------------
>
> I have adapted the existing Jackrabbit Webapp module to work with Oak
> and be constructed based on oak-pojor [3]. You can check out the app
> and just run
>
>> mvn jetty:run
>
> Access the webui at http://localhost:8080 and create a repository as
> per UI. It currently has following features
>
> 1. Repository is configurable via a JSON file copies to 'oak' folder (default)
>
> 2. Felix WebConsole is integrated - Allows developer to view OSGi
> state and config etc
>     Check /osgi/system/console
>
> 3. Felix Script Console integrated to get programatic access to repository
>
> 4. All Oak MBean registered and can be used by user to perform
> maintainence tasks
>
> Spring Boot
> ----------------
>
> Clay has been working a Oak based application [4] which uses Spring
> Boot [7]. The fork of the same at [5] is now using pojosr to configure
> a repository to be used in Spring [6]. In addition again Felix
> WebConsole etc would also work
>
> To try it out checkout the application and build it. Then run following 
> command
>
>> java -jar target/com.meta64.mobile-0.0.1-SNAPSHOT.jar --jcrHome=oak 
>> --jcrAdminPassword=password --aeskey=password --server.port=8990 
>> --spring.config.location=classpath:/application.properties,classpath:/application-dev.properties
>
> And then access the app at 8990 port
>
> Proposal
> =======
>
> Do share your feedback around above proposed approach. In particular
> following aspect
>
> Q - Should we make oak-pojosr based setup as one of the
> recommended/supported approach for configuring Oak in non OSGi env
>
> Chetan Mehrotra
> [1] http://jackrabbit.apache.org/oak/docs/construct.html
> [2] https://github.com/apache/jackrabbit-oak/tree/trunk/oak-pojosr
> [3] https://github.com/apache/jackrabbit-oak/tree/trunk/oak-examples/webapp
> [4] https://github.com/Clay-Ferguson/meta64
> [5] https://github.com/chetanmeh/meta64/tree/oak-pojosr
> [6] 
> https://github.com/chetanmeh/meta64/blob/oak-pojosr/src/main/java/com/meta64/mobile/repo/OakRepository.java#L218
> [7] http://projects.spring.io/spring-boot/



-- 
-Tor

Reply via email to