jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1394973 - in /jackrabbit/oak/trunk/oak-mongomk: ./ src/main/java/org/apache/jackrabbit/mongomk/api/ src/main/java/org/apache/jackrabbit/mongomk/api/command/ src/main/java/org/apache/jackrabbit/mongomk/api/model/ src/main/java/org/apache/ja...
Date Sat, 06 Oct 2012 08:52:22 GMT
Author: chetanm
Date: Sat Oct  6 08:52:22 2012
New Revision: 1394973

URL: http://svn.apache.org/viewvc?rev=1394973&view=rev
Log:
OAK-366 - MongoDB microkernal integration with OSGi

* Upgrading the mongo-java-driver version to 2.9.1 as it has required OSGi metadata compared
to 2.7.3 version
* Changing version of commons-coded to 1.5 as the required api is present in previous version.
With this we avoid updating the commons-codec version in various quickstarts
* Sling PropertiesUtil class is inlined to avoid dependency on Sling jars
* DBCollection class is removed as the newer version does not have final modifier which was
preventing us from creating Mocks for testing
* In addition required package-info files are added to exported packages

Added:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/package-info.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/package-info.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/package-info.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernalService.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/resources/
    jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/
    jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/
    jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/metatype.properties
Removed:
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/com/mongodb/DBCollection.java
Modified:
    jackrabbit/oak/trunk/oak-mongomk/pom.xml

Modified: jackrabbit/oak/trunk/oak-mongomk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/pom.xml?rev=1394973&r1=1394972&r2=1394973&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk/pom.xml Sat Oct  6 08:52:22 2012
@@ -32,8 +32,36 @@
 
   <artifactId>oak-mongomk</artifactId>
   <name>Oak Mongo MicroKernel</name>
+  <packaging>bundle</packaging>
 
-  <dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Private-Package>
+                            org.apache.jackrabbit.mongomk.*
+                        </Private-Package>
+                        <Export-Package>
+                            org.apache.jackrabbit.mongomk.api.*
+                        </Export-Package>
+                        <Embed-Dependency>
+                            org.apache.sling.commons.osgi;inline=org/apache/sling/commons/osgi/PropertiesUtil.class
+                        </Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
 
     <!-- OAK -->
     <dependency>
@@ -46,7 +74,7 @@
     <dependency>
       <groupId>org.mongodb</groupId>
       <artifactId>mongo-java-driver</artifactId>
-      <version>2.7.3</version>
+      <version>2.9.1</version>
     </dependency>
 
     <!-- Logging -->
@@ -65,7 +93,7 @@
     <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
-      <version>1.6</version>
+      <version>1.5</version>
     </dependency>
     <dependency>
       <groupId>org.json</groupId>
@@ -73,6 +101,37 @@
       <version>20090211</version>
     </dependency>
 
+    <dependency>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.commons.osgi</artifactId>
+        <version>2.1.0</version>
+        <optional>true</optional>
+    </dependency>
+
+    <!-- Optional OSGi dependencies, used only when running within OSGi -->
+    <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.core</artifactId>
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+    <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+    <dependency>
+        <groupId>biz.aQute</groupId>
+        <artifactId>bndlib</artifactId>
+        <scope>provided</scope>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.scr.annotations</artifactId>
+        <scope>provided</scope>
+    </dependency>
+
     <!-- Test -->
     <dependency>
       <groupId>junit</groupId>

Added: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/package-info.java?rev=1394973&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/package-info.java
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/command/package-info.java
Sat Oct  6 08:52:22 2012
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Oak repository API
+ */
+@Version("0.1")
+@Export(optional = "provide:=true")
+package org.apache.jackrabbit.mongomk.api.command;
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+

Added: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/package-info.java?rev=1394973&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/package-info.java
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/model/package-info.java
Sat Oct  6 08:52:22 2012
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Oak repository API
+ */
+@Version("0.1")
+@Export(optional = "provide:=true")
+package org.apache.jackrabbit.mongomk.api.model;
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+

Added: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/package-info.java?rev=1394973&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/package-info.java
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/api/package-info.java
Sat Oct  6 08:52:22 2012
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Oak repository API
+ */
+@Version("0.1")
+@Export(optional = "provide:=true")
+package org.apache.jackrabbit.mongomk.api;
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+

Added: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernalService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernalService.java?rev=1394973&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernalService.java
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/osgi/MongoMicroKernalService.java
Sat Oct  6 08:52:22 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.mongomk.osgi;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mongomk.impl.BlobStoreMongo;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
+import org.apache.jackrabbit.mongomk.impl.MongoMicroKernel;
+import org.apache.jackrabbit.mongomk.impl.NodeStoreMongo;
+import org.apache.jackrabbit.mongomk.util.MongoUtil;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.annotations.Deactivate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Properties;
+
+
+@Component(metatype = true,
+        label = "%oak.mongomk.label",
+        description = "%oak.mongomk.description",
+        policy = ConfigurationPolicy.REQUIRE
+)
+public class MongoMicroKernalService {
+
+    private static final String DEFAULT_HOST = "localhost";
+
+    private static final int DEFAULT_PORT= 27017;
+
+    private static final String DEFAULT_DB = "oak";
+
+
+    @Property(value = DEFAULT_HOST)
+    private static final String PROP_HOST = "host";
+
+    @Property(intValue = DEFAULT_PORT)
+    private static final String PROP_PORT = "port";
+
+    @Property(value = DEFAULT_DB)
+    private static final String PROP_DB = "db";
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private ServiceRegistration reg;
+
+    private MongoConnection connection;
+
+    @Activate
+    private void activate(BundleContext context,Map<String,?> config) throws Exception
{
+        String host = PropertiesUtil.toString(config.get(PROP_HOST), DEFAULT_HOST);
+        int port = PropertiesUtil.toInteger(config.get(PROP_PORT), DEFAULT_PORT);
+        String db = PropertiesUtil.toString(config.get(PROP_DB), DEFAULT_DB);
+
+        logger.info("Starting MongoDB MicroKernal with host={}, port={}, db={}",
+                new Object[] {host, port, db});
+        connection = new MongoConnection(host,port,db);
+
+        MongoUtil.bootstrap(connection);
+        logger.info("Connected to database {}", connection.getDB());
+
+        MongoMicroKernel mk = new MongoMicroKernel( new NodeStoreMongo(connection),new BlobStoreMongo(connection));
+
+        Properties props = new Properties();
+        props.setProperty("oak.mk.type","mongo");
+        reg = context.registerService(MicroKernel.class.getName(),mk,props);
+    }
+
+    @Deactivate
+    private void deactivate(){
+        if(reg != null){
+            reg.unregister();
+        }
+
+        if(connection != null){
+            connection.close();
+        }
+    }
+
+}

Added: jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1394973&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/metatype.properties
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/resources/OSGI-INF/metatype/metatype.properties
Sat Oct  6 08:52:22 2012
@@ -0,0 +1,31 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+oak.mongomk.label=Apache Jackrabbit Oak MongoDB MicroKernal Service
+oak.mongomk.description= Configure an instance of the MongoDB \
+  based MicroKernal implementation
+
+host.name = MongoDB Host
+host.description = The host to connect to.
+
+port.name = MongoDB Port
+port.description = The port to connect to.
+
+db.name = MongoDB Database
+db.description = The database to use.



Mime
View raw message