incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1164020 - in /sling/trunk/bundles/jcr/webdav: ./ src/main/java/org/apache/sling/jcr/webdav/impl/handler/ src/main/java/org/apache/sling/jcr/webdav/impl/helper/ src/main/java/org/apache/sling/jcr/webdav/impl/servlets/ src/main/resources/OSG...
Date Thu, 01 Sep 2011 11:33:32 GMT
Author: fmeschbe
Date: Thu Sep  1 11:33:31 2011
New Revision: 1164020

URL: http://svn.apache.org/viewvc?rev=1164020&view=rev
Log:
SLING-2185 Support IOHandler and PropertyHandler services to extend the Jackrabbit WebDAV
functionality (thanks Timothee Maret for the patch)

Added:
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
  (with props)
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
  (with props)
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
  (with props)
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
  (with props)
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
  (with props)
Modified:
    sling/trunk/bundles/jcr/webdav/pom.xml
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
    sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
    sling/trunk/bundles/jcr/webdav/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/bundles/jcr/webdav/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/pom.xml?rev=1164020&r1=1164019&r2=1164020&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/pom.xml (original)
+++ sling/trunk/bundles/jcr/webdav/pom.xml Thu Sep  1 11:33:31 2011
@@ -55,6 +55,11 @@
                 <configuration>
                     <instructions>
                         <Bundle-Category>sling,jcr</Bundle-Category>
+                        <_exportcontents>
+                            org.apache.jackrabbit.server.io; version=2.3,
+                            org.apache.jackrabbit.webdav;
+                            org.apache.jackrabbit.webdav.property; version=2.3
+                        </_exportcontents>
                         <Private-Package>
                             org.apache.sling.jcr.webdav.impl.*
                         </Private-Package>
@@ -74,7 +79,6 @@
                         <Embed-Dependency>
                             jackrabbit-jcr-server,
                             jackrabbit-webdav,
-                            xercesImpl,
                             jackrabbit-jcr-commons
                         </Embed-Dependency>
                         <Embed-Transitive>true</Embed-Transitive>
@@ -117,7 +121,7 @@
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr-server</artifactId>
-            <version>2.2.5</version>
+            <version>2.3-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
 
