incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r1461975 - in /sling/whiteboard/ieb/oak: launchpad/ launchpad/src/main/resources/resources/config/ server/ server/src/main/java/org/apache/sling/oak/server/
Date Thu, 28 Mar 2013 08:15:31 GMT
Author: ieb
Date: Thu Mar 28 08:15:30 2013
New Revision: 1461975

URL: http://svn.apache.org/r1461975
Log:
SLING-2788 Repo starts Ok with only minor errors.

Modified:
    sling/whiteboard/ieb/oak/launchpad/pom.xml
    sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config
    sling/whiteboard/ieb/oak/server/pom.xml
    sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java

Modified: sling/whiteboard/ieb/oak/launchpad/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/launchpad/pom.xml?rev=1461975&r1=1461974&r2=1461975&view=diff
==============================================================================
--- sling/whiteboard/ieb/oak/launchpad/pom.xml (original)
+++ sling/whiteboard/ieb/oak/launchpad/pom.xml Thu Mar 28 08:15:30 2013
@@ -135,13 +135,6 @@
                             <version>0.0.1-SNAPSHOT</version>
                         </bundle>
                         <bundle>
-                            <groupId>org.apache.sling</groupId>
-                            <artifactId>org.apache.sling.jcr.base</artifactId>
-                            <version>2.1.3-SNAPSHOT</version>
-                        </bundle>
-                        <!-- This is embedded in oak-sling <bundle> <groupId>org.apache.jackrabbit</groupId>

-                            <artifactId>oak-jcr</artifactId> <version>0.7-SNAPSHOT</version>
</bundle> -->
-                        <bundle>
                             <groupId>org.apache.jackrabbit</groupId>
                             <artifactId>oak-core</artifactId>
                             <version>0.7-SNAPSHOT</version>
@@ -181,7 +174,11 @@
                             <artifactId>guava</artifactId>
                             <version>13.0.1</version>
                         </bundle>
-
+                        <bundle>
+                            <groupId>com.h2database</groupId>
+                            <artifactId>h2</artifactId>
+                            <version>1.3.170</version>
+                        </bundle>
                     </additionalBundles>
                 </configuration>
             </plugin>

Modified: sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config?rev=1461975&r1=1461974&r2=1461975&view=diff
==============================================================================
--- sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config
(original)
+++ sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config
Thu Mar 28 08:15:30 2013
@@ -1,2 +1,2 @@
-oak.mk.homeDir="./quickstart/repository"
-oak.mk.name="Oak"
+homeDir="./sling/repository"
+name="Oak"

Modified: sling/whiteboard/ieb/oak/server/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/pom.xml?rev=1461975&r1=1461974&r2=1461975&view=diff
==============================================================================
--- sling/whiteboard/ieb/oak/server/pom.xml (original)
+++ sling/whiteboard/ieb/oak/server/pom.xml Thu Mar 28 08:15:30 2013
@@ -88,6 +88,12 @@
             <version>0.7-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>oak-core</artifactId>
+            <version>0.7-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
         
         <dependency>
             <groupId>org.apache.sling</groupId>
@@ -104,13 +110,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.base</artifactId>
-            <version>2.1.3-SNAPSHOT</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.jcr.resource</artifactId>
-            <version>2.2.4</version>
+            <version>2.1.2</version>
             <scope>provided</scope>
         </dependency>
 

Modified: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java?rev=1461975&r1=1461974&r2=1461975&view=diff
==============================================================================
--- sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
(original)
+++ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
Thu Mar 28 08:15:30 2013
@@ -35,12 +35,26 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.jcr.osgi.OsgiRepository;
+import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.commit.JcrConflictHandler;
+import org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider;
+import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexProvider;
+import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.nodetype.DefaultTypeEditor;
+import org.apache.jackrabbit.oak.plugins.nodetype.RegistrationEditorProvider;
+import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider;
+import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
+import org.apache.jackrabbit.oak.plugins.version.VersionHook;
+import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.base.AbstractNamespaceMappingRepository;
-import org.apache.sling.jcr.resource.JcrResourceConstants;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -105,10 +119,11 @@ public class SlingRepositoryImpl extends
     private static final Logger LOGGER = LoggerFactory.getLogger(SlingRepositoryImpl.class);
 
     /**
-     * Content repository provided by Oak.
+     * micro Kernel for storing Oak content.
      */
     @Reference
-    private ContentRepository repository;
+    private MicroKernel microKernel;
+
 
     /**
      * Factory for the security provider.
@@ -129,7 +144,7 @@ public class SlingRepositoryImpl extends
     /**
      * The configured oak repository ready for use.
      */
