Author: cziegeler
Date: Wed Oct 12 10:19:52 2016
New Revision: 1764430

URL: http://svn.apache.org/viewvc?rev=1764430&view=rev
Log:
SLING-6138 : Use JcrResourceListener for observation

Removed:
    
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/OakResourceListener.java
    
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/OakResourceListenerTest.java
Modified:
    sling/trunk/bundles/jcr/resource/pom.xml
    
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/api/package-info.java
    
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
    
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/package-info.java

Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=1764430&r1=1764429&r2=1764430&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Wed Oct 12 10:19:52 2016
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>26</version>
+        <version>28</version>
         <relativePath />
     </parent>
 
@@ -32,7 +32,7 @@
 
     <name>Apache Sling JCR Resource Resolver</name>
     <description>
-        This bundle provides the JCR based ResourceResolver.
+        This bundle provides the JCR based ResourceProvider.
     </description>
 
     <scm>
@@ -80,19 +80,11 @@
                 <configuration>
                     <instructions>
                         <Import-Package>
-                            javax.script.*;
-                            javax.annotation;resolution:=optional,
                             
org.apache.sling.scripting.api.*;resolution:=optional,
-                            org.apache.sling.api.resource;provide:=true,
+                            
org.apache.jackrabbit.api.observation;resolution:=optional,
                             org.apache.sling.commons.osgi;version="$(@)",
-                            !org.apache.jackrabbit.api.observation,
-                            
org.apache.jackrabbit.oak.plugins.observation;version=0.0.0;resolution:=optional,
-                            
org.apache.jackrabbit.oak.spi.commit;version=0.0.0;resolution:=optional,
                             *
                         </Import-Package>
-                        <DynamicImport-Package>
-                            org.apache.jackrabbit.api.observation
-                        </DynamicImport-Package>
 
                         <!-- Include utility classes from Jackrabbit JCR 
Commons -->
                         <Embed-Dependency>
@@ -127,20 +119,19 @@
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
-            <version>2.0</version>
         </dependency>
 
     <!-- OSGi -->
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
+            <artifactId>osgi.core</artifactId>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>4.3.0</version>
+            <artifactId>org.osgi.service.component</artifactId>
+            <version>1.3.0</version>
+            <scope>provided</scope>
         </dependency>
-
     <!-- Jackrabbit / Oak -->
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -152,7 +143,7 @@
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>oak-core</artifactId>
             <version>${oak.version}</version>
-            <scope>provided</scope>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -246,7 +237,7 @@
         <!-- For the Console Plugin of the JcrResourceResolverFactoryImpl -->
         <dependency>
             <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
+            <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
         <!-- Testing -->

Modified: 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/api/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/api/package-info.java?rev=1764430&r1=1764429&r2=1764430&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/api/package-info.java
 (original)
+++ 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/api/package-info.java
 Wed Oct 12 10:19:52 2016
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-@Version("1.0")
+@org.osgi.annotation.versioning.Version("1.0")
 package org.apache.sling.jcr.resource.api;
 
-import aQute.bnd.annotation.Version;
 

Modified: 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java?rev=1764430&r1=1764429&r2=1764430&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
 (original)
+++ 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
 Wed Oct 12 10:19:52 2016
@@ -34,7 +34,6 @@ import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Item;
 import javax.jcr.Node;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -64,30 +63,25 @@ import org.apache.sling.jcr.resource.api
 import org.apache.sling.jcr.resource.internal.JcrModifiableValueMap;
 import org.apache.sling.jcr.resource.internal.JcrResourceListener;
 import org.apache.sling.jcr.resource.internal.NodeUtil;
-import org.apache.sling.jcr.resource.internal.OakResourceListener;
 import org.apache.sling.spi.resource.provider.ProviderContext;
 import org.apache.sling.spi.resource.provider.QueryLanguageProvider;
 import org.apache.sling.spi.resource.provider.ResolveContext;
 import org.apache.sling.spi.resource.provider.ResourceContext;
 import org.apache.sling.spi.resource.provider.ResourceProvider;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Component(metatype = true,
-        label = "Apache Sling JCR Resource Provider Factory",
-        description = "This provider adds JCR resources to the resource tree",
-        
name="org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory")
+@Component(name="org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory")
 @Service(value = ResourceProvider.class)
