You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by to...@apache.org on 2014/10/27 14:49:53 UTC

svn commit: r1634538 [1/2] - in /sling/trunk/contrib/extensions/replication: core/ core/src/main/java/org/apache/sling/replication/agent/ core/src/main/java/org/apache/sling/replication/agent/impl/ core/src/main/java/org/apache/sling/replication/compon...

Author: tommaso
Date: Mon Oct 27 13:49:51 2014
New Revision: 1634538

URL: http://svn.apache.org/r1634538
Log:
SLING-4106 - cleand up agent API, moved replication component stuff to component package

Added:
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgentException.java
      - copied, changed from r1633767, sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/AgentReplicationException.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java   (with props)
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/SettingsUtils.java   (with props)
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-test-content-event.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-content-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-test-remote-event.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-remote-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-test-replicate-event.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-replicate-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-test-scheduled-event.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-scheduled-event.json
    sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.author/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-remote-event.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-remote-event.json
    sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.publish/org.apache.sling.replication.component.impl.GenericReplicationComponentFactory-trigger-content-changed.json
      - copied unchanged from r1633767, sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.publish/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-content-changed.json
Removed:
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/AgentReplicationException.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationComponent.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationComponentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationComponentProvider.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/DefaultReplicationComponentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/DefaultReplicationComponentProvider.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/GenericReplicationComponentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SettingsUtils.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/package-info.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/package-info.java
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-content-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-remote-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-replicate-event.json
    sling/trunk/contrib/extensions/replication/it/src/main/resources/SLING-CONTENT/libs/test/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-test-scheduled-event.json
    sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.author/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-remote-event.json
    sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.publish/org.apache.sling.replication.agent.impl.GenericReplicationComponentFactory-trigger-content-changed.json
Modified:
    sling/trunk/contrib/extensions/replication/core/pom.xml
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgent.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationStrategy.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/PrivilegeReplicationRequestAuthorizationStrategy.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/exporter/AgentReplicationPackageExporterFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/exporter/LocalReplicationPackageExporterFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/exporter/RemoteReplicationPackageExporterFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/importer/AdvancedRemoteReplicationPackageImporter.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/importer/LocalReplicationPackageImporterFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/packaging/impl/importer/RemoteReplicationPackageImporterFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/queue/ReplicationQueueException.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/queue/ReplicationQueueProvider.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentRootServlet.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentServlet.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProviderFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/trigger/impl/AbstractJcrEventTrigger.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/trigger/impl/ChainReplicateReplicationTrigger.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/trigger/impl/PersistingJcrEventReplicationTrigger.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/trigger/impl/ResourceEventReplicationTrigger.java
    sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactoryTest.java
    sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/DefaultReplicationComponentFactoryTest.java
    sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java
    sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/trigger/impl/PersistingJcrEventReplicationTriggerTest.java
    sling/trunk/contrib/extensions/replication/sample/src/main/resources/SLING-CONTENT/libs/sling/replication/install.publish/org.apache.sling.replication.agent.impl.SimpleReplicationAgentFactory-reverse.json

Modified: sling/trunk/contrib/extensions/replication/core/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/pom.xml?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/pom.xml (original)
+++ sling/trunk/contrib/extensions/replication/core/pom.xml Mon Oct 27 13:49:51 2014
@@ -78,7 +78,8 @@
                             org.apache.sling.replication.queue,
                             org.apache.sling.replication.trigger,
                             org.apache.sling.replication.packaging,
-                            org.apache.sling.replication.transport.authentication
+                            org.apache.sling.replication.transport.authentication,
+                            org.apache.sling.replication.util
                         </Export-Package>
                         <Embed-Dependency>httpasyncclient</Embed-Dependency>
                     </instructions>

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgent.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgent.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgent.java Mon Oct 27 13:49:51 2014
@@ -21,41 +21,35 @@ package org.apache.sling.replication.age
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.replication.communication.ReplicationRequest;
 import org.apache.sling.replication.communication.ReplicationResponse;
+import org.apache.sling.replication.component.ReplicationComponent;
 import org.apache.sling.replication.queue.ReplicationQueue;
-import org.apache.sling.replication.queue.ReplicationQueueException;
 
 /**
  * A replication agent is responsible for handling {@link org.apache.sling.replication.communication.ReplicationRequest}s.
  * <p/>
- * This means executing actions of a specific {@link org.apache.sling.replication.communication.ReplicationActionType}s on
- * specific path(s) which will resume in e.g. polling resources from a certain Sling instance and / or sending resources to
+ * This means executing actions of e.g.: a specific {@link org.apache.sling.replication.communication.ReplicationActionType}s on
+ * specific path(s) which will resume pulling resources from a certain Sling instance and / or pushing resources to
  * other instances.
  */