@@ -138,6 +142,10 @@
 
         <!-- OSGi Libraries -->
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java?rev=1164020&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
Thu Sep  1 11:33:31 2011
@@ -0,0 +1,152 @@
+/*
+ * 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.sling.jcr.webdav.impl.handler;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Modified;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.server.io.DefaultHandler;
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.server.io.PropertyExportContext;
+import org.apache.jackrabbit.server.io.PropertyHandler;
+import org.apache.jackrabbit.server.io.PropertyImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.property.PropEntry;
+import org.apache.sling.commons.osgi.OsgiUtil;
+import org.apache.sling.jcr.webdav.impl.servlets.SlingWebDavServlet;
+import org.osgi.framework.Constants;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Wraps {@link org.apache.jackrabbit.server.io.DefaultHandler} in order to run
+ * it as a service.
+ */
+@Component(metatype = true, label = "%defaulthandler.name", description = "%defaulthandler.description")
+@Properties({
+    @Property(name = Constants.SERVICE_RANKING, intValue = 1000, propertyPrivate = false),
+    @Property(name = SlingWebDavServlet.TYPE_COLLECTIONS, value = SlingWebDavServlet.TYPE_COLLECTIONS_DEFAULT,
propertyPrivate = false),
+    @Property(name = SlingWebDavServlet.TYPE_NONCOLLECTIONS, value = SlingWebDavServlet.TYPE_NONCOLLECTIONS_DEFAULT,
propertyPrivate = false),
+    @Property(name = SlingWebDavServlet.TYPE_CONTENT, value = SlingWebDavServlet.TYPE_CONTENT_DEFAULT,
propertyPrivate = false) })
+@Service
+public class DefaultHandlerService implements IOHandler, PropertyHandler {
+
+    private DefaultHandler delegatee;
+
+    @Activate
+    @Modified
+    @SuppressWarnings("unused")
+    private void activate(final Map<String, Object> properties) {
+        final String collectionType = OsgiUtil.toString(
+            properties.get(SlingWebDavServlet.TYPE_COLLECTIONS),
+            SlingWebDavServlet.TYPE_COLLECTIONS_DEFAULT);
+        final String nonCollectionType = OsgiUtil.toString(
+            properties.get(SlingWebDavServlet.TYPE_NONCOLLECTIONS),
+            SlingWebDavServlet.TYPE_NONCOLLECTIONS_DEFAULT);
+        final String contentType = OsgiUtil.toString(
+            properties.get(SlingWebDavServlet.TYPE_CONTENT),
+            SlingWebDavServlet.TYPE_CONTENT_DEFAULT);
+
+        this.delegatee = new DefaultHandler(null, collectionType,
+            nonCollectionType, contentType);
+    }
+
+    @Deactivate
+    @SuppressWarnings("unused")
+    private void deactivate() {
+        this.delegatee = null;
+    }
+
+    public IOManager getIOManager() {
+        return delegatee.getIOManager();
+    }
+
+    public void setIOManager(IOManager ioManager) {
+        delegatee.setIOManager(ioManager);
+    }
+
+    public String getName() {
+        return delegatee.getName();
+    }
+
+    public boolean canImport(ImportContext context, boolean isCollection) {
+        return delegatee.canImport(context, isCollection);
+    }
+
+    public boolean canImport(ImportContext context, DavResource resource) {
+        return delegatee.canImport(context, resource);
+    }
+
+    public boolean importContent(ImportContext context, boolean isCollection)
+            throws IOException {
+        return delegatee.importContent(context, isCollection);
+    }
+
+    public boolean importContent(ImportContext context, DavResource resource)
+            throws IOException {
+        return delegatee.importContent(context, resource);
+    }
+
+    public boolean canExport(ExportContext context, boolean isCollection) {
+        return delegatee.canExport(context, isCollection);
+    }
+
+    public boolean canExport(ExportContext context, DavResource resource) {
+        return delegatee.canExport(context, resource);
+    }
+
+    public boolean exportContent(ExportContext context, boolean isCollection)
+            throws IOException {
+        return delegatee.exportContent(context, isCollection);
+    }
+
+    public boolean exportContent(ExportContext context, DavResource resource)
+            throws IOException {
+        return delegatee.exportContent(context, resource);
+    }
+
+    public boolean canExport(PropertyExportContext context, boolean isCollection) {
+        return delegatee.canExport(context, isCollection);
+    }
+
+    public boolean exportProperties(PropertyExportContext exportContext,
+            boolean isCollection) throws RepositoryException {
+        return delegatee.exportProperties(exportContext, isCollection);
+    }
+
+    public boolean canImport(PropertyImportContext context, boolean isCollection) {
+        return delegatee.canImport(context, isCollection);
+    }
+
+    public Map<? extends PropEntry, ?> importProperties(
+            PropertyImportContext importContext, boolean isCollection)
+            throws RepositoryException {
+        return delegatee.importProperties(importContext, isCollection);
+    }
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DefaultHandlerService.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java?rev=1164020&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
Thu Sep  1 11:33:31 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.sling.jcr.webdav.impl.handler;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.server.io.DirListingExportHandler;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.PropertyHandler;
+import org.osgi.framework.Constants;
+
+/**
+ * Wraps {@link org.apache.jackrabbit.server.io.DirListingExportHandler} in order to run
it as a service.
+ */
+@Component(metatype = true, label = "%dirlistingexporthandler.name", description = "%dirlistingexporthandler.description")
+@Property(name = Constants.SERVICE_RANKING, intValue = 100, propertyPrivate = false)
+@Service(value = {IOHandler.class, PropertyHandler.class})
+public class DirListingExportHandlerService extends DirListingExportHandler {
+
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/DirListingExportHandlerService.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java?rev=1164020&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
Thu Sep  1 11:33:31 2011
@@ -0,0 +1,93 @@
+/*
+ * 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.sling.jcr.webdav.impl.handler;
+
+import java.util.ArrayList;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * IOManager service that uses a ServiceTracker to find available IOHandlers.
+ */
+public class SlingHandlerManager<ManagedType> {
+
+    private final TreeMap<ServiceReference, ManagedType> handlerServices = new TreeMap<ServiceReference,
ManagedType>();
+
+    private ComponentContext componentContext;
+
+    private final String referenceName;
+
+    private ManagedType[] handlers;
+
+    protected SlingHandlerManager(final String referenceName) {
+        this.referenceName = referenceName;
+    }
+
+    public void setComponentContext(ComponentContext componentContext) {
+        this.componentContext = componentContext;
+    }
+
+    @SuppressWarnings("unchecked")
+    protected ManagedType[] getHandlers(ManagedType[] type) {
+        if (this.handlers == null) {
+
+            final Set<Entry<ServiceReference, ManagedType>> entries;
+            synchronized (this.handlerServices) {
+                entries = this.handlerServices.entrySet();
+            }
+
+            final ArrayList<ManagedType> ioHandlers = new ArrayList<ManagedType>(
+                entries.size());
+            for (Entry<ServiceReference, ManagedType> entry : entries) {
+                final ManagedType ioHandler;
+                if (entry.getValue() == null) {
+                    // unckecked cast
+                    ioHandler = (ManagedType) this.componentContext.locateService(
+                        referenceName, entry.getKey());
+                    entry.setValue(ioHandler);
+                } else {
+                    ioHandler = entry.getValue();
+                }
+                ioHandlers.add(ioHandler);
+            }
+
+            // unckecked cast
+            this.handlers = ioHandlers.toArray(type);
+        }
+        return this.handlers;
+    }
+
+    protected void bindHandler(final ServiceReference ref) {
+        synchronized (this.handlerServices) {
+            this.handlerServices.put(ref, null);
+            this.handlers = null;
+        }
+    }
+
+    protected void unbindHandler(final ServiceReference ref) {
+        synchronized (this.handlerServices) {
+            this.handlerServices.remove(ref);
+            this.handlers = null;
+        }
+    }
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingHandlerManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java?rev=1164020&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
Thu Sep  1 11:33:31 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.sling.jcr.webdav.impl.handler;
+
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManagerImpl;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * IOManager service that uses a ServiceTracker to find available IOHandlers.
+ */
+public class SlingIOManager extends IOManagerImpl {
+
+    private static final IOHandler[] IOHANDLERS_PROTOTYPE = new IOHandler[0];
+
+    private final SlingHandlerManager<IOHandler> handlerManager;
+
+    public SlingIOManager(final String referenceName) {
+        handlerManager = new SlingHandlerManager<IOHandler>(referenceName);
+    }
+
+    @Override
+    public void addIOHandler(IOHandler ioHandler) {
+        throw new UnsupportedOperationException(
+            "This IOManager only supports registered IOHandler services");
+    }
+
+    @Override
+    public IOHandler[] getIOHandlers() {
+        return this.handlerManager.getHandlers(IOHANDLERS_PROTOTYPE);
+    }
+
+    public void setComponentContext(ComponentContext componentContext) {
+        this.handlerManager.setComponentContext(componentContext);
+    }
+
+    public void bindIOHandler(final ServiceReference ioHandlerReference) {
+        this.handlerManager.bindHandler(ioHandlerReference);
+    }
+
+    public void unbindIOHandler(final ServiceReference ioHandlerReference) {
+        this.handlerManager.unbindHandler(ioHandlerReference);
+    }
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingIOManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java?rev=1164020&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
(added)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
Thu Sep  1 11:33:31 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.sling.jcr.webdav.impl.handler;
+
+import org.apache.jackrabbit.server.io.PropertyHandler;
+import org.apache.jackrabbit.server.io.PropertyManagerImpl;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * PropertyManager service that uses a ServiceTracker to find available
+ * PropertyHandler.
+ */
+public class SlingPropertyManager extends PropertyManagerImpl {
+
+    private static final PropertyHandler[] PROPERTYHANDLERS_PROTOTYPE = new PropertyHandler[0];
+
+    private final SlingHandlerManager<PropertyHandler> handlerManager;
+
+    public SlingPropertyManager(final String referenceName) {
+        handlerManager = new SlingHandlerManager<PropertyHandler>(referenceName);
+    }
+
+    @Override
+    public void addPropertyHandler(PropertyHandler propertyHandler) {
+        throw new UnsupportedOperationException(
+            "This PropertyManager only supports registered PropertyHandler services");
+    }
+
+    @Override
+    public PropertyHandler[] getPropertyHandlers() {
+        return this.handlerManager.getHandlers(PROPERTYHANDLERS_PROTOTYPE);
+    }
+
+    public void setComponentContext(ComponentContext componentContext) {
+        this.handlerManager.setComponentContext(componentContext);
+    }
+
+    public void bindPropertyHandler(final ServiceReference propertyHandlerReference) {
+        this.handlerManager.bindHandler(propertyHandlerReference);
+    }
+
+    public void unbindPropertyHandler(final ServiceReference propertyHandlerReference) {
+        this.handlerManager.unbindHandler(propertyHandlerReference);
+    }
+}

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/handler/SlingPropertyManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java?rev=1164020&r1=1164019&r2=1164020&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/helper/SlingResourceConfig.java
Thu Sep  1 11:33:31 2011
@@ -18,20 +18,8 @@
  */
 package org.apache.sling.jcr.webdav.impl.helper;
 
-import java.net.URL;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.server.io.DefaultHandler;
-import org.apache.jackrabbit.server.io.DirListingExportHandler;
 import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.server.io.IOManagerImpl;
 import org.apache.jackrabbit.server.io.PropertyManager;
-import org.apache.jackrabbit.server.io.PropertyManagerImpl;
 import org.apache.jackrabbit.webdav.simple.DefaultItemFilter;
 import org.apache.jackrabbit.webdav.simple.ItemFilter;
 import org.apache.jackrabbit.webdav.simple.ResourceConfig;
@@ -40,6 +28,13 @@ import org.apache.sling.commons.mime.Mim
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.jcr.webdav.impl.servlets.SlingWebDavServlet;
 
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
 public class SlingResourceConfig extends ResourceConfig {
 
     private final String[] collectionTypes;
@@ -55,8 +50,12 @@ public class SlingResourceConfig extends
     private final Dictionary<String, String> servletInitParams;
 
     public SlingResourceConfig(MimeTypeService mimeTypeService,
-            Dictionary<?, ?> config) {
+            Dictionary<?, ?> config,
+            IOManager ioManager,
+            PropertyManager propertyManager) {
         super(new SlingTikaDetector(mimeTypeService));
+        this.ioManager = ioManager;
+        this.propertyManager = propertyManager;
         collectionTypes = OsgiUtil.toStringArray(
             config.get(SlingWebDavServlet.COLLECTION_TYPES),
             SlingWebDavServlet.COLLECTION_TYPES_DEFAULT);
@@ -76,29 +75,6 @@ public class SlingResourceConfig extends
         itemFilter.setFilteredURIs(filterURIs);
         itemFilter.setFilteredNodetypes(filterNodeTypes);
 
-        String collectionType = OsgiUtil.toString(
-            config.get(SlingWebDavServlet.TYPE_COLLECTIONS),
-            SlingWebDavServlet.TYPE_COLLECTIONS_DEFAULT);
-        String nonCollectionType = OsgiUtil.toString(
-            config.get(SlingWebDavServlet.TYPE_NONCOLLECTIONS),
-            SlingWebDavServlet.TYPE_NONCOLLECTIONS_DEFAULT);
-        String contentType = OsgiUtil.toString(
-            config.get(SlingWebDavServlet.TYPE_CONTENT),
-            SlingWebDavServlet.TYPE_CONTENT_DEFAULT);
-
-        // share these handlers between the IOManager and the PropertyManager
-        DirListingExportHandler dirHandler = new DirListingExportHandler();
-        DefaultHandler defaultHandler = new DefaultHandler(null, collectionType,
-            nonCollectionType, contentType);
-
-        ioManager = new IOManagerImpl();
-        ioManager.addIOHandler(dirHandler);
-        ioManager.addIOHandler(defaultHandler);
-
-        propertyManager = new PropertyManagerImpl();
-        propertyManager.addPropertyHandler(dirHandler);
-        propertyManager.addPropertyHandler(defaultHandler);
-
         servletContextPath = OsgiUtil.toString(
             config.get(SlingWebDavServlet.PROP_CONTEXT),
             SlingWebDavServlet.DEFAULT_CONTEXT);

Modified: sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java?rev=1164020&r1=1164019&r2=1164020&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/impl/servlets/SlingWebDavServlet.java
Thu Sep  1 11:33:31 2011
@@ -23,14 +23,28 @@ import javax.jcr.Session;
 import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.References;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.PropertyHandler;
 import org.apache.jackrabbit.webdav.DavLocatorFactory;
 import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.webdav.impl.handler.SlingIOManager;
+import org.apache.sling.jcr.webdav.impl.handler.SlingPropertyManager;
 import org.apache.sling.jcr.webdav.impl.helper.SlingLocatorFactory;
 import org.apache.sling.jcr.webdav.impl.helper.SlingResourceConfig;
 import org.apache.sling.jcr.webdav.impl.helper.SlingSessionProvider;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.http.HttpService;
 import org.osgi.service.http.NamespaceException;
@@ -38,7 +52,7 @@ import org.osgi.service.http.NamespaceEx
 /**
  * The <code>SlingWebDavServlet</code> implements the WebDAV protocol as a
  * default servlet for Sling handling all WebDAV methods.
- * 
+ *
  * @scr.component name="org.apache.sling.jcr.webdav.impl.servlets.SimpleWebDavServlet"
  *                label="%dav.name" description="%dav.description"
  *                immediate="true"
@@ -49,68 +63,89 @@ import org.osgi.service.http.NamespaceEx
  *               value="sling/servlet/default" private="true"
  * @scr.property name="sling.servlet.methods" value="*" private="true"
  */
+@Component(name = "org.apache.sling.jcr.webdav.impl.servlets.SimpleWebDavServlet", label
= "%dav.name", description = "%dav.description", immediate = true)
+@Service(Servlet.class)
+@Properties({
+    @Property(name = Constants.SERVICE_DESCRIPTION, value = "Sling WebDAV Servlet"),
+    @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation"),
+    @Property(name = "sling.servlet.resourceTypes", value = "sling/servlet/default", propertyPrivate
= true),
+    @Property(name = "sling.servlet.methods", value = "*", propertyPrivate = true) })
+    @References({
+        @Reference(name = SlingWebDavServlet.IOHANDLER_REF_NAME, referenceInterface = IOHandler.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = SlingWebDavServlet.PROPERTYHANDLER_REF_NAME, referenceInterface
= PropertyHandler.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
+})
 public class SlingWebDavServlet extends SimpleWebdavServlet {
 
-    /** @scr.property valueRef="DEFAULT_CONTEXT" */
+    public static final String DEFAULT_CONTEXT = "/dav";
+
+    @Property(DEFAULT_CONTEXT)
     public static final String PROP_CONTEXT = "dav.root";
 
-    /** @scr.property valueRef="DEFAULT_REALM" */
+    public static final String DEFAULT_REALM = "Sling WebDAV";
+
+    @Property(DEFAULT_REALM)
     public static final String PROP_REALM = "dav.realm";
 
-    /** @scr.property valueRef="COLLECTION_TYPES_DEFAULT" */
     public static final String COLLECTION_TYPES = "collection.types";
 
-    /** @scr.property valueRef="FILTER_PREFIXES_DEFAULT" */
-    public static final String FILTER_PREFIXES = "filter.prefixes";
+    public static final String TYPE_NONCOLLECTIONS_DEFAULT = "nt:file";
 
-    /** @scr.property valueRef="EMPTY_DEFAULT" */
-    public static final String FILTER_TYPES = "filter.types";
+    public static final String TYPE_CONTENT_DEFAULT = "nt:resource";
 
-    /** @scr.property valueRef="EMPTY_DEFAULT" */
-    public static final String FILTER_URIS = "filter.uris";
+    @Property(name = COLLECTION_TYPES)
+    public static final String[] COLLECTION_TYPES_DEFAULT = new String[] {
+        TYPE_NONCOLLECTIONS_DEFAULT, TYPE_CONTENT_DEFAULT };
 
-    /** @scr.property valueRef="TYPE_COLLECTIONS_DEFAULT" */
-    public static final String TYPE_COLLECTIONS = "type.collections";
+    public static final String FILTER_PREFIXES = "filter.prefixes";
 
-    /** @scr.property valueRef="TYPE_NONCOLLECTIONS_DEFAULT" */
-    public static final String TYPE_NONCOLLECTIONS = "type.noncollections";
+    @Property(name = FILTER_PREFIXES)
+    public static final String[] FILTER_PREFIXES_DEFAULT = new String[] {
+        "rep", "jcr" };
 
-    /** @scr.property valueRef="TYPE_CONTENT_DEFAULT" */
-    public static final String TYPE_CONTENT = "type.content";
+    public static final String[] EMPTY_DEFAULT = new String[0];
 
-    public static final String DEFAULT_CONTEXT = "/dav";
+    @Property({})
+    public static final String FILTER_TYPES = "filter.types";
 
-    public static final String DEFAULT_REALM = "Sling WebDAV";
+    @Property({})
+    public static final String FILTER_URIS = "filter.uris";
 
-    public static final String[] EMPTY_DEFAULT = new String[0];
+    public static final String TYPE_COLLECTIONS_DEFAULT = "sling:Folder";
 
-    public static final String[] FILTER_PREFIXES_DEFAULT = new String[] {
-        "rep", "jcr" };
+    @Property(TYPE_COLLECTIONS_DEFAULT)
+    public static final String TYPE_COLLECTIONS = "type.collections";
 
-    public static final String TYPE_COLLECTIONS_DEFAULT = "sling:Folder";
+    @Property(TYPE_NONCOLLECTIONS_DEFAULT)
+    public static final String TYPE_NONCOLLECTIONS = "type.noncollections";
 
-    public static final String TYPE_NONCOLLECTIONS_DEFAULT = "nt:file";
+    @Property(TYPE_CONTENT_DEFAULT)
+    public static final String TYPE_CONTENT = "type.content";
 
-    public static final String TYPE_CONTENT_DEFAULT = "nt:resource";
+    static final String IOHANDLER_REF_NAME = "IOHandler";
 
-    public static final String[] COLLECTION_TYPES_DEFAULT = new String[] {
-        TYPE_NONCOLLECTIONS_DEFAULT, TYPE_CONTENT_DEFAULT };
+    static final String PROPERTYHANDLER_REF_NAME = "PropertyHandler";
 
-    /** @scr.reference */
+    @Reference
     private SlingRepository repository;
 
-    /** @scr.reference */
+    @Reference
     private HttpService httpService;
 
-    /** @scr.reference */
+    @Reference
     private MimeTypeService mimeTypeService;
 
+    private final SlingIOManager ioManager = new SlingIOManager(
+        IOHANDLER_REF_NAME);
+
+    private final SlingPropertyManager propertyManager = new SlingPropertyManager(
+        PROPERTYHANDLER_REF_NAME);
+
     private SlingResourceConfig resourceConfig;
 
     private DavLocatorFactory locatorFactory;
 
     private SessionProvider sessionProvider;
-    
+
     private boolean simpleWebDavServletRegistered;
 
     // ---------- SimpleWebdavServlet overwrites -------------------------------
@@ -118,10 +153,10 @@ public class SlingWebDavServlet extends 
     @Override
     public void init() throws ServletException {
         super.init();
-        
+
         setResourceConfig(resourceConfig);
     }
-    
+
     @Override
     public Repository getRepository() {
         return repository;
@@ -169,8 +204,13 @@ public class SlingWebDavServlet extends 
     protected void activate(ComponentContext context)
             throws NamespaceException, ServletException {
 
+        this.ioManager.setComponentContext(context);
+        this.propertyManager.setComponentContext(context);
+
         resourceConfig = new SlingResourceConfig(mimeTypeService,
-            context.getProperties());
+            context.getProperties(),
+            ioManager,
+            propertyManager);
 
         // Register servlet, and set the contextPath field to signal successful
         // registration
@@ -182,12 +222,30 @@ public class SlingWebDavServlet extends 
     }
 
     protected void deactivate(ComponentContext context) {
-        
+
         if (simpleWebDavServletRegistered) {
             httpService.unregister(resourceConfig.getServletContextPath());
             simpleWebDavServletRegistered = false;
         }
 
-        resourceConfig = null;
+        this.resourceConfig = null;
+        this.ioManager.setComponentContext(null);
+        this.propertyManager.setComponentContext(null);
+    }
+
+    public void bindIOHandler(final ServiceReference ioHandlerReference) {
+        this.ioManager.bindIOHandler(ioHandlerReference);
+    }
+
+    public void unbindIOHandler(final ServiceReference ioHandlerReference) {
+        this.ioManager.unbindIOHandler(ioHandlerReference);
+    }
+
+    public void bindPropertyHandler(final ServiceReference propertyHandlerReference) {
+        this.propertyManager.bindPropertyHandler(propertyHandlerReference);
+    }
+
+    public void unbindPropertyHandler(final ServiceReference propertyHandlerReference) {
+        this.propertyManager.unbindPropertyHandler(propertyHandlerReference);
     }
 }

Modified: sling/trunk/bundles/jcr/webdav/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/webdav/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1164020&r1=1164019&r2=1164020&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/webdav/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/bundles/jcr/webdav/src/main/resources/OSGI-INF/metatype/metatype.properties
Thu Sep  1 11:33:31 2011
@@ -27,6 +27,26 @@
 # SimpleWebDavServlet
 # (This servlet is directly registered with the HttpService besides the
 # SlingMainServlet. Requests to this servlet do not pass by Sling)
+iomanager.name = Apache Sling IOManager Service
+iomanager.description = The Sling IOManager service tracks all \
+ IOHandler services running on the framework and allows to access them \
+ as a sorted list (based on the service.ranking property).
+
+propertymanager.name = Apache Sling PropertyManager Service
+propertymanager.description = The Sling PropertyManager service tracks all \
+ PropertyManager services running on the framework and allows to access them \
+ as a sorted list (based on the service.ranking property).
+
+dirlistingexporthandler.name = Apache Sling Directory Listing Exporter Service
+dirlistingexporthandler.description = The Sling Directory Listing Exporter Service \
+ wraps a org.apache.jackrabbit.server.io.DirListingExportHandler instance in order to \
+ run it as a service.
+
+defaulthandler.name = Apache Sling Default Handler Service
+defaulthandler.description = The Apache Sling Default Handler Service \
+ wraps a org.apache.jackrabbit.server.io.DefaultHandler instance in order to \
+ run it as a service.
+
 dav.name = Apache Sling Simple WebDAV Servlet
 dav.description = The Simple WebDAV Servlet allows direct access to the \
  complete Repository. It is directly accessible in its own URL space and \



Mime
View raw message