-@Properties({ @Property(name = ResourceProvider.PROPERTY_NAME, value = "JCR", 
propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_ROOT, value = "/", 
propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_MODIFIABLE, boolValue = 
true, propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_ADAPTABLE, boolValue = 
true, propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_AUTHENTICATE, value = 
ResourceProvider.AUTHENTICATE_REQUIRED, propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_ATTRIBUTABLE, boolValue = 
true, propertyPrivate=true),
-        @Property(name = ResourceProvider.PROPERTY_REFRESHABLE, boolValue = 
true, propertyPrivate=true),
+@Properties({ @Property(name = ResourceProvider.PROPERTY_NAME, value = "JCR"),
+        @Property(name = ResourceProvider.PROPERTY_ROOT, value = "/"),
+        @Property(name = ResourceProvider.PROPERTY_MODIFIABLE, boolValue = 
true),
+        @Property(name = ResourceProvider.PROPERTY_ADAPTABLE, boolValue = 
true),
+        @Property(name = ResourceProvider.PROPERTY_AUTHENTICATE, value = 
ResourceProvider.AUTHENTICATE_REQUIRED),
+        @Property(name = ResourceProvider.PROPERTY_ATTRIBUTABLE, boolValue = 
true),
+        @Property(name = ResourceProvider.PROPERTY_REFRESHABLE, boolValue = 
true)
 })
 @Reference(name = "dynamicClassLoaderManager",
            referenceInterface = DynamicClassLoaderManager.class,
@@ -107,25 +101,12 @@ public class JcrResourceProvider extends
         IGNORED_PROPERTIES.add("jcr:createdBy");
     }
 
-    private static final boolean DEFAULT_OPTIMIZE_FOR_OAK = true;
-    @Property(boolValue=DEFAULT_OPTIMIZE_FOR_OAK,
-              label="Optimize For Oak",
-              description="If this switch is enabled, and Oak is used as the 
repository implementation, some optimized components are used.")
-    private static final String PROPERTY_OPTIMIZE_FOR_OAK = "optimize.oak";
-
-    private static final int DEFAULT_OBSERVATION_QUEUE_LENGTH = 1000;
-    @Property(
-            intValue = DEFAULT_OBSERVATION_QUEUE_LENGTH,
-            label = "Observation queue length",
-            description = "Maximum number of pending revisions in a 
observation listener queue")
-    private static final String OBSERVATION_QUEUE_LENGTH = 
"oak.observation.queue-length";
-
     @Reference(name = REPOSITORY_REFERNENCE_NAME, referenceInterface = 
SlingRepository.class)
-    private ServiceReference repositoryReference;
+    private ServiceReference<SlingRepository> repositoryReference;
 
     @Reference
     private PathMapper pathMapper;
-    
+
     @Reference
     private LoginAdminWhitelist loginAdminWhitelist;
 
@@ -138,21 +119,15 @@ public class JcrResourceProvider extends
 
     private volatile SlingRepository repository;
 
-    private int observationQueueLength;
-
-    private volatile boolean optimizeForOak;
-
     private volatile String root;
 
-    private volatile BundleContext bundleCtx;
-
     private volatile JcrProviderStateFactory stateFactory;
 
     private final AtomicReference<DynamicClassLoaderManager> 
classLoaderManagerReference = new AtomicReference<DynamicClassLoaderManager>();
 
     @Activate
     protected void activate(final ComponentContext context) throws 
RepositoryException {
-        SlingRepository repository = (SlingRepository) 
context.locateService(REPOSITORY_REFERNENCE_NAME,
+        SlingRepository repository = 
context.locateService(REPOSITORY_REFERNENCE_NAME,
                 this.repositoryReference);
         if (repository == null) {
             // concurrent unregistration of SlingRepository service
@@ -163,18 +138,14 @@ public class JcrResourceProvider extends
         }
 
         this.repository = repository;
-        this.observationQueueLength = 
PropertiesUtil.toInteger(context.getProperties().get(OBSERVATION_QUEUE_LENGTH), 
DEFAULT_OBSERVATION_QUEUE_LENGTH);
-        this.optimizeForOak = 
PropertiesUtil.toBoolean(context.getProperties().get(PROPERTY_OPTIMIZE_FOR_OAK),
 DEFAULT_OPTIMIZE_FOR_OAK);
         this.root = 
PropertiesUtil.toString(context.getProperties().get(ResourceProvider.PROPERTY_ROOT),
 "/");
-        this.bundleCtx = context.getBundleContext();
 
-        this.stateFactory = new JcrProviderStateFactory(repositoryReference, 
repository, 
+        this.stateFactory = new JcrProviderStateFactory(repositoryReference, 
repository,
                 classLoaderManagerReference, pathMapper, loginAdminWhitelist);
     }
 
     @Deactivate
     protected void deactivate() {
-        this.bundleCtx = null;
         this.stateFactory = null;
     }
 
@@ -206,13 +177,13 @@ public class JcrResourceProvider extends
     }
 
     @SuppressWarnings("unused")
-    private void bindRepository(final ServiceReference ref) {
+    private void bindRepository(final ServiceReference<SlingRepository> ref) {
         this.repositoryReference = ref;
         this.repository = null; // make sure ...
     }
 
     @SuppressWarnings("unused")
-    private void unbindRepository(final ServiceReference ref) {
+    private void unbindRepository(final ServiceReference<SlingRepository> ref) 
{
         if (this.repositoryReference == ref) {
             this.repositoryReference = null;
             this.repository = null; // make sure ...
@@ -220,33 +191,9 @@ public class JcrResourceProvider extends
     }
 
     private void registerListener(final ProviderContext ctx) {
-        // check for Oak
-        boolean isOak = false;
-        if ( optimizeForOak ) {
-            final String repoDesc = 
this.repository.getDescriptor(Repository.REP_NAME_DESC);
-            if ( repoDesc != null && repoDesc.toLowerCase().contains(" oak") ) 
{
-                if ( this.executor != null ) {
-                    isOak = true;
-                } else {
-                    logger.error("Detected Oak based repository but no 
executor service available! Unable to use improved JCR Resource listener");
-                }
-            }
-        }
         try {
-            if (isOak) {
-                try {
-                    this.listener = new OakResourceListener(root, ctx, 
bundleCtx, executor, pathMapper, observationQueueLength, repository);
-                    logger.info("Detected Oak based repository. Using improved 
JCR Resource Listener with observation queue length {}", 
observationQueueLength);
-                } catch ( final RepositoryException re ) {
-                    throw new SlingException("Can't create the 
OakResourceListener", re);
-                } catch ( final Throwable t ) {
-                    logger.error("Unable to instantiate improved JCR Resource 
listener for Oak. Using fallback.", t);
-                }
-            }
-            if (this.listener == null) {
-                this.listener = new JcrResourceListener(ctx, root, pathMapper, 
repository);
-            }
-        } catch (RepositoryException e) {
+            this.listener = new JcrResourceListener(ctx, root, pathMapper, 
repository);
+       } catch (RepositoryException e) {
             throw new SlingException("Can't create the listener", e);
         }
     }

Modified: 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/package-info.java?rev=1764430&r1=1764429&r2=1764430&view=diff
==============================================================================
--- 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/package-info.java
 (original)
+++ 
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/package-info.java
 Wed Oct 12 10:19:52 2016
@@ -17,8 +17,7 @@
  * under the License.
  */
 
-@Version("2.4")
+@org.osgi.annotation.versioning.Version("2.4")
 package org.apache.sling.jcr.resource;
 
-import aQute.bnd.annotation.Version;
 


Reply via email to