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/08/12 06:15:32 UTC

[jackrabbit-filevault] branch master updated: JCRVLT-465 only use declarative services 1.3 (#96)

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

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git


The following commit(s) were added to refs/heads/master by this push:
     new 52a19ac  JCRVLT-465 only use declarative services 1.3 (#96)
52a19ac is described below

commit 52a19aca994d74f2f1345ae828ff123eb28609be
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Aug 12 08:15:21 2020 +0200

    JCRVLT-465 only use declarative services 1.3 (#96)
---
 parent/pom.xml                                     |  2 ++
 .../registry/impl/AbstractPackageRegistry.java     |  2 +-
 .../packaging/registry/impl/FSPackageRegistry.java | 25 ++++++++++++----------
 .../vault/rcp/impl/RcpTaskManagerImpl.java         | 23 +++++++++++++++-----
 4 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index a14e600..26e606d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -145,6 +145,8 @@ Bundle-Category: jackrabbit
 -snapshot: SNAPSHOT
 # export all versioned packages except for conditional ones (https://github.com/bndtools/bnd/issues/3721#issuecomment-579026778)
 -exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}}
+# support only DS 1.3 (https://github.com/bndtools/bnd/pull/3121/files)
+-dsannotations-options: version;maximum=1.3.0
                                 ]]></bnd>
                             </configuration>
                         </execution>
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/AbstractPackageRegistry.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/AbstractPackageRegistry.java
index 8b87716..87cdc2a 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/AbstractPackageRegistry.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/AbstractPackageRegistry.java
@@ -76,7 +76,7 @@ public abstract class AbstractPackageRegistry implements PackageRegistry, Intern
      */
     public static final String DEFAULT_PACKAGE_ROOT_PATH_PREFIX = DEFAULT_PACKAGE_ROOT_PATH + "/";
 
-    protected final @NotNull SecurityConfig securityConfig;
+    protected @NotNull SecurityConfig securityConfig;
 
     public AbstractPackageRegistry(SecurityConfig securityConfig) {
         if (securityConfig != null) {
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSPackageRegistry.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSPackageRegistry.java
index 0741a60..8125436 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSPackageRegistry.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSPackageRegistry.java
@@ -112,9 +112,9 @@ public class FSPackageRegistry extends AbstractPackageRegistry {
     @Reference
     private PackageEventDispatcher dispatcher;
 
-    private final File homeDir;
+    private File homeDir;
 
-    private final InstallationScope scope;
+    private InstallationScope scope = InstallationScope.UNSCOPED;
 
     private File getHomeDir() {
         return homeDir;
@@ -149,23 +149,26 @@ public class FSPackageRegistry extends AbstractPackageRegistry {
         loadPackageCache();
     }
     /**
-     * Deafult constructor for OSGi initialization (homeDir defined via activator)
+     * Default constructor for OSGi initialization (homeDir defined via activator)
      * @throws IOException 
      */
+    public FSPackageRegistry() throws IOException {
+        super(null); // set security config delayed (i.e. only after activate())
+    }
+
     @Activate
-    public FSPackageRegistry(BundleContext context, Config config) throws IOException {
-        this(
-                context.getProperty(REPOSITORY_HOME) != null ? ( 
-                        new File(config.homePath()).isAbsolute() ? new File(config.homePath()) : new File(context.getProperty(REPOSITORY_HOME) + "/" + config.homePath()))  
-                      : context.getDataFile(config.homePath()),
-                InstallationScope.valueOf(config.scope()),
-                new AbstractPackageRegistry.SecurityConfig(config.authIdsForHookExecution(), config.authIdsForRootInstallation()));
+    public void activate(BundleContext context, Config config) {
+        this.homeDir = context.getProperty(REPOSITORY_HOME) != null ? ( 
+                new File(config.homePath()).isAbsolute() ? new File(config.homePath()) : new File(context.getProperty(REPOSITORY_HOME) + "/" + config.homePath())) : 
+                context.getDataFile(config.homePath());
         if (!homeDir.exists()) {
             homeDir.mkdirs();
         }
+        log.info("Jackrabbit Filevault FS Package Registry initialized with home location {}", this.homeDir.getPath());
+        this.scope = InstallationScope.valueOf(config.scope());
+        this.securityConfig = new AbstractPackageRegistry.SecurityConfig(config.authIdsForHookExecution(), config.authIdsForRootInstallation());
     }
 
-
     @ObjectClassDefinition(
             name = "Apache Jackrabbit FS Package Registry Service"
     )
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 4381a6a..42625ce 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
@@ -87,19 +87,22 @@ public class RcpTaskManagerImpl implements RcpTaskManager {
 
     SortedMap<String, RcpTaskImpl> tasks;
 
-    private final File dataFile;
+    private File dataFile;
 
     private final ObjectMapper mapper = new ObjectMapper();
     
     private Configuration configuration;
     
-    private final ConfigurationAdmin configurationAdmin;
+    @Reference
+    ConfigurationAdmin configurationAdmin;
 
     /** the serialized tasks which have been processed (for detecting relevant updates) */
     private String serializedTasks;
-
+    
+    
+    
     @Activate
-    public RcpTaskManagerImpl(BundleContext bundleContext, @Reference ConfigurationAdmin configurationAdmin, Map <String, Object> newConfigProperties) throws IOException {
+    void activate(BundleContext bundleContext, Map <String, Object> newConfigProperties) throws IOException {
         mapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true);
         mapper.addMixIn(RepositoryAddress.class, RepositoryAddressMixin.class);
         SimpleModule module = new SimpleModule();
@@ -109,7 +112,6 @@ public class RcpTaskManagerImpl implements RcpTaskManager {
         mapper.addMixIn(SimpleCredentials.class, SimpleCredentialsMixin.class);
         mapper.addMixIn(ConnectionOptions.class, ConnectionOptionsMixin.class);
         this.dataFile = bundleContext.getDataFile(TASKS_DATA_FILE_NAME);
-        this.configurationAdmin = configurationAdmin;
         this.configuration = configurationAdmin.getConfiguration(PID);
         try {
             tasks = loadTasks((String)newConfigProperties.get(PROP_TASKS_SERIALIZATION), dataFile);
@@ -119,6 +121,17 @@ public class RcpTaskManagerImpl implements RcpTaskManager {
         }
     }
 
+    // default constructor, used by DS 1.3
+    public RcpTaskManagerImpl() {
+        
+    }
+
+    // alternative constructor, currently only used for testing
+    public RcpTaskManagerImpl(BundleContext bundleContext, ConfigurationAdmin configurationAdmin, Map <String, Object> newConfigProperties) throws IOException {
+        this.configurationAdmin = configurationAdmin;
+        activate(bundleContext, newConfigProperties);
+    }
+
     @Deactivate
     void deactivate() throws IOException, RepositoryException {
         log.info("RcpTaskManager deactivated. Stopping running tasks...");