sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1763710 - in /sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl: PackageTransformer.java PackageTransformerConfiguration.java
Date Fri, 07 Oct 2016 09:24:03 GMT
Author: kwin
Date: Fri Oct  7 09:24:03 2016
New Revision: 1763710

URL: http://svn.apache.org/viewvc?rev=1763710&view=rev
Log:
SLING-6111 allow to configure whether to create a snapshot prior to installing a package

Added:
    sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
  (with props)
Modified:
    sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java

Modified: sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java?rev=1763710&r1=1763709&r2=1763710&view=diff
==============================================================================
--- sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
(original)
+++ sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
Fri Oct  7 09:24:03 2016
@@ -48,6 +48,7 @@ import org.apache.sling.installer.api.ta
 import org.apache.sling.installer.api.tasks.TransformationResult;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.osgi.framework.Version;
+import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
@@ -84,6 +85,13 @@ public class PackageTransformer implemen
     @Reference
     private RetryHandler retryHandler;
 
+    private PackageTransformerConfiguration configuration;
+
+    @Activate
+    private void activate(final PackageTransformerConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
     /**
      * @see org.apache.sling.installer.api.tasks.ResourceTransformer#transform(org.apache.sling.installer.api.tasks.RegisteredResource)
      */
@@ -222,10 +230,15 @@ public class PackageTransformer implemen
 
                 // finally, install package
                 final ImportOptions opts = new ImportOptions();
+                if (configuration.shouldCreateSnapshots()) {
+                    pkg.install(opts);
+                    ctx.log("Content package installed: {}", resource);
+                } else {
+                    pkg.extract(opts);
+                    ctx.log("Content package extracted: {}", resource);
+                }
 
-                pkg.install(opts);
-
-                ctx.log("Content package installed: {}", resource);
+                
                 setFinishedState(ResourceState.INSTALLED);
 
                 // notify retry handler to install dependend packages.

Added: sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java?rev=1763710&view=auto
==============================================================================
--- sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
(added)
+++ sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
Fri Oct  7 09:24:03 2016
@@ -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.installer.factory.packages.impl;
+
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(name = "Apache Sling OSGi Installer Package Transformer", description
= "Allows to configure how content packages are installed through the OSGi installer")
+public @interface PackageTransformerConfiguration {
+    @AttributeDefinition(name = "Create Snapshots", description = "Boolean flag indicating
whether prior to the installation of the package a snapshot of the repository should be created.")
+    boolean shouldCreateSnapshots() default true;
+}

Propchange: sling/trunk/installer/factories/packages/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message