-public interface ReplicationAgent {
-
-    /**
-     * get agent name
-     *
-     * @return the agent name as a <code>String</code>
-     */
-    String getName();
+public interface ReplicationAgent extends ReplicationComponent {
 
     /**
      * get the agent queue with the given name
      *
-     * @param name a queue name as a <code>String</code>
+     * @param name a queue name
      * @return a {@link ReplicationQueue} with the given name bound to this agent, if it exists, <code>null</code> otherwise
-     * @throws ReplicationQueueException
+     * @throws ReplicationAgentException
      */
-    ReplicationQueue getQueue(String name) throws ReplicationQueueException;
+    ReplicationQueue getQueue(String name) throws ReplicationAgentException;
 
     /**
-     * sends a {@link ReplicationRequest} to this {@link org.apache.sling.replication.agent.ReplicationAgent}
+     * executes a {@link ReplicationRequest}
      *
      * @param replicationRequest the replication request
+     * @param resourceResolver   the resource resolver used for authenticating the request,
      * @return a {@link ReplicationResponse}
-     * @throws AgentReplicationException
+     * @throws ReplicationAgentException if any error happens during the execution of the request or if the authentication fails
      */
-    ReplicationResponse execute(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws AgentReplicationException;
+    ReplicationResponse execute(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws ReplicationAgentException;
 
 }

Copied: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgentException.java (from r1633767, sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/AgentReplicationException.java)
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgentException.java?p2=sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgentException.java&p1=sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/AgentReplicationException.java&r1=1633767&r2=1634538&rev=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/AgentReplicationException.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationAgentException.java Mon Oct 27 13:49:51 2014
@@ -22,13 +22,13 @@ package org.apache.sling.replication.age
  * Represents errors happened while {@link ReplicationAgent}s do replications.
  */
 @SuppressWarnings("serial")
-public class AgentReplicationException extends Exception {
+public class ReplicationAgentException extends Exception {
 
-    public AgentReplicationException(Exception e) {
+    public ReplicationAgentException(Exception e) {
         super(e);
     }
 
-    public AgentReplicationException(String string) {
+    public ReplicationAgentException(String string) {
         super(string);
     }
 }

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java Mon Oct 27 13:49:51 2014
@@ -0,0 +1,28 @@
+/*
+ * 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.replication.agent;
+
+/**
+ * An {@link Exception} representing failed authorization in execution of a certain {@link org.apache.sling.replication.communication.ReplicationRequest}
+ */
+public class ReplicationRequestAuthorizationException extends Exception {
+    public ReplicationRequestAuthorizationException(String message) {
+        super(message);
+    }
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationStrategy.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationStrategy.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationStrategy.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/ReplicationRequestAuthorizationStrategy.java Mon Oct 27 13:49:51 2014
@@ -30,8 +30,9 @@ public interface ReplicationRequestAutho
      * @param resourceResolver   a {@link org.apache.sling.api.resource.ResourceResolver} representing the calling 'user'
      * @param replicationRequest a request bringing metadata for getting {@link org.apache.sling.replication.packaging.ReplicationPackage}s
      *                           to be exported
-     * @throws AgentReplicationException
+     * @throws ReplicationRequestAuthorizationException if the {@link org.apache.sling.api.resource.ResourceResolver} is
+     *                                                  not authorized to execute the given {@link org.apache.sling.replication.communication.ReplicationRequest}
      */
-    void checkPermission(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws AgentReplicationException;
+    void checkPermission(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws ReplicationRequestAuthorizationException;
 
 }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java Mon Oct 27 13:49:51 2014
@@ -35,9 +35,9 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.replication.agent.ReplicationAgent;
-import org.apache.sling.replication.agent.ReplicationComponent;
-import org.apache.sling.replication.agent.ReplicationComponentFactory;
-import org.apache.sling.replication.agent.ReplicationComponentProvider;
+import org.apache.sling.replication.component.ReplicationComponent;
+import org.apache.sling.replication.component.ReplicationComponentFactory;
+import org.apache.sling.replication.component.ReplicationComponentProvider;
 import org.apache.sling.replication.event.ReplicationEventFactory;
 import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
@@ -160,10 +160,9 @@ public class CoordinatingReplicationAgen
 
                 ReplicationAgent agent = componentFactory.createComponent(ReplicationAgent.class, properties, this);
 
-                log.debug("activated agent {}", agent != null ? agent.getName() : null);
+                log.debug("activated agent {}", name);
 
                 if (agent != null) {
-                    props.put(NAME, agent.getName());
 
                     // register agent service
                     componentReg = context.registerService(ReplicationAgent.class.getName(), agent, props);

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/PrivilegeReplicationRequestAuthorizationStrategy.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/PrivilegeReplicationRequestAuthorizationStrategy.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/PrivilegeReplicationRequestAuthorizationStrategy.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/PrivilegeReplicationRequestAuthorizationStrategy.java Mon Oct 27 13:49:51 2014
@@ -24,7 +24,8 @@ import javax.jcr.security.AccessControlM
 import javax.jcr.security.Privilege;
 
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.replication.agent.AgentReplicationException;
+import org.apache.sling.replication.agent.ReplicationAgentException;
+import org.apache.sling.replication.agent.ReplicationRequestAuthorizationException;
 import org.apache.sling.replication.agent.ReplicationRequestAuthorizationStrategy;
 import org.apache.sling.replication.communication.ReplicationActionType;
 import org.apache.sling.replication.communication.ReplicationRequest;
@@ -41,7 +42,7 @@ public class PrivilegeReplicationRequest
         this.jcrPrivilege = jcrPrivilege;
     }
 
-    public void checkPermission(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws AgentReplicationException {
+    public void checkPermission(ResourceResolver resourceResolver, ReplicationRequest replicationRequest) throws ReplicationRequestAuthorizationException {
         Session session = resourceResolver.adaptTo(Session.class);
 
         try {
@@ -54,33 +55,32 @@ public class PrivilegeReplicationRequest
 
         }
         catch (RepositoryException e) {
-            throw new AgentReplicationException("Not enough privileges");
+            throw new ReplicationRequestAuthorizationException("Not enough privileges");
         }
 
-
     }
 
     private void checkPermissionForAdd(Session session, String[] paths)
-            throws RepositoryException, AgentReplicationException {
+            throws RepositoryException, ReplicationRequestAuthorizationException {
         AccessControlManager acMgr = session.getAccessControlManager();
 
         Privilege[] privileges = new Privilege[] { acMgr.privilegeFromName(jcrPrivilege), acMgr.privilegeFromName(Privilege.JCR_READ) };
         for (String path : paths) {
             if(!acMgr.hasPrivileges(path, privileges)) {
-                throw new AgentReplicationException("Not enough privileges");
+                throw new ReplicationRequestAuthorizationException("Not enough privileges");
             }
         }
 
     }
 
     private void checkPermissionForDelete(Session session, String[] paths)
-            throws RepositoryException, AgentReplicationException {
+            throws RepositoryException, ReplicationRequestAuthorizationException {
         AccessControlManager acMgr = session.getAccessControlManager();
 
         Privilege[] privileges = new Privilege[] { acMgr.privilegeFromName(jcrPrivilege), acMgr.privilegeFromName(Privilege.JCR_REMOVE_NODE)  };
         for (String path : paths) {
             if(session.nodeExists(path) && !acMgr.hasPrivileges(path, privileges)) {
-                throw new AgentReplicationException("Not enough privileges");
+                throw new ReplicationRequestAuthorizationException("Not enough privileges");
             }
         }
 

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java Mon Oct 27 13:49:51 2014
@@ -29,12 +29,12 @@ import java.util.Properties;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.replication.agent.AgentReplicationException;
 import org.apache.sling.replication.agent.ReplicationAgent;
-import org.apache.sling.replication.agent.ReplicationComponent;
+import org.apache.sling.replication.agent.ReplicationAgentException;
 import org.apache.sling.replication.agent.ReplicationRequestAuthorizationStrategy;
 import org.apache.sling.replication.communication.ReplicationRequest;
 import org.apache.sling.replication.communication.ReplicationResponse;
+import org.apache.sling.replication.component.ReplicationComponent;
 import org.apache.sling.replication.event.ReplicationEventFactory;
 import org.apache.sling.replication.event.ReplicationEventType;
 import org.apache.sling.replication.packaging.ReplicationPackage;
@@ -129,14 +129,14 @@ public class SimpleReplicationAgent impl
     }
 
     public ReplicationResponse execute(ResourceResolver resourceResolver, ReplicationRequest replicationRequest)
-            throws AgentReplicationException {
+            throws ReplicationAgentException {
         try {
             replicationRequestAuthorizationStrategy.checkPermission(resourceResolver, replicationRequest);
             List<ReplicationPackage> replicationPackages = buildPackages(replicationRequest);
             return schedule(replicationPackages);
         } catch (Exception e) {
             log.error("Error executing replication request {}", replicationRequest, e);
-            throw new AgentReplicationException(e);
+            throw new ReplicationAgentException(e);
         }
 
     }
@@ -149,9 +149,7 @@ public class SimpleReplicationAgent impl
 
         ResourceResolver agentResourceResolver = getAgentResourceResolver();
 
-        List<ReplicationPackage> replicationPackages = replicationPackageExporter.exportPackage(agentResourceResolver, replicationRequest);
-
-        return replicationPackages;
+        return replicationPackageExporter.exportPackage(agentResourceResolver, replicationRequest);
     }
 
     private ReplicationResponse schedule(List<ReplicationPackage> replicationPackages) {
@@ -178,9 +176,9 @@ public class SimpleReplicationAgent impl
                 replicationPackage.getType(),
                 replicationPackage.getInfo());
 
-        // send the replication package to the queue distribution handler
+        // dispatch the replication package to the queue distribution handler
         try {
-            ReplicationQueueItemState state = queueDistributionStrategy.add(getName(), replicationQueueItem,
+            ReplicationQueueItemState state = queueDistributionStrategy.add(name, replicationQueueItem,
                     queueProvider);
 
             Dictionary<Object, Object> properties = new Properties();
@@ -204,16 +202,16 @@ public class SimpleReplicationAgent impl
         return replicationResponse;
     }
 
-    public String getName() {
-        return name;
-    }
-
-    public ReplicationQueue getQueue(String name) throws ReplicationQueueException {
+    public ReplicationQueue getQueue(String queueName) throws ReplicationAgentException {
         ReplicationQueue queue;
-        if (name != null && name.length() > 0) {
-            queue = queueProvider.getQueue(getName(), name);
-        } else {
-            queue = queueProvider.getDefaultQueue(getName());
+        try {
+            if (queueName != null && queueName.length() > 0) {
+                queue = queueProvider.getQueue(this.name, queueName);
+            } else {
+                queue = queueProvider.getDefaultQueue(this.name);
+            }
+        } catch (ReplicationQueueException e) {
+            throw new ReplicationAgentException(e);
         }
         return queue;
     }
@@ -225,12 +223,12 @@ public class SimpleReplicationAgent impl
 
         for (int i = 0; i < triggers.size(); i++) {
             ReplicationTrigger trigger = triggers.get(i);
-            String handlerId = getName() + "-" + i;
+            String handlerId = name + "-" + i;
             trigger.register(handlerId, new AgentBasedTriggerRequestHandler(this));
         }
 
         if (!isPassive()) {
-            queueProvider.enableQueueProcessing(getName(), new PackageQueueProcessor());
+            queueProvider.enableQueueProcessing(name, new PackageQueueProcessor());
         }
     }
 
@@ -238,12 +236,12 @@ public class SimpleReplicationAgent impl
         log.info("disabling agent");
         for (int i = 0; i < triggers.size(); i++) {
             ReplicationTrigger trigger = triggers.get(i);
-            String handlerId = getName() + "-" + i;
+            String handlerId = name + "-" + i;
             trigger.unregister(handlerId);
         }
 
         if (!isPassive()) {
-            queueProvider.disableQueueProcessing(getName());
+            queueProvider.disableQueueProcessing(name);
         }
     }
 
@@ -268,8 +266,7 @@ public class SimpleReplicationAgent impl
 
                 replicationPackage.delete();
                 success = true;
-            }
-            else {
+            } else {
                 log.warn("replication package with id {} does not exist", queueItem.getId());
             }
 
@@ -287,7 +284,7 @@ public class SimpleReplicationAgent impl
         try {
             resourceResolver = resourceResolverFactory.getServiceResourceResolver(authenticationInfo);
         } catch (LoginException e) {
-            log.error("cannot obtain a resource resolver", e);
+            log.error("cannot obtain a resource resolver for service {}", subServiceName, e);
         }
 
         return resourceResolver;
@@ -311,7 +308,7 @@ public class SimpleReplicationAgent impl
             try {
                 ResourceResolver resourceResolver = getAgentResourceResolver();
                 agent.execute(resourceResolver, request);
-            } catch (AgentReplicationException e) {
+            } catch (ReplicationAgentException e) {
                 log.error("Error executing handler", e);
             }
         }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java?rev=1634538&r1=1634537&r2=1634538&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java Mon Oct 27 13:49:51 2014
@@ -33,9 +33,9 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.replication.agent.ReplicationAgent;
-import org.apache.sling.replication.agent.ReplicationComponent;
-import org.apache.sling.replication.agent.ReplicationComponentFactory;
-import org.apache.sling.replication.agent.ReplicationComponentProvider;
+import org.apache.sling.replication.component.ReplicationComponent;
+import org.apache.sling.replication.component.ReplicationComponentFactory;
+import org.apache.sling.replication.component.ReplicationComponentProvider;
 import org.apache.sling.replication.event.ReplicationEventFactory;
 import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
@@ -140,10 +140,9 @@ public class SimpleReplicationAgentFacto
             if (componentReg == null && componentFactory != null) {
                 ReplicationAgent agent = componentFactory.createComponent(ReplicationAgent.class, config, this);
 
-                log.debug("activated agent {}", agent != null ? agent.getName() : null);
+                log.debug("activated agent {}", name);
 
                 if (agent != null) {
-                    props.put(NAME, agent.getName());
 
                     // register agent service
                     componentReg = context.registerService(ReplicationAgent.class.getName(), agent, props);

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java Mon Oct 27 13:49:51 2014
@@ -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.replication.component;
+
+/**
+ * A {@link ReplicationComponent} is a component requiring explicit enabling and disabling.
+ * Examples of such components are {@link org.apache.sling.replication.agent.ReplicationAgent}s and some {@link org.apache.sling.replication.trigger.ReplicationTrigger}s,
+ * but this extends to basically all the replication infrastructure items that can be configured and built.
+ */
+public interface ReplicationComponent {
+
+    /**
+     * Enable the component
+     */
+    void enable();
+
+    /**
+     * Disable the component
+     */
+    void disable();
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java Mon Oct 27 13:49:51 2014
@@ -0,0 +1,289 @@
+/*
+ * 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.replication.component;
+
+import java.util.Map;
+
+/**
+ * factory for {@link ReplicationComponent}s
+ */
+public interface ReplicationComponentFactory {
+
+    /**
+     * the type of the component
+     */
+    String COMPONENT_TYPE = "type";
+
+    /**
+     * the name of the component
+     */
+    String COMPONENT_NAME = "name";
+
+    /**
+     * type for components referencing OSGi services
+     */
+    String COMPONENT_TYPE_SERVICE = "service";
+
+    /**
+     * component enabled
+     */
+    String COMPONENT_ENABLED = "enabled";
+
+
+    /**
+     * replication agent component
+     */
+    String COMPONENT_AGENT = "agent";
+
+    /**
+     * package exporter component
+     */
+    String COMPONENT_PACKAGE_EXPORTER = "packageExporter";
+
+    /**
+     * package importer component
+     */
+    String COMPONENT_PACKAGE_IMPORTER = "packageImporter";
+
+    /**
+     * request authorization strategy component
+     */
+    String COMPONENT_REQUEST_AUTHORIZATION_STRATEGY = "requestAuthorizationStrategy";
+
+    /**
+     * queue distribution strategy component
+     */
+    String COMPONENT_QUEUE_DISTRIBUTION_STRATEGY = "queueDistributionStrategy";
+
+    /**
+     * queue provider component
+     */
+    String COMPONENT_QUEUE_PROVIDER = "queueProvider";
+
+    /**
+     * trigger component
+     */
+    String COMPONENT_TRIGGER = "trigger";
+
+    /**
+     * package builder component
+     */
+    String COMPONENT_PACKAGE_BUILDER = "packageBuilder";
+
+    /**
+     * transport authentication provider component
+     */
+    String COMPONENT_TRANSPORT_AUTHENTICATION_PROVIDER = "transportAuthenticationProvider";
+
+    /**
+     * simple replication agent type
+     */
+    String AGENT_SIMPLE = "simple";
+
+    /**
+     * service user property
+     */
+    String AGENT_SIMPLE_PROPERTY_SERVICE_NAME = "serviceName";
+
+    /**
+     * 'passive' property for agents (for defining "queueing agents")
+     */
+    String AGENT_SIMPLE_PROPERTY_IS_PASSIVE = "isPassive";
+
+    /**
+     * local package exporter type
+     */
+    String PACKAGE_EXPORTER_LOCAL = "local";
+
+    /**
+     * remote package exporter type
+     */
+    String PACKAGE_EXPORTER_REMOTE = "remote";
+
+    /**
+     * endpoints property
+     */
+    String PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS = "endpoints";
+
+    /**
+     * endpoint strategy property
+     */
+    String PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS_STRATEGY = "endpoints.strategy";
+
+    /**
+     * no. of items to poll property
+     */
+    String PACKAGE_EXPORTER_REMOTE_PROPERTY_POLL_ITEMS = "poll.items";
+
+    /**
+     * package exporter's agent property
+     */
+    String PACKAGE_EXPORTER_AGENT = "agent";
+
+    /**
+     * local package importer type
+     */
+    String PACKAGE_IMPORTER_LOCAL = "local";
+
+    /**
+     * remote package importer type
+     */
+    String PACKAGE_IMPORTER_REMOTE = "remote";
+
+    /**
+     * endpoints property
+     */
+    String PACKAGE_IMPORTER_REMOTE_PROPERTY_ENDPOINTS = "endpoints";
+
+    /**
+     * endpoint strategy property
+     */
+    String PACKAGE_IMPORTER_REMOTE_PROPERTY_ENDPOINTS_STRATEGY = "endpoints.strategy";
+
+    /**
+     * user property
+     */
+    String TRANSPORT_AUTHENTICATION_PROVIDER_USER = "user";
+
+    /**
+     * username property
+     */
+    String TRANSPORT_AUTHENTICATION_PROVIDER_USER_PROPERTY_USERNAME = "username";
+
+    /**
+     * password property
+     */
+    String TRANSPORT_AUTHENTICATION_PROVIDER_USER_PROPERTY_PASSWORD = "password";
+
+    /**
+     * remote event trigger type
+     */
+    String TRIGGER_REMOTE_EVENT = "remoteEvent";
+
+    /**
+     * remote event endpoint property
+     */
+    String TRIGGER_REMOTE_EVENT_PROPERTY_ENDPOINT = "endpoint";
+
+    /**
+     * resource event trigger type
+     */
+    String TRIGGER_RESOURCE_EVENT = "resourceEvent";
+
+    /**
+     * resource event path property
+     */
+    String TRIGGER_RESOURCE_EVENT_PROPERTY_PATH = "path";
+
+    /**
+     * scheduled trigger type
+     */
+    String TRIGGER_SCHEDULED_EVENT = "scheduledEvent";
+
+    /**
+     * scheduled trigger action property
+     */
+    String TRIGGER_SCHEDULED_EVENT_PROPERTY_ACTION = "action";
+
+    /**
+     * scheduled trigger path property
+     */
+    String TRIGGER_SCHEDULED_EVENT_PROPERTY_PATH = "path";
+
+    /**
+     * scheduled trigger seconds property
+     */
+    String TRIGGER_SCHEDULED_EVENT_PROPERTY_SECONDS = "seconds";
+
+    /**
+     * chain replication trigger type
+     */
+    String TRIGGER_REPLICATION_EVENT = "replicationEvent";
+
+    /**
+     * chain replication path property
+     */
+    String TRIGGER_REPLICATION_EVENT_PROPERTY_PATH = "path";
+
+    /**
+     * jcr event trigger type
+     */
+    String TRIGGER_JCR_EVENT = "jcrEvent";
+
+    /**
+     * jcr event trigger path property
+     */
+    String TRIGGER_JCR_EVENT_PROPERTY_PATH = "path";
+
+    /**
+     * jcr event trigger service user property
+     */
+    String TRIGGER_JCR_EVENT_PROPERTY_SERVICE_NAME = "servicename";
+
+    /**
+     * jcr persisting event trigger type
+     */
+    String TRIGGER_PERSISTED_JCR_EVENT = "persistedJcrEvent";
+
+    /**
+     * jcr persisting event trigger path property
+     */
+    String TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_PATH = "path";
+
+    /**
+     * jcr persisting event trigger service user property
+     */
+    String TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_SERVICE_NAME = "servicename";
+
+    /**
+     * jcr persisting event trigger nuggets path property
+     */
+    String TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_NUGGETS_PATH = "nuggets.path";
+
+    /**
+     * privilege request authorization strategy type
+     */
+    String REQUEST_AUTHORIZATION_STRATEGY_PRIVILEGE = "privilege";
+
+    /**
+     * privilege request authorization strategy jcr privilege property
+     */
+    String REQUEST_AUTHORIZATION_STRATEGY_PRIVILEGE_PROPERTY_JCR_PRIVILEGE = "jcrPrivilege";
+
+    /**
+     * file vault package builder type
+     */
+    String PACKAGE_BUILDER_FILEVLT = "vlt";
+
+
+    /**
+     * create a {@link ReplicationComponent}
+     *
+     * @param type              the {@link java.lang.Class} of the component to be created
+     * @param properties        the properties to be supplied for the initialization of the component
+     * @param componentProvider the {@link ReplicationComponentProvider} used to eventually
+     *                          wire additional required {@link ReplicationComponent}s
+     * @param <ComponentType>   the actual type of the {@link ReplicationComponent}
+     *                          to be created
+     * @return a {@link ReplicationComponent} of the specified type initialized with given properties
+     */
+    <ComponentType> ComponentType createComponent(java.lang.Class<ComponentType> type,
+                                                  Map<String, Object> properties,
+                                                  ReplicationComponentProvider componentProvider);
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java Mon Oct 27 13:49:51 2014
@@ -0,0 +1,40 @@
+/*
+ * 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.replication.component;
+
+/**
+ * provider for already existing {@link ReplicationComponent}s
+ */
+public interface ReplicationComponentProvider {
+
+    /**
+     * Retrieves an already existing component by name.
+     * If null is passed as componentName then a default component is returned.
+     *
+     * @param type            the {@link java.lang.Class} of the component to be retrieved
+     * @param componentName   the component name as a <code>String</code>
+     * @param <ComponentType> the actual type of the {@link ReplicationComponent}
+     *                        to be retrieved
+     * @return the {@link ReplicationComponent} of the specified type,
+     * with the specified name, or <code>null</code> if such a {@link ReplicationComponent}
+     * doesn't exist
+     */
+    <ComponentType> ComponentType getComponent(java.lang.Class<ComponentType> type,
+                                                                            String componentName);
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/ReplicationComponentProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java Mon Oct 27 13:49:51 2014
@@ -0,0 +1,377 @@
+/*
+ * 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.replication.component.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.vault.packaging.Packaging;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.commons.scheduler.Scheduler;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.replication.agent.ReplicationAgent;
+import org.apache.sling.replication.agent.impl.PrivilegeReplicationRequestAuthorizationStrategy;
+import org.apache.sling.replication.agent.impl.SimpleReplicationAgent;
+import org.apache.sling.replication.component.ReplicationComponentFactory;
+import org.apache.sling.replication.component.ReplicationComponentProvider;
+import org.apache.sling.replication.agent.ReplicationRequestAuthorizationStrategy;
+import org.apache.sling.replication.communication.ReplicationActionType;
+import org.apache.sling.replication.event.ReplicationEventFactory;
+import org.apache.sling.replication.packaging.ReplicationPackageExporter;
+import org.apache.sling.replication.packaging.ReplicationPackageImporter;
+import org.apache.sling.replication.packaging.impl.exporter.AgentReplicationPackageExporter;
+import org.apache.sling.replication.packaging.impl.exporter.LocalReplicationPackageExporter;
+import org.apache.sling.replication.packaging.impl.exporter.RemoteReplicationPackageExporter;
+import org.apache.sling.replication.packaging.impl.importer.LocalReplicationPackageImporter;
+import org.apache.sling.replication.packaging.impl.importer.RemoteReplicationPackageImporter;
+import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
+import org.apache.sling.replication.queue.ReplicationQueueProvider;
+import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
+import org.apache.sling.replication.serialization.impl.vlt.FileVaultReplicationPackageBuilder;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.impl.UserCredentialsTransportAuthenticationProvider;
+import org.apache.sling.replication.trigger.ReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.ChainReplicateReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.JcrEventReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.PersistingJcrEventReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.RemoteEventReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.ResourceEventReplicationTrigger;
+import org.apache.sling.replication.trigger.impl.ScheduledReplicationTrigger;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A generic factory for replication components using a compact configuration, already existing OSGi services
+ * for the components to be wired can be used as well as directly instantiated components (called by type name).
+ * <p/>
+ * Currently supported components are {@link org.apache.sling.replication.agent.ReplicationAgent}s,
+ * {@link org.apache.sling.replication.trigger.ReplicationTrigger}s and
+ * {@link org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider}s
+ */
+@Component(metatype = true,
+        label = "Generic Replication Components Factory",
+        description = "OSGi configuration Replication Component factory",
+        specVersion = "1.1",
+        immediate = true
+)
+@Service(ReplicationComponentFactory.class)
+public class DefaultReplicationComponentFactory implements ReplicationComponentFactory, ReplicationComponentProvider {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference
+    private ReplicationEventFactory replicationEventFactory;
+
+    @Reference
+    private ResourceResolverFactory resourceResolverFactory;
+
+    @Reference
+    private SlingRepository repository;
+
+    @Reference
+    private Packaging packaging;
+
+    @Reference
+    private Scheduler scheduler;
+
+    private BundleContext bundleContext;
+
+    @Activate
+    protected void activate(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public <ComponentType> ComponentType createComponent(Class<ComponentType> type, Map<String, Object> properties,
+                                                         ReplicationComponentProvider componentProvider) {
+
+        if (componentProvider == null) {
+            componentProvider = this;
+        }
+        try {
+            if (type.isAssignableFrom(ReplicationAgent.class)) {
+                return (ComponentType) createAgent(properties, componentProvider);
+            } else if (type.isAssignableFrom(ReplicationTrigger.class)) {
+                return (ComponentType) createTrigger(properties, componentProvider);
+            } else if (type.isAssignableFrom(TransportAuthenticationProvider.class)) {
+                return (ComponentType) createTransportAuthenticationProvider(properties, componentProvider);
+            } else if (type.isAssignableFrom(ReplicationPackageImporter.class)) {
+                return (ComponentType) createImporter(properties, componentProvider);
+            } else if (type.isAssignableFrom(ReplicationPackageExporter.class)) {
+                return (ComponentType) createExporter(properties, componentProvider);
+            }
+        }
+        catch (IllegalArgumentException e) {
+            log.debug("Cannot create component", e);
+        }
+
+
+        return null;
+    }
+
+    public ReplicationAgent createAgent(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), ReplicationComponentFactory.AGENT_SIMPLE);
+
+        if (ReplicationComponentFactory.AGENT_SIMPLE.equals(factory)) {
+
+            Map<String, Object> exporterProperties = extractMap(COMPONENT_PACKAGE_EXPORTER, properties);
+            ReplicationPackageExporter packageExporter = createExporter(exporterProperties, componentProvider);
+
+            Map<String, Object> importerProperties = extractMap(COMPONENT_PACKAGE_IMPORTER, properties);
+            ReplicationPackageImporter packageImporter = createImporter(importerProperties, componentProvider);
+
+            Map<String, Object> authorizationStrategyProperties = extractMap(COMPONENT_REQUEST_AUTHORIZATION_STRATEGY, properties);
+            ReplicationRequestAuthorizationStrategy packageExporterStrategy = createAuthorizationStrategy(authorizationStrategyProperties, componentProvider);
+
+            Map<String, Object> queueDistributionStrategyProperties = extractMap(COMPONENT_QUEUE_DISTRIBUTION_STRATEGY, properties);
+            ReplicationQueueDistributionStrategy queueDistributionStrategy = createDistributionStrategy(queueDistributionStrategyProperties, componentProvider);
+
+            Map<String, Object> queueProviderProperties = extractMap(COMPONENT_QUEUE_PROVIDER, properties);
+            ReplicationQueueProvider queueProvider = createQueueProvider(queueProviderProperties, componentProvider);
+
+            List<Map<String, Object>> triggersProperties = extractMapList(COMPONENT_TRIGGER, properties);
+            List<ReplicationTrigger> triggers = createTriggerList(triggersProperties, componentProvider);
+
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), String.valueOf(new Random().nextInt(1000)));
+
+            String serviceName = PropertiesUtil.toString(properties.get(ReplicationComponentFactory.AGENT_SIMPLE_PROPERTY_SERVICE_NAME), null);
+
+            boolean isPassive = PropertiesUtil.toBoolean(properties.get(ReplicationComponentFactory.AGENT_SIMPLE_PROPERTY_IS_PASSIVE), false);
+
+
+            return new SimpleReplicationAgent(name, isPassive, serviceName,
+                    packageImporter, packageExporter, packageExporterStrategy,
+                    queueProvider, queueDistributionStrategy, replicationEventFactory, resourceResolverFactory, triggers);
+
+        }
+
+        return null;
+
+    }
+
+    private ReplicationRequestAuthorizationStrategy createAuthorizationStrategy(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationRequestAuthorizationStrategy.class, name);
+
+        }
+        else if (REQUEST_AUTHORIZATION_STRATEGY_PRIVILEGE.equals(factory)) {
+            String jcrPrivilege = PropertiesUtil.toString(properties.get(REQUEST_AUTHORIZATION_STRATEGY_PRIVILEGE_PROPERTY_JCR_PRIVILEGE), null);
+            return new PrivilegeReplicationRequestAuthorizationStrategy(jcrPrivilege);
+        }
+
+        return null;
+    }
+
+
+    public ReplicationPackageExporter createExporter(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationPackageExporter.class, name);
+
+        } else if (PACKAGE_EXPORTER_LOCAL.equals(factory)) {
+            Map<String, Object> builderProperties = extractMap(COMPONENT_PACKAGE_BUILDER, properties);
+            ReplicationPackageBuilder packageBuilder = createBuilder(builderProperties);
+            return new LocalReplicationPackageExporter(packageBuilder);
+        } else if (PACKAGE_EXPORTER_REMOTE.equals(factory)) {
+            Map<String, Object> authenticationProviderProperties = extractMap(COMPONENT_TRANSPORT_AUTHENTICATION_PROVIDER, properties);
+            TransportAuthenticationProvider authenticationProvider = createTransportAuthenticationProvider(authenticationProviderProperties, componentProvider);
+
+            Map<String, Object> builderProperties = extractMap(COMPONENT_PACKAGE_BUILDER, properties);
+            ReplicationPackageBuilder packageBuilder = createBuilder(builderProperties);
+
+
+            String[] endpoints = PropertiesUtil.toStringArray(properties.get(PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS), new String[0]);
+            String endpointStrategyName = PropertiesUtil.toString(properties.get(PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS_STRATEGY), "One");
+            int pollItems = PropertiesUtil.toInteger(properties.get(PACKAGE_EXPORTER_REMOTE_PROPERTY_POLL_ITEMS), Integer.MAX_VALUE);
+
+            return new  RemoteReplicationPackageExporter(packageBuilder, authenticationProvider, endpoints, endpointStrategyName, pollItems);
+        } else if (PACKAGE_EXPORTER_AGENT.equals(factory)) {
+            Map<String, Object> builderProperties = extractMap(COMPONENT_PACKAGE_BUILDER, properties);
+            ReplicationPackageBuilder packageBuilder = createBuilder(builderProperties);
+            ReplicationAgent agent = componentProvider.getComponent(ReplicationAgent.class, null);
+
+            return new AgentReplicationPackageExporter(properties, agent, packageBuilder);
+        }
+
+
+        return null;
+    }
+
+    public ReplicationPackageImporter createImporter(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationPackageImporter.class, name);
+        } else if (PACKAGE_IMPORTER_LOCAL.equals(factory)) {
+            Map<String, Object> builderProperties = extractMap(COMPONENT_PACKAGE_BUILDER, properties);
+            ReplicationPackageBuilder packageBuilder = createBuilder(builderProperties);
+            return new LocalReplicationPackageImporter(packageBuilder, replicationEventFactory);
+        } else if (PACKAGE_IMPORTER_REMOTE.equals(factory)) {
+            Map<String, Object> authenticationProviderProperties = extractMap(COMPONENT_TRANSPORT_AUTHENTICATION_PROVIDER, properties);
+            TransportAuthenticationProvider authenticationProvider = createTransportAuthenticationProvider(authenticationProviderProperties, componentProvider);
+
+            String[] endpoints = PropertiesUtil.toStringArray(properties.get(PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS), new String[0]);
+            String endpointStrategyName = PropertiesUtil.toString(properties.get(PACKAGE_EXPORTER_REMOTE_PROPERTY_ENDPOINTS_STRATEGY), "One");
+
+            return new RemoteReplicationPackageImporter(authenticationProvider, endpoints, endpointStrategyName);
+        }
+
+        return null;
+    }
+
+    public ReplicationQueueProvider createQueueProvider(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationQueueProvider.class, name);
+        }
+
+        return null;
+    }
+
+    public ReplicationQueueDistributionStrategy createDistributionStrategy(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationQueueDistributionStrategy.class, name);
+
+        }
+
+        return null;
+    }
+
+    public TransportAuthenticationProvider createTransportAuthenticationProvider(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(TransportAuthenticationProvider.class, name);
+
+        } else if (TRANSPORT_AUTHENTICATION_PROVIDER_USER.equals(factory)) {
+            String username = PropertiesUtil.toString(properties.get(TRANSPORT_AUTHENTICATION_PROVIDER_USER_PROPERTY_USERNAME), "").trim();
+            String password = PropertiesUtil.toString(properties.get(TRANSPORT_AUTHENTICATION_PROVIDER_USER_PROPERTY_PASSWORD), "").trim();
+            return new UserCredentialsTransportAuthenticationProvider(username, password);
+        }
+
+        return null;
+    }
+
+    public ReplicationPackageBuilder createBuilder(Map<String, Object> properties) {
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (PACKAGE_BUILDER_FILEVLT.equals(factory)) {
+            return new FileVaultReplicationPackageBuilder(packaging, replicationEventFactory);
+        }
+
+        return null;
+    }
+
+
+    private ReplicationTrigger createTrigger(Map<String, Object> properties, ReplicationComponentProvider componentProvider) {
+        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), COMPONENT_TYPE_SERVICE);
+
+        if (COMPONENT_TYPE_SERVICE.equals(factory)) {
+            String name = PropertiesUtil.toString(properties.get(COMPONENT_NAME), null);
+            return componentProvider.getComponent(ReplicationTrigger.class, name);
+
+        } else if (TRIGGER_REMOTE_EVENT.equals(factory)) {
+            Map<String, Object> authenticationProviderProperties = extractMap(COMPONENT_TRANSPORT_AUTHENTICATION_PROVIDER, properties);
+
+            TransportAuthenticationProvider authenticationProvider = createTransportAuthenticationProvider(authenticationProviderProperties, componentProvider);
+            String endpoint = PropertiesUtil.toString(properties.get(TRIGGER_REMOTE_EVENT_PROPERTY_ENDPOINT), null);
+
+            return new RemoteEventReplicationTrigger(endpoint, authenticationProvider, scheduler);
+        } else if (TRIGGER_RESOURCE_EVENT.equals(factory)) {
+            String path = PropertiesUtil.toString(properties.get(TRIGGER_RESOURCE_EVENT_PROPERTY_PATH), null);
+
+            return new ResourceEventReplicationTrigger(path, bundleContext);
+        } else if (TRIGGER_SCHEDULED_EVENT.equals(factory)) {
+            String action = PropertiesUtil.toString(properties.get(TRIGGER_SCHEDULED_EVENT_PROPERTY_ACTION), ReplicationActionType.POLL.name());
+            String path = PropertiesUtil.toString(properties.get(TRIGGER_SCHEDULED_EVENT_PROPERTY_PATH), "/");
+            int interval = PropertiesUtil.toInteger(properties.get(TRIGGER_SCHEDULED_EVENT_PROPERTY_SECONDS), 30);
+
+            return new ScheduledReplicationTrigger(action, path, interval, scheduler);
+        } else if (TRIGGER_REPLICATION_EVENT.equals(factory)) {
+            String path = PropertiesUtil.toString(properties.get(TRIGGER_REPLICATION_EVENT_PROPERTY_PATH), null);
+
+            return new ChainReplicateReplicationTrigger(path, bundleContext);
+        } else if (TRIGGER_JCR_EVENT.equals(factory)) {
+            String path = PropertiesUtil.toString(properties.get(TRIGGER_JCR_EVENT_PROPERTY_PATH), null);
+            String serviceName = PropertiesUtil.toString(properties.get(TRIGGER_JCR_EVENT_PROPERTY_SERVICE_NAME), null);
+
+            return new JcrEventReplicationTrigger(repository, path, serviceName);
+        } else if (TRIGGER_PERSISTED_JCR_EVENT.equals(factory)) {
+            String path = PropertiesUtil.toString(properties.get(TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_PATH), null);
+            String serviceName = PropertiesUtil.toString(properties.get(TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_SERVICE_NAME), null);
+            String nuggetsPath = PropertiesUtil.toString(properties.get(TRIGGER_PERSISTED_JCR_EVENT_PROPERTY_NUGGETS_PATH), null);
+
+            return new PersistingJcrEventReplicationTrigger(repository, path, serviceName, nuggetsPath);
+        }
+
+        return null;
+    }
+
+    private List<ReplicationTrigger> createTriggerList(List<Map<String, Object>> triggersProperties, ReplicationComponentProvider componentProvider) {
+        List<ReplicationTrigger> triggers = new ArrayList<ReplicationTrigger>();
+        for (Map<String, Object> properties : triggersProperties) {
+            triggers.add(createTrigger(properties, componentProvider));
+        }
+
+        return triggers;
+    }
+
+    Map<String, Object> extractMap(String key, Map<String, Object> objectMap) {
+        Map<String, Object> map = SettingsUtils.extractMap(key, objectMap);
+        return map == null ? new HashMap<String, Object>() : map;
+    }
+
+    List<Map<String, Object>> extractMapList(String key, Map<String, Object> objectMap) {
+        List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
+        for (String mapKey : objectMap.keySet()) {
+            if (mapKey.startsWith(key)) {
+                result.add(SettingsUtils.extractMap(mapKey, objectMap));
+            }
+        }
+        return result;
+    }
+
+    public <ComponentType> ComponentType getComponent(Class<ComponentType> type, String componentName) {
+        return null;
+    }
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java?rev=1634538&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java Mon Oct 27 13:49:51 2014
@@ -0,0 +1,190 @@
+/*
+ * 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.replication.component.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.felix.scr.annotations.Component;
+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.sling.replication.agent.ReplicationAgent;
+import org.apache.sling.replication.component.ReplicationComponentProvider;
+import org.apache.sling.replication.packaging.ReplicationPackageExporter;
+import org.apache.sling.replication.packaging.ReplicationPackageImporter;
+import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
+import org.apache.sling.replication.queue.ReplicationQueueProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * default implementation of {@link org.apache.sling.replication.component.ReplicationComponentProvider} (as an OSGi service).
+ */
+@Component
+@Service(ReplicationComponentProvider.class)
+@Property(name = "name", value = "default")
+@References({
+        @Reference(name = "replicationAgent", referenceInterface = ReplicationAgent.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "replicationPackageImporter", referenceInterface = ReplicationPackageImporter.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "replicationPackageExporter", referenceInterface = ReplicationPackageExporter.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "replicationQueueProvider", referenceInterface = ReplicationQueueProvider.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "replicationQueueDistributionStrategy", referenceInterface = ReplicationQueueDistributionStrategy.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "transportAuthenticationProvider", referenceInterface = TransportAuthenticationProvider.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+})
+public class DefaultReplicationComponentProvider implements ReplicationComponentProvider {
+
+    public static final String COMPONENT_TYPE = "type";
+    public static final String NAME = "name";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    Map<String, ReplicationAgent> replicationAgentMap = new ConcurrentHashMap<String, ReplicationAgent>();
+    Map<String, ReplicationQueueProvider> replicationQueueProviderMap = new ConcurrentHashMap<String, ReplicationQueueProvider>();
+    Map<String, ReplicationQueueDistributionStrategy> replicationQueueDistributionStrategyMap = new ConcurrentHashMap<String, ReplicationQueueDistributionStrategy>();
+    Map<String, TransportAuthenticationProvider> transportAuthenticationProviderMap = new ConcurrentHashMap<String, TransportAuthenticationProvider>();
+    Map<String, ReplicationPackageImporter> replicationPackageImporterMap = new ConcurrentHashMap<String, ReplicationPackageImporter>();
+    Map<String, ReplicationPackageExporter> replicationPackageExporterMap = new ConcurrentHashMap<String, ReplicationPackageExporter>();
+    private BundleContext bundleContext;
+
+    public <ComponentType> ComponentType getComponent(Class<ComponentType> type, String componentName) {
+        if (type.isAssignableFrom(ReplicationPackageExporter.class)) {
+            return (ComponentType) replicationPackageExporterMap.get(componentName);
+        } else if (type.isAssignableFrom(ReplicationPackageImporter.class)) {
+            return (ComponentType) replicationPackageImporterMap.get(componentName);
+        } else if (type.isAssignableFrom(ReplicationQueueProvider.class)) {
+            return (ComponentType) replicationQueueProviderMap.get(componentName);
+        } else if (type.isAssignableFrom(ReplicationQueueDistributionStrategy.class)) {
+            return (ComponentType) replicationQueueDistributionStrategyMap.get(componentName);
+        } else if (type.isAssignableFrom(TransportAuthenticationProvider.class)) {
+            return (ComponentType) transportAuthenticationProviderMap.get(componentName);
+        }
+
+        return null;
+    }
+
+    private void bindReplicationQueueProvider(ReplicationQueueProvider replicationQueueProvider, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationQueueProviderMap.put(name, replicationQueueProvider);
+        }
+    }
+
+    private void unbindReplicationQueueProvider(ReplicationQueueProvider replicationQueueProvider, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationQueueProviderMap.remove(name);
+        }
+    }
+
+    private void bindReplicationQueueDistributionStrategy(ReplicationQueueDistributionStrategy replicationQueueDistributionStrategy, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationQueueDistributionStrategyMap.put(name, replicationQueueDistributionStrategy);
+        }
+    }
+
+    private void unbindReplicationQueueDistributionStrategy(ReplicationQueueDistributionStrategy replicationQueueDistributionStrategy, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationQueueDistributionStrategyMap.remove(name);
+        }
+    }
+
+    private void bindTransportAuthenticationProvider(TransportAuthenticationProvider transportAuthenticationProvider, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            transportAuthenticationProviderMap.put(name, transportAuthenticationProvider);
+
+        }
+
+    }
+
+    private void unbindTransportAuthenticationProvider(TransportAuthenticationProvider transportAuthenticationProvider, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            transportAuthenticationProviderMap.remove(name);
+
+        }
+    }
+
+    private void bindReplicationPackageImporter(ReplicationPackageImporter replicationPackageImporter, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationPackageImporterMap.put(name, replicationPackageImporter);
+
+        }
+    }
+
+    private void unbindReplicationPackageImporter(ReplicationPackageImporter replicationPackageImporter, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationPackageImporterMap.remove(name);
+        }
+    }
+
+    private void bindReplicationPackageExporter(ReplicationPackageExporter replicationPackageExporter, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationPackageExporterMap.put(name, replicationPackageExporter);
+        }
+    }
+
+    private void unbindReplicationPackageExporter(ReplicationPackageExporter replicationPackageExporter, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationPackageExporterMap.remove(name);
+        }
+
+    }
+
+    private void bindReplicationAgent(ReplicationAgent replicationAgent, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationAgentMap.put(name, replicationAgent);
+        }
+    }
+
+    private void unbindReplicationAgent(ReplicationAgent replicationAgent, Map<String, Object> config) {
+
+        String name = (String) config.get("name");
+        if (name != null) {
+            replicationAgentMap.remove(name);
+        }
+
+    }
+
+
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/DefaultReplicationComponentProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native