-    private OsgiRepository oakRepository;
+    private RepositoryImpl repository;
 
     /**
      * Anon user id.
@@ -151,14 +166,6 @@ public class SlingRepositoryImpl extends
      */
     private char[] adminPassword;
 
-    /**
-     * Dummy property holding the sling folder type ensuring that the resource
-     * bundle is present. If its not present, there is a risk that on activate
-     * the standard Sling CND files wont be available to add to the repo, which
-     * (on certain Operating systems) will cause a startup order leaving the
-     * repo in an invalid state. Putting the property here
-     */
-    private String slingFolderType;
 
     /**
      * @param componentContext component context.
@@ -175,19 +182,45 @@ public class SlingRepositoryImpl extends
             DEFAULT_ADMIN_USER);
         adminPassword = getProperty(properties, PROPERTY_ADMIN_PASS,
             DEFAULT_ADMIN_PASS).toCharArray();
+        repository = getRespository();
+        LOGGER.info("Calling Setup ");
+        super.setup(componentContext.getBundleContext());
+        LOGGER.info("Done Setup Repository ready ======================== ");
+    }
+
+    /**
+     * @return a newly constructed repository.
+     */
+    private RepositoryImpl getRespository() {
         securityProvider = securityProviderFactory.getSecurityProvider();
         executor = Executors.newScheduledThreadPool(1);
-        oakRepository = new OsgiRepository(repository, executor,
+        return new RepositoryImpl(getContentRepository(), executor,
             securityProvider);
-        // This import ensures that the resource bundle containing the node
-        // types is present
-        // before this component starts up. It may be unnecessary, but this
-        // ensures its there.
-        slingFolderType = JcrResourceConstants.NT_SLING_FOLDER;
-        LOGGER.debug(
-            "Bound sucessfully to jcr resource bundle, Sling Folder type is {} ",
-            slingFolderType);
-        super.setup(componentContext.getBundleContext());
+    }
+
+    /**
+     * @return creates a new Oak repository suitable for Jcr (see Jcr class)
+     */
+    private ContentRepository getContentRepository() {
+        if (microKernel == null) {
+            throw new IllegalStateException("Cant start without a micro kernel");
+        }
+        LOGGER.info("Creating Oak Content repository using micro Kernel {} ", microKernel.getClass());
+        return new Oak(microKernel)
+                .with(new InitialContent())
+                .with(JcrConflictHandler.JCR_CONFLICT_HANDLER)
+                .with(new DefaultTypeEditor())
+                .with(new VersionHook())
+                .with(new SecurityProviderImpl())
+                .with(new NameValidatorProvider())
+                .with(new NamespaceValidatorProvider())
+                .with(new TypeEditorProvider())
+                .with(new RegistrationEditorProvider())
+                .with(new ConflictValidatorProvider())
+                .with(new Property2IndexHookProvider())
+                .with(new Property2IndexProvider())
+                .with(new NodeTypeIndexProvider())
+                .createContentRepository();
     }
 
     /**
@@ -217,7 +250,7 @@ public class SlingRepositoryImpl extends
     @Deactivate
     public void deactivate(ComponentContext componentContext) {
         super.tearDown();
-        oakRepository = null;
+        repository = null;
         securityProvider = null;
         executor.shutdown();
         executor = null;
@@ -225,20 +258,29 @@ public class SlingRepositoryImpl extends
 
     @Override
     public String[] getDescriptorKeys() {
-        return oakRepository.getDescriptorKeys();
+        return repository.getDescriptorKeys();
     }
 
     @Override
     public String getDescriptor(String key) {
-        return oakRepository.getDescriptor(key);
+        return repository.getDescriptor(key);
     }
 
     @Override
     public Session login(Credentials credentials, String workspaceName)
             throws LoginException, NoSuchWorkspaceException,
             RepositoryException {
-        return getNamespaceAwareSession(oakRepository.login(credentials,
-            workspaceName));
+        // block taken from OsgiRepository.
+        // TODO: The context class loader hack below shouldn't be needed
+        // with a properly OSGi-compatible JAAS implementation
+        Thread thread = Thread.currentThread();
+        ClassLoader loader = thread.getContextClassLoader();
+        try {
+            thread.setContextClassLoader(Oak.class.getClassLoader());
+            return getNamespaceAwareSession(repository.login(credentials, workspaceName));
+        } finally {
+            thread.setContextClassLoader(loader);
+        }
     }
 
     @Override



Mime
View raw message