You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/06/26 09:35:20 UTC

[jackrabbit-filevault] branch feature/JCRVLT-449-persist-tasks created (now 7fb3149)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch feature/JCRVLT-449-persist-tasks
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git.


      at 7fb3149  JCRVLT-449 persist RCP tasks

This branch includes the following new commits:

     new 7fb3149  JCRVLT-449 persist RCP tasks

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-filevault] 01/01: JCRVLT-449 persist RCP tasks

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/JCRVLT-449-persist-tasks
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit 7fb31497defcb188b45aaddb8aefebed1c0d67f8
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Jun 26 11:35:04 2020 +0200

    JCRVLT-449 persist RCP tasks
    
    make WorkspaceFilter serializable
---
 .../apache/jackrabbit/vault/fs/api/FilterSet.java  |  15 +-
 .../jackrabbit/vault/fs/api/ItemFilterSet.java     |   5 +
 .../apache/jackrabbit/vault/fs/api/PathFilter.java |  14 +-
 .../jackrabbit/vault/fs/api/PathFilterSet.java     |   5 +
 .../jackrabbit/vault/fs/api/RepositoryAddress.java |   8 +-
 .../jackrabbit/vault/fs/api/WorkspaceFilter.java   |   3 +-
 .../vault/fs/config/DefaultWorkspaceFilter.java    |   5 +
 .../vault/fs/filter/DefaultPathFilter.java         |   4 +
 vault-rcp/pom.xml                                  |  56 ++++--
 .../jackrabbit/vault/rcp/impl/RcpTaskImpl.java     | 203 +++++++++++++++++----
 .../vault/rcp/impl/RcpTaskManagerImpl.java         |  78 +++++---
 .../vault/rcp/impl/RcpTaskManagerImplTest.java     |  81 ++++++++
 vault-rcp/src/test/resources/filter.xml            |  30 +++
 13 files changed, 419 insertions(+), 88 deletions(-)

diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java
index eea59e3..3feb3d2 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java
@@ -18,6 +18,7 @@
 package org.apache.jackrabbit.vault.fs.api;
 
 import java.io.PrintWriter;
+import java.io.Serializable;
 import java.io.StringWriter;
 import java.util.Collections;
 import java.util.Iterator;
@@ -36,7 +37,12 @@ import org.jetbrains.annotations.Nullable;
  * if an item has not the node addressed by the root path as ancestor, it is
  * always excluded.
  */
-public abstract class FilterSet<E extends Filter> implements Dumpable {
+public abstract class FilterSet<E extends Filter> implements Dumpable, Serializable {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 6974855223334062983L;
 
     /**
      * root path of this definition
@@ -297,7 +303,12 @@ public abstract class FilterSet<E extends Filter> implements Dumpable {
     /**
      * Holds a filter entry
      */
-    public static class Entry<E extends Filter> implements Dumpable {
+    public static class Entry<E extends Filter> implements Dumpable, Serializable {
+
+        /**
+         * 
+         */
+        private static final long serialVersionUID = -138305780523722012L;
 
         /**
          * The item filter
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/ItemFilterSet.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/ItemFilterSet.java
index 454e91d..d6dc560 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/ItemFilterSet.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/ItemFilterSet.java
@@ -35,6 +35,11 @@ import javax.jcr.RepositoryException;
 public class ItemFilterSet extends FilterSet<ItemFilter> {
 
     /**
+     * 
+     */
+    private static final long serialVersionUID = 5031626199477577120L;
+
+    /**
      * The include all item filter set
      */
     public static final ItemFilterSet INCLUDE_ALL =
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
index 78e6b75..1757b7e 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilter.java
@@ -18,9 +18,9 @@
 package org.apache.jackrabbit.vault.fs.api;
 
 import java.io.PrintWriter;
+import java.io.Serializable;
 import java.io.StringWriter;
 
-import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
  * It is usually part of a {@link PathFilterSet}.
  *
  */
-public interface PathFilter extends Filter, Dumpable {
+public interface PathFilter extends Filter, Dumpable, Serializable {
 
     /**
      * The "Catch all" item filter.
@@ -37,6 +37,11 @@ public interface PathFilter extends Filter, Dumpable {
     PathFilter ALL = new PathFilter() {
 
         /**
+         * 
+         */
+        private static final long serialVersionUID = -494310821410470590L;
+
+        /**
          * Returns always {@code true}
          */
         public boolean matches(String path) {
@@ -89,6 +94,11 @@ public interface PathFilter extends Filter, Dumpable {
     PathFilter NONE = new PathFilter() {
 
         /**
+         * 
+         */
+        private static final long serialVersionUID = -6234466171409392783L;
+
+        /**
          * Returns always {@code false}
          */
         public boolean matches(String path) {
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilterSet.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilterSet.java
index 7b8cba9..a310914 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilterSet.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/PathFilterSet.java
@@ -35,6 +35,11 @@ import org.jetbrains.annotations.Nullable;
 public class PathFilterSet extends FilterSet<PathFilter> {
 
     /**
+     * 
+     */
+    private static final long serialVersionUID = 2772732931289986519L;
+
+    /**
      * PathFilterSets of this type are only used to remove nodes during import
      * and ignored for calculation of the package type.
      */
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddress.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddress.java
index ab55dce..0535c2a 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddress.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddress.java
@@ -17,6 +17,7 @@
 
 package org.apache.jackrabbit.vault.fs.api;
 
+import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -39,7 +40,12 @@ import org.jetbrains.annotations.Nullable;
  * <li> scheme://host:port/prefix/workspace/jcr_root/path
  * </ul>
  */
-public class RepositoryAddress {
+public class RepositoryAddress implements Serializable {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -8908383584312413471L;
 
     /**
      * the (virtual) jcr root. 
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java
index b0880ce..9dcae54 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java
@@ -18,6 +18,7 @@
 package org.apache.jackrabbit.vault.fs.api;
 
 import java.io.InputStream;
+import java.io.Serializable;
 import java.util.List;
 
 import javax.jcr.Node;
@@ -32,7 +33,7 @@ import org.osgi.annotation.versioning.ProviderType;
  * {@code WorkspaceFilter} defined a filter for items (node or property).
  */
 @ProviderType
-public interface WorkspaceFilter extends Dumpable {
+public interface WorkspaceFilter extends Dumpable, Serializable {
 
     /**
      * Returns a list of path filter sets for node items.
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
index 08799b1..e0aa35e 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/DefaultWorkspaceFilter.java
@@ -71,6 +71,11 @@ import org.xml.sax.SAXException;
 public class DefaultWorkspaceFilter implements Dumpable, WorkspaceFilter {
 
     /**
+     * 
+     */
+    private static final long serialVersionUID = -3447699591404393205L;
+
+    /**
      * default logger
      */
     private static final Logger log = LoggerFactory.getLogger(DefaultWorkspaceFilter.class);
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
index 74fd43b..9c3dd0a 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFilter.java
@@ -31,6 +31,10 @@ import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 public class DefaultPathFilter implements PathFilter {
 
     /**
+     * 
+     */
+    private static final long serialVersionUID = 6720323970254051462L;
+    /**
      * the internal regex pattern
      */
     private Pattern regex;
diff --git a/vault-rcp/pom.xml b/vault-rcp/pom.xml
index e91f195..12f5d5a 100644
--- a/vault-rcp/pom.xml
+++ b/vault-rcp/pom.xml
@@ -1,23 +1,24 @@
 <?xml version="1.0"?><!--
-  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
+    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
+    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.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
     <modelVersion>4.0.0</modelVersion>
     <!-- ====================================================================== -->
-    <!-- P A R E N T  P R O J E C T  D E S C R I P T I O N                      -->
+    <!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
     <!-- ====================================================================== -->
     <parent>
         <groupId>org.apache.jackrabbit.vault</groupId>
@@ -27,7 +28,7 @@
     </parent>
 
     <!-- ====================================================================== -->
-    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- P R O J E C T D E S C R I P T I O N -->
     <!-- ====================================================================== -->
     <artifactId>org.apache.jackrabbit.vault.rcp</artifactId>
 
@@ -35,7 +36,7 @@
     <description>
         Builds an OSGi bundle that provides the vlt rcp manager
     </description>
-    
+
     <properties>
         <!-- downgrade dependencies to make compatible with the minimum supported version -->
         <jackrabbit.version>2.14.0</jackrabbit.version>
@@ -44,7 +45,7 @@
     </properties>
 
     <!-- ====================================================================== -->
-    <!-- B U I L D                                                             -->
+    <!-- B U I L D -->
     <!-- ====================================================================== -->
     <build>
         <plugins>
@@ -87,7 +88,7 @@
     </build>
 
     <!-- ====================================================================== -->
-    <!-- D E P E N D E N C I E S                                                -->
+    <!-- D E P E N D E N C I E S -->
     <!-- ====================================================================== -->
     <dependencies>
         <dependency>
@@ -151,7 +152,10 @@
             <artifactId>jackrabbit-spi2dav</artifactId>
             <scope>compile</scope>
         </dependency>
-        
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.framework</artifactId>
+        </dependency>
         <!-- OSGi Annotations: @Version -->
         <dependency>
             <groupId>org.osgi</groupId>
@@ -174,6 +178,18 @@
             <version>${project.version}</version>
         </dependency>
 
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>3.3.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskImpl.java b/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskImpl.java
index 8a3c209..0a00f78 100644
--- a/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskImpl.java
+++ b/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskImpl.java
@@ -16,6 +16,9 @@
  */
 package org.apache.jackrabbit.vault.rcp.impl;
 
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
 
@@ -38,22 +41,19 @@ import org.apache.jackrabbit.vault.util.RepositoryCopier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * {@code RcpTask}...
- */
-public class RcpTaskImpl implements Runnable, RcpTask {
+/** {@code RcpTask}... */
+public class RcpTaskImpl implements Runnable, RcpTask, Serializable {
 
     /**
-     * default logger
+     * 
      */
-    private static final Logger log = LoggerFactory.getLogger(RcpTaskImpl.class);
+    private static final long serialVersionUID = -63586992801753312L;
 
-    private final RcpTaskManagerImpl mgr;
+    /** default logger */
+    private static final Logger log = LoggerFactory.getLogger(RcpTaskImpl.class);
 
     private final String id;
 
-    private RepositoryCopier rcp = new RepositoryCopier();
-
     private final RepositoryAddress src;
 
     private final Credentials srcCreds;
@@ -62,17 +62,24 @@ public class RcpTaskImpl implements Runnable, RcpTask {
 
     private final boolean recursive;
 
-    private volatile Result result;
-
     private List<String> excludes;
 
-    private Thread thread;
+    private transient Result result;
+
+    private transient RepositoryCopier rcp;
+
+    private transient Thread thread;
+
+    private transient Session srcSession;
 
-    private Session srcSession;
+    private transient Session dstSession;
 
-    private Session dstSession;
-    
-    private final static class ResultImpl implements RcpTask.Result {
+    /** classloader used in the thread executing the task */
+    private transient ClassLoader classLoader;
+
+    private WorkspaceFilter filter;
+
+    private static final class ResultImpl implements RcpTask.Result {
 
         private final State state;
         private final Throwable throwable;
@@ -80,7 +87,7 @@ public class RcpTaskImpl implements Runnable, RcpTask {
         public ResultImpl(State state) {
             this(state, null);
         }
-        
+
         public ResultImpl(State state, Throwable throwable) {
             super();
             this.state = state;
@@ -96,37 +103,51 @@ public class RcpTaskImpl implements Runnable, RcpTask {
         public Throwable getThrowable() {
             return throwable;
         }
-        
     }
 
-    public RcpTaskImpl(RcpTaskManagerImpl mgr, RepositoryAddress src, Credentials srcCreds, String dst, String id) {
-        this(mgr, src, srcCreds, dst, id, (WorkspaceFilter)null, false);
+    public RcpTaskImpl(ClassLoader dynLoader, RepositoryAddress src, Credentials srcCreds, String dst, String id) {
+        this(dynLoader, src, srcCreds, dst, id, (WorkspaceFilter) null, false);
     }
 
-    public RcpTaskImpl(RcpTaskManagerImpl mgr, RepositoryAddress src, Credentials srcCreds, String dst, String id, List<String> excludes, boolean recursive) throws ConfigurationException {
-        this(mgr, src, srcCreds, dst, id, createFilterForExcludes(excludes), recursive);
+    public RcpTaskImpl(ClassLoader dynLoader, RepositoryAddress src, Credentials srcCreds, String dst, String id, List<String> excludes,
+            boolean recursive) throws ConfigurationException {
+        this(dynLoader, src, srcCreds, dst, id, createFilterForExcludes(excludes), recursive);
         this.excludes = excludes;
     }
 
+    public RcpTaskImpl(ClassLoader dynLoader, RepositoryAddress src, Credentials srcCreds, String dst, String id, WorkspaceFilter srcFilter,
+            boolean recursive) {
+        this.src = src;
+        this.dst = dst;
+        this.srcCreds = srcCreds;
+        this.id = id == null || id.length() == 0
+                ? UUID.randomUUID().toString()
+                : id;
+        this.recursive = recursive;
+        this.filter = srcFilter;
+        initTransientData();
+        this.classLoader = dynLoader;
+    }
+
     private static WorkspaceFilter createFilterForExcludes(List<String> excludes) throws ConfigurationException {
         // could be done better
         DefaultWorkspaceFilter srcFilter = new DefaultWorkspaceFilter();
         PathFilterSet filterSet = new PathFilterSet("/");
-        for (String path: excludes) {
+        for (String path : excludes) {
             filterSet.addExclude(new DefaultPathFilter(path));
         }
         return srcFilter;
     }
 
-    public RcpTaskImpl(RcpTaskManagerImpl mgr, RepositoryAddress src, Credentials srcCreds, String dst, String id, WorkspaceFilter srcFilter, boolean recursive) {
-        this.mgr = mgr;
-        this.src = src;
-        this.dst = dst;
-        this.srcCreds = srcCreds;
-        this.id = id == null || id.length() == 0
-                ? UUID.randomUUID().toString()
-                : id;
-        rcp.setTracker(new ProgressTrackerListener(){
+    private void readObject(java.io.ObjectInputStream stream)
+            throws IOException, ClassNotFoundException {
+        stream.defaultReadObject();
+        initTransientData();
+    }
+
+    private void initTransientData() {
+        rcp = new RepositoryCopier();
+        rcp.setTracker(new ProgressTrackerListener() {
             public void onMessage(Mode mode, String action, String path) {
                 log.info("{} {}", action, path);
             }
@@ -135,13 +156,16 @@ public class RcpTaskImpl implements Runnable, RcpTask {
                 log.error("{} {}", path, e.toString());
             }
         });
-        this.recursive = recursive;
-        if (srcFilter != null) {
-            rcp.setSourceFilter(srcFilter);
+        if (filter != null) {
+            rcp.setSourceFilter(filter);
         }
         result = new ResultImpl(Result.State.NEW);
     }
 
+    public void setClassLoader(ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
     @Override
     public String getId() {
         return id;
@@ -193,17 +217,16 @@ public class RcpTaskImpl implements Runnable, RcpTask {
         }
         // clone session
         dstSession = session.impersonate(new SimpleCredentials(session.getUserID(), new char[0]));
-        ClassLoader dynLoader = mgr.getDynamicClassLoader();
         ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader(dynLoader);
+        Thread.currentThread().setContextClassLoader(classLoader);
         try {
             srcSession = getSourceSession(src);
         } finally {
             Thread.currentThread().setContextClassLoader(oldLoader);
         }
 
-        thread  = new Thread(this, "Vault RCP Task - " + id);
-        thread.setContextClassLoader(dynLoader);
+        thread = new Thread(this, "Vault RCP Task - " + id);
+        thread.setContextClassLoader(classLoader);
         thread.start();
         return true;
     }
@@ -232,7 +255,7 @@ public class RcpTaskImpl implements Runnable, RcpTask {
 
     public void run() {
         result = new ResultImpl(Result.State.RUNNING);
-        log.info("Starting repository copy task id={}. From {} to {}.", new Object[]{
+        log.info("Starting repository copy task id={}. From {} to {}.", new Object[] {
                 id, src.toString(), dst
         });
         try {
@@ -269,4 +292,104 @@ public class RcpTaskImpl implements Runnable, RcpTask {
         return excludes;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((dst == null) ? 0 : dst.hashCode());
+        result = prime * result + ((excludes == null) ? 0 : excludes.hashCode());
+        result = prime * result + ((filter == null) ? 0 : filter.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + (recursive ? 1231 : 1237);
+        result = prime * result + ((src == null) ? 0 : src.hashCode());
+        result = prime * result + ((srcCreds == null) ? 0 : srcCreds.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        RcpTaskImpl other = (RcpTaskImpl) obj;
+        if (dst == null) {
+            if (other.dst != null)
+                return false;
+        } else if (!dst.equals(other.dst))
+            return false;
+        if (excludes == null) {
+            if (other.excludes != null)
+                return false;
+        } else if (!excludes.equals(other.excludes))
+            return false;
+        if (filter == null) {
+            if (other.filter != null)
+                return false;
+        } else if (!filter.equals(other.filter))
+            return false;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (recursive != other.recursive)
+            return false;
+        if (src == null) {
+            if (other.src != null)
+                return false;
+        } else if (!src.equals(other.src))
+            return false;
+        if (!areCredentialsEqual(srcCreds, other.srcCreds)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "RcpTaskImpl [" + (id != null ? "id=" + id + ", " : "") + (src != null ? "src=" + src + ", " : "")
+                + (srcCreds != null ? "srcCreds=" + srcCreds + ", " : "") + (dst != null ? "dst=" + dst + ", " : "") + "recursive="
+                + recursive + ", " + (excludes != null ? "excludes=" + excludes + ", " : "") + (filter != null ? "filter=" + filter : "")
+                + "]";
+    }
+
+    /** @param credentials
+     * @return */
+    boolean areCredentialsEqual(Credentials credentials, Credentials otherCredentials) {
+        if (credentials == null || otherCredentials == null) {
+            if (otherCredentials != null || credentials != null) {
+                return false;
+            }
+        } else {
+            if (credentials.getClass() != otherCredentials.getClass()) {
+                return false;
+            }
+            if (!(credentials instanceof SimpleCredentials)) {
+                throw new IllegalArgumentException("Only equality check for SimpleCredentials supported!");
+            }
+            SimpleCredentials simpleCredentials = SimpleCredentials.class.cast(credentials);
+            SimpleCredentials simpleOtherCredentials = SimpleCredentials.class.cast(otherCredentials);
+
+            if (!Arrays.equals(simpleCredentials.getPassword(), simpleOtherCredentials.getPassword())) {
+                return false;
+            }
+            if (!simpleCredentials.getUserID().equals(simpleOtherCredentials.getUserID())) {
+                return false;
+            }
+
+            if (!Arrays.equals(simpleCredentials.getAttributeNames(), simpleOtherCredentials.getAttributeNames())) {
+                return false;
+            }
+
+            for (String attributeName : simpleCredentials.getAttributeNames()) {
+                if (!simpleCredentials.getAttribute(attributeName).equals(simpleOtherCredentials.getAttribute(attributeName))) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
 }
\ No newline at end of file
diff --git a/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java b/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java
index ecd0870..32f7b43 100644
--- a/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java
+++ b/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java
@@ -16,6 +16,12 @@
  */
 package org.apache.jackrabbit.vault.rcp.impl;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -29,38 +35,64 @@ import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.rcp.RcpTask;
 import org.apache.jackrabbit.vault.rcp.RcpTaskManager;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * {@code RcpTaskManager}...
- */
-@Component(
-        immediate = true,
-        property = {"service.vendor=The Apache Software Foundation"}
-)
+/** {@code RcpTaskManager}... */
+@Component(immediate = true, property = { "service.vendor=The Apache Software Foundation" })
 public class RcpTaskManagerImpl implements RcpTaskManager {
 
-    /**
-     * default logger
-     */
+    private static final String TASKS_DATA_FILE_NAME = "tasks";
+    /** default logger */
     private static final Logger log = LoggerFactory.getLogger(RcpTaskManagerImpl.class);
 
-    @Reference
-    private DynamicClassLoaderManager dynLoaderMgr;
+    private final DynamicClassLoaderManager dynLoaderMgr;
 
-    private final Map<String, RcpTaskImpl> tasks = new LinkedHashMap<>();
+    Map<String, RcpTaskImpl> tasks;
+    
+    private final File dataFile;
+
+    @Activate
+    public RcpTaskManagerImpl(BundleContext bundleContext, @Reference DynamicClassLoaderManager dynLoaderMgr) {
+        this.dynLoaderMgr = dynLoaderMgr;
+        // load tasks from data file
+        dataFile = bundleContext.getDataFile(TASKS_DATA_FILE_NAME);
+        if (dataFile == null) {
+            log.warn("No filesystem support of OSGi provided, persisting/loading tasks not possible!");
+            return;
+        }
+        try (FileInputStream fis = new FileInputStream (dataFile);
+            ObjectInputStream ois = new ObjectInputStream (fis)) {
+            tasks = Map.class.cast(ois.readObject());
+            for (RcpTaskImpl task : tasks.values()) {
+                task.setClassLoader(getDynamicClassLoader());
+            }
+            log.info("Loaded RCP tasks from '{}'", dataFile);
+        } catch (ClassNotFoundException | IOException e) {
+            log.error("Could not restore previous tasks", e);
+            tasks = new LinkedHashMap<>();
+        }
+    }
 
     @Deactivate
-    private void deactivate() {
+    void deactivate() throws IOException {
         log.info("RcpTaskManager deactivated. Stopping running tasks...");
-        for (String id : tasks.keySet()) {
-            removeTask(id);
+        for (RcpTask task : tasks.values()) {
+            task.stop();
         }
         log.info("RcpTaskManager deactivated. Stopping running tasks...done.");
+        if (dataFile != null) {
+            try (FileOutputStream fos = new FileOutputStream (dataFile);
+                 ObjectOutputStream oos = new ObjectOutputStream (fos)) {
+                   oos.writeObject(tasks);
+            }
+            log.info("Persisted RCP tasks in '{}'", dataFile);
+        }
     }
 
     public RcpTask getTask(String taskId) {
@@ -70,28 +102,30 @@ public class RcpTaskManagerImpl implements RcpTaskManager {
     public Map<String, RcpTask> getTasks() {
         return Collections.unmodifiableMap(tasks);
     }
-    
+
     @Override
-    public RcpTask addTask(RepositoryAddress src, Credentials srcCreds, String dst, String id, List<String> excludes, boolean recursive) throws ConfigurationException {
+    public RcpTask addTask(RepositoryAddress src, Credentials srcCreds, String dst, String id, List<String> excludes, boolean recursive)
+            throws ConfigurationException {
         if (id != null && id.length() > 0 && tasks.containsKey(id)) {
             throw new IllegalArgumentException("Task with id " + id + " already exists.");
         }
-        RcpTaskImpl task = new RcpTaskImpl(this, src, srcCreds, dst, id, excludes, recursive);
+        RcpTaskImpl task = new RcpTaskImpl(getDynamicClassLoader(), src, srcCreds, dst, id, excludes, recursive);
         tasks.put(task.getId(), task);
         return task;
     }
 
     @Override
-    public RcpTask addTask(RepositoryAddress src, Credentials srcCreds, String dst, String id, WorkspaceFilter srcFilter, boolean recursive) {
+    public RcpTask addTask(RepositoryAddress src, Credentials srcCreds, String dst, String id, WorkspaceFilter srcFilter,
+            boolean recursive) {
         if (id != null && id.length() > 0 && tasks.containsKey(id)) {
             throw new IllegalArgumentException("Task with id " + id + " already exists.");
         }
-        RcpTaskImpl task = new RcpTaskImpl(this, src, srcCreds, dst, id, srcFilter, recursive);
+        RcpTaskImpl task = new RcpTaskImpl(getDynamicClassLoader(), src, srcCreds, dst, id, srcFilter, recursive);
         tasks.put(task.getId(), task);
         return task;
     }
 
-    public boolean removeTask(String taskId)  {
+    public boolean removeTask(String taskId) {
         RcpTask rcpTask = tasks.remove(taskId);
         if (rcpTask != null) {
             rcpTask.stop();
diff --git a/vault-rcp/src/test/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImplTest.java b/vault-rcp/src/test/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImplTest.java
new file mode 100644
index 0000000..2cefbb8
--- /dev/null
+++ b/vault-rcp/src/test/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImplTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.rcp.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.osgi.framework.BundleContext;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class RcpTaskManagerImplTest {
+
+    @Mock
+    BundleContext mockBundleContext;
+    
+    @Mock
+    DynamicClassLoaderManager mockClassLoaderManager;
+    @Mock
+    ClassLoader mockClassLoader;
+    
+    @Rule
+    public TemporaryFolder folder= new TemporaryFolder();
+    
+    @Test
+    public void testSerializeDeserialize() throws IOException, ConfigurationException, URISyntaxException {
+        Mockito.when(mockBundleContext.getDataFile(Mockito.anyString())).then(new Answer<File>() {
+
+            @Override
+            public File answer(InvocationOnMock invocation) throws Throwable {
+                String name = invocation.getArgument(0, String.class);
+                return new File(folder.getRoot(),name);
+            }
+            
+        });
+        Mockito.when(mockClassLoaderManager.getDynamicClassLoader()).thenReturn(mockClassLoader);
+        RcpTaskManagerImpl taskManager = new RcpTaskManagerImpl(mockBundleContext, mockClassLoaderManager);
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        try (InputStream input = this.getClass().getResourceAsStream("/filter.xml")) {
+            filter.load(input);
+        }
+        taskManager.addTask(new RepositoryAddress("http://localhost:4502"), new SimpleCredentials("testUser", "pw".toCharArray()), "/target/path", "2", Arrays.asList("exclude1", "exclude2"), false);
+        taskManager.addTask(new RepositoryAddress("http://localhost:8080"), new SimpleCredentials("testUser3", "pw3".toCharArray()), "/target/path5", "3", filter, true);
+        taskManager.deactivate();
+        RcpTaskManagerImpl taskManager2 = new RcpTaskManagerImpl(mockBundleContext, mockClassLoaderManager);
+        Assert.assertEquals(taskManager.tasks, taskManager2.tasks);
+    }
+}
diff --git a/vault-rcp/src/test/resources/filter.xml b/vault-rcp/src/test/resources/filter.xml
new file mode 100644
index 0000000..a70a937
--- /dev/null
+++ b/vault-rcp/src/test/resources/filter.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<workspaceFilter version="1.0">
+    <filter root="/apps/test"/>
+    <filter root="/apps/test2">
+        <include pattern=".*/valid" />
+        <include pattern=".*/anothervalid" />
+    </filter>
+    <filter root="/apps/test3" type="cleanup">
+        <exclude pattern=".*/invalid" />
+    </filter>
+    <filter root="/apps/test4/test">
+        <exclude pattern=".*/invalid" />
+    </filter>
+</workspaceFilter>