ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1802921 - in /ace/trunk: org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/ org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/ org.apache.ace.deployment/ org.apache.ace.d...
Date Tue, 25 Jul 2017 11:58:04 GMT
Author: jawi
Date: Tue Jul 25 11:58:04 2017
New Revision: 1802921

URL: http://svn.apache.org/viewvc?rev=1802921&view=rev
Log:
ACE-627 allow ordering of artifact data to be defined

- introduced an ArtifactDataHelper service that DeploymentProviders can use to
  define a particular order for the artifacts that are being returned by it.


Added:
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java
  (with props)
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java
  (with props)
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java
  (with props)
Modified:
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
    ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
    ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
    ace/trunk/org.apache.ace.deployment/provider.api.bnd
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/DeploymentProvider.java
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/packageinfo
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/Activator.java
    ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
    ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderPerformanceTest.java
    ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java

Modified: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
(original)
+++ ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/Activator.java
Tue Jul 25 11:58:04 2017
@@ -18,6 +18,7 @@
  */
 package org.apache.ace.it.deployment.provider.filebased;
 
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
@@ -33,15 +34,18 @@ public class Activator extends Dependenc
             .setInterface(DeploymentProvider.class.getName(), null)
             .setImplementation(FileBasedProvider.class)
             .add(createConfigurationDependency()
-                .setPid(PID)
-             )
-             .add(createServiceDependency()
-                 .setService(LogService.class)
-                 .setRequired(false)));
+                .setPid(PID))
+            .add(createServiceDependency()
+                .setService(ArtifactDataHelper.class)
+                .setDefaultImplementation(NoOpArtifactDataHelper.class)
+                .setRequired(false))
+            .add(createServiceDependency()
+                .setService(LogService.class)
+                .setRequired(false)));
     }
 
     @Override
     public void destroy(BundleContext arg0, DependencyManager arg1) throws Exception {
         // TODO Auto-generated method stub
     }
-}
\ No newline at end of file
+}

Modified: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
(original)
+++ ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/FileBasedProvider.java
Tue Jul 25 11:58:04 2017
@@ -40,6 +40,7 @@ import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
 import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.provider.OverloadedException;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
@@ -66,14 +67,17 @@ public class FileBasedProvider implement
     private static final int OSGI_R4_MANIFEST_VERSION = 2;
     private volatile File m_baseDirectory;
     private volatile File m_defaultDirectory;
+
+    private volatile ArtifactDataHelper m_artifactDataHelper;
     private volatile LogService m_log;
+
     private final Semaphore m_disk = new Semaphore(1, true);
-    
+
     private final AtomicInteger m_usageCounter = new AtomicInteger();
     /** Maximum number of concurrent users. Value 0 is used for unlimited users. */
     private int m_maximumNumberOfUsers = 0;
     /** The default backoff time for each new user over the limit */
-    private static final int BACKOFF_TIME_PER_USER = 5; 
+    private static final int BACKOFF_TIME_PER_USER = 5;
 
     /**
      * Get the bundle data from the bundles in the <data dir>/<target>/<version>
directory It reads the manifest from all the
@@ -85,7 +89,8 @@ public class FileBasedProvider implement
             if (m_maximumNumberOfUsers != 0  && m_maximumNumberOfUsers < concurrentUsers)
{
                 throw new OverloadedException("Too many users, maximum allowed = " + m_maximumNumberOfUsers
+ ", current = " + concurrentUsers,  (concurrentUsers - m_maximumNumberOfUsers) * BACKOFF_TIME_PER_USER);
             }
-            return internalGetBundleData(targetId, version);
+
+            return m_artifactDataHelper.process(internalGetBundleData(targetId, version),
targetId, null, version);
         } finally {
             m_usageCounter.getAndDecrement();
         }
@@ -147,7 +152,7 @@ public class FileBasedProvider implement
             }
             List<ArtifactData> dataVersionFrom = internalGetBundleData(targetId, versionFrom);
             List<ArtifactData> dataVersionTo = internalGetBundleData(targetId, versionTo);
-    
+
             Iterator<ArtifactData> it = dataVersionTo.iterator();
             while (it.hasNext()) {
                 ArtifactDataImpl bundleDataVersionTo = (ArtifactDataImpl) it.next();
@@ -155,7 +160,7 @@ public class FileBasedProvider implement
                 ArtifactData bundleDataVersionFrom = getBundleData(bundleDataVersionTo.getSymbolicName(),
dataVersionFrom);
                 bundleDataVersionTo.setChanged(!bundleDataVersionTo.equals(bundleDataVersionFrom));
             }
-            return dataVersionTo;
+            return m_artifactDataHelper.process(dataVersionTo, targetId, versionFrom, versionTo);
         } finally {
             m_usageCounter.getAndDecrement();
         }
@@ -198,7 +203,7 @@ public class FileBasedProvider implement
                 // try the default
                 getVersions(targetId, versionList, m_defaultDirectory);
             }
-    
+
             // now sort the list of versions and convert all values to strings.
             Collections.sort(versionList);
             List<String> stringVersionList = new ArrayList<>();
@@ -341,7 +346,7 @@ public class FileBasedProvider implement
 
         return bundleData;
     }
-    
+
     /**
      *
      * @param targetId ID that requested versions
@@ -381,7 +386,7 @@ public class FileBasedProvider implement
             if (maximumNumberOfUsers != null) {
                 m_maximumNumberOfUsers = Integer.parseInt(maximumNumberOfUsers);
             }
-            
+
             String baseDirectoryName = getNotNull(settings, DIRECTORY_NAME, "The base directory
cannot be null");
             File baseDirectory = new File(baseDirectoryName);
             if (!baseDirectory.exists() || !baseDirectory.isDirectory()) {

Added: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java?rev=1802921&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java
(added)
+++ ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java
Tue Jul 25 11:58:04 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.ace.it.deployment.provider.filebased;
+
+import java.util.List;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
+
+public class NoOpArtifactDataHelper implements ArtifactDataHelper {
+
+    @Override
+    public List<ArtifactData> process(List<ArtifactData> artifacts, String targetId,
String versionFrom, String versionTo) {
+        return artifacts;
+    }
+
+}
\ No newline at end of file

Propchange: ace/trunk/org.apache.ace.deployment.itest/src/org/apache/ace/it/deployment/provider/filebased/NoOpArtifactDataHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
(original)
+++ ace/trunk/org.apache.ace.deployment.itest/test/org/apache/ace/it/deployment/provider/filebased/FileBasedProviderTest.java
Tue Jul 25 11:58:04 2017
@@ -18,13 +18,16 @@
  */
 package org.apache.ace.it.deployment.provider.filebased;
 
+import static org.testng.Assert.*;
 import java.io.File;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
 import org.apache.ace.deployment.util.test.BundleStreamGenerator;
 import org.apache.ace.test.utils.FileUtils;
@@ -61,7 +64,6 @@ public class FileBasedProviderTest {
     private ArtifactData BUNDLE3_2;
     private ArtifactData BUNDLE4_2;
 
-    @SuppressWarnings("serial")
     @BeforeTest(alwaysRun = true)
     protected void setUp() throws Exception {
 
@@ -73,6 +75,13 @@ public class FileBasedProviderTest {
 
         m_backend = new FileBasedProvider();
         TestUtils.configureObject(m_backend, LogService.class);
+        TestUtils.configureObject(m_backend, ArtifactDataHelper.class, new ArtifactDataHelper()
{
+            @Override
+            public List<ArtifactData> process(List<ArtifactData> artifacts, String
targetId, String versionFrom, String versionTo) {
+                return artifacts;
+            }
+        });
+
         m_backend.updated(new Hashtable<String, String>() {
             {
                 put("BaseDirectoryName", m_tempDirectory.getAbsolutePath());
@@ -159,6 +168,26 @@ public class FileBasedProviderTest {
     }
 
     /**
+     * Tests that a {@link ArtifactDataHelper} instance can be used to mangle the returned
artifact data.
+     */
+    @Test()
+    public void testArtifactDataHelperIsUsed() {
+        TestUtils.configureObject(m_backend, ArtifactDataHelper.class, new ArtifactDataHelper()
{
+            @Override
+            public List<ArtifactData> process(List<ArtifactData> artifacts, String
targetId, String versionFrom, String versionTo) {
+                Collections.sort(artifacts, (a, b) -> b.getSymbolicName().compareTo(a.getSymbolicName()));
+                return artifacts;
+            }
+        });
+
+        // XXX
+        List<ArtifactData> bundleData = m_backend.getBundleData(MULTIPLEVERSIONTARGET,
VERSION1);
+        assertEquals(2, bundleData.size(), "Expected two bundle to be found, but found "
+ bundleData.size());
+        assertEquals(BUNDLE4, bundleData.get(0), "Expected to find bundle " + BUNDLE4.getSymbolicName());
+        assertEquals(BUNDLE3, bundleData.get(1), "Expected to find bundle " + BUNDLE3.getSymbolicName());
+    }
+
+    /**
      * Test the getBundleData for a single version, returning a single bundle
      */
     @Test()

Modified: ace/trunk/org.apache.ace.deployment/provider.api.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/provider.api.bnd?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/provider.api.bnd (original)
+++ ace/trunk/org.apache.ace.deployment/provider.api.bnd Tue Jul 25 11:58:04 2017
@@ -1,6 +1,6 @@
 # Licensed to the Apache Software Foundation (ASF) under the terms of ASLv2 (http://www.apache.org/licenses/LICENSE-2.0).
 
 Export-Package: org.apache.ace.deployment.provider
-Bundle-Version: 1.1.2
+Bundle-Version: 1.2.0
 Bundle-Name: Apache ACE Deployment Provider API
 Bundle-Description: Provides the Deployment Provider API packages
\ No newline at end of file

Added: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java?rev=1802921&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java
(added)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java
Tue Jul 25 11:58:04 2017
@@ -0,0 +1,48 @@
+/*
+ * 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.ace.deployment.provider;
+
+import java.util.List;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * Provides an additional hook for processing {@link ArtifactData}s as returned by a {@link
DeploymentProvider}.
+ * <p>
+ * {@link DeploymentProvider}s can use this service to define a particular order in which
they should be included in the
+ * deployment package.
+ * </p>
+ */
+@ConsumerType
+public interface ArtifactDataHelper {
+
+    /**
+     * @param artifacts
+     *            the list of artifacts that should be processed, cannot be <code>null</code>;
+     * @param targetId
+     *            the identifier of the target these artifacts are intended for, cannot be
<code>null</code>;
+     * @param versionFrom
+     *            the optional from version, can be <code>null</code>;
+     * @param versionTo
+     *            the to version, cannot be <code>null</code>.
+     * @return the list of processed artifacts, in the order they should appear in the deployment
package.
+     */
+    List<ArtifactData> process(List<ArtifactData> artifacts, String targetId,
String versionFrom, String versionTo);
+
+}

Propchange: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/ArtifactDataHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/DeploymentProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/DeploymentProvider.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/DeploymentProvider.java
(original)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/DeploymentProvider.java
Tue Jul 25 11:58:04 2017
@@ -24,8 +24,7 @@ import java.util.List;
 import org.osgi.annotation.versioning.ProviderType;
 
 /**
- * An interface that provides the meta information for the bundles
- * in a certain version number.
+ * An interface that provides the meta information for the bundles in a certain version number.
  */
 @ProviderType
 public interface DeploymentProvider {
@@ -34,43 +33,52 @@ public interface DeploymentProvider {
      * Get the collection of bundleData for a specific version. This data can be used to
generate a deployment package.
      * The ArtifactData.hasChanged method will return true for all bundles in this collection
      *
-     * @return a collection of bundledata. If there are no bundles in this version, return
an empty list
-     * @throws IllegalArgumentException if the target or version do not exist
-     * @throws OverloadedException if the provider is overloaded
-     * @throws java.io.IOException If an IOException occurs.
+     * @return a list of artifacts, in the order in which they should appear in the deployment
package. In case no
+     *         artifacts are present in this version, an empty list is to be returned.
+     * @throws IllegalArgumentException
+     *             if the target or version do not exist
+     * @throws OverloadedException
+     *             if the provider is overloaded
+     * @throws java.io.IOException
+     *             If an IOException occurs.
      */
-    public List<ArtifactData> getBundleData(String targetId, String version) throws
OverloadedException, IllegalArgumentException, IOException;
+    List<ArtifactData> getBundleData(String targetId, String version) throws OverloadedException,
IllegalArgumentException, IOException;
 
     /**
      * This data can be used to generate a fix package. It gives the differences between
the versionFrom and versionTo.
      *
      * Changes between versions are indicated by ArtifactData.hasChanged:
      * <ol>
-     * <li> If a bundle was present in versionFrom and not in VersionTo, it will not
be in the collection</li>
-     * <li> If a bundle existed in versionFrom and exists unchanged in VersionTo, hasChanged
will return false</li>
-     * <li> If a bundle existed in versionFrom and exists changed (i.e. other version)
in versionTo, hasChanged will return true</li>
-     * <li> If a bundle did not exist in versionFrom and exists in VersionTo, hasChanged
will return true</li>
+     * <li>If a bundle was present in versionFrom and not in VersionTo, it will not
be in the collection</li>
+     * <li>If a bundle existed in versionFrom and exists unchanged in VersionTo, hasChanged
will return false</li>
+     * <li>If a bundle existed in versionFrom and exists changed (i.e. other version)
in versionTo, hasChanged will
+     * return true</li>
+     * <li>If a bundle did not exist in versionFrom and exists in VersionTo, hasChanged
will return true</li>
      * </ol>
      *
-     * @return a list of bundles.
-     * @throws IllegalArgumentException if the target, the versionFrom or versionTo do no
exist
-     * @throws OverloadedException if the provider is overloaded
-     * @throws java.io.IOException If an IOException occurs.
+     * @return a list of artifacts, in the order in which they should appear in the deployment
package. In case no
+     *         artifacts are present in this version, an empty list is to be returned.
+     * @throws IllegalArgumentException
+     *             if the target, the versionFrom or versionTo do no exist
+     * @throws OverloadedException
+     *             if the provider is overloaded
+     * @throws java.io.IOException
+     *             If an IOException occurs.
      */
-
-    public List<ArtifactData> getBundleData(String targetId, String versionFrom, String
versionTo) throws OverloadedException, IllegalArgumentException, IOException;
+    List<ArtifactData> getBundleData(String targetId, String versionFrom, String versionTo)
throws OverloadedException, IllegalArgumentException, IOException;
 
     /**
-     * Returns a list of versions for a specific target. The list is sorted in
-     * ascending order, so the latest version is the last one in the list.
+     * Returns a list of versions for a specific target. The list is sorted in ascending
order, so the latest version is
+     * the last one in the list.
      *
-     * @param targetId  The id of the target for which all available deployment package
-     *                   versions are being retrieved.
-     * @return All available deployment package versions for a specific target. If none available,
-     *         return an empty List.
+     * @param targetId
+     *            The id of the target for which all available deployment package versions
are being retrieved.
+     * @return All available deployment package versions for a specific target. If none available,
return an empty List.
      *         If the target doesn't exist, an IllegalArgumentException is thrown
-     * @throws java.io.IOException If an IOException occurs.
-     * @throws OverloadedException if the provider is overloaded
+     * @throws java.io.IOException
+     *             If an IOException occurs.
+     * @throws OverloadedException
+     *             if the provider is overloaded
      */
-    public List<String> getVersions(String targetId) throws OverloadedException, IllegalArgumentException,
IOException;
-}
\ No newline at end of file
+    List<String> getVersions(String targetId) throws OverloadedException, IllegalArgumentException,
IOException;
+}

Modified: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/packageinfo
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/packageinfo?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/packageinfo
(original)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/packageinfo
Tue Jul 25 11:58:04 2017
@@ -1 +1 @@
-version 1.1.1
\ No newline at end of file
+version 1.2.0
\ No newline at end of file

Modified: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/Activator.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/Activator.java
(original)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/Activator.java
Tue Jul 25 11:58:04 2017
@@ -18,6 +18,7 @@
  */
 package org.apache.ace.deployment.provider.repositorybased;
 
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
@@ -33,15 +34,13 @@ public class Activator extends Dependenc
             .setInterface(DeploymentProvider.class.getName(), null)
             .setImplementation(RepositoryBasedProvider.class)
             .add(createConfigurationDependency()
-                .setPid(PID)
-             )
-             .add(createServiceDependency()
-                 .setService(LogService.class)
-                 .setRequired(false)));
+                .setPid(PID))
+            .add(createServiceDependency()
+                .setService(ArtifactDataHelper.class)
+                .setDefaultImplementation(NoOpArtifactDataHelper.class)
+                .setRequired(false))
+            .add(createServiceDependency()
+                .setService(LogService.class)
+                .setRequired(false)));
     }
-
-    @Override
-    public void destroy(BundleContext arg0, DependencyManager arg1) throws Exception {
-        // TODO Auto-generated method stub
-    }
-}
\ No newline at end of file
+}

Added: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java?rev=1802921&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java
(added)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java
Tue Jul 25 11:58:04 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.ace.deployment.provider.repositorybased;
+
+import java.util.List;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
+
+public class NoOpArtifactDataHelper implements ArtifactDataHelper {
+
+    @Override
+    public List<ArtifactData> process(List<ArtifactData> artifacts, String targetId,
String versionFrom, String versionTo) {
+        return artifacts;
+    }
+
+}
\ No newline at end of file

Propchange: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/NoOpArtifactDataHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
(original)
+++ ace/trunk/org.apache.ace.deployment/src/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
Tue Jul 25 11:58:04 2017
@@ -39,6 +39,7 @@ import javax.xml.parsers.SAXParserFactor
 
 import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.provider.OverloadedException;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
@@ -65,7 +66,7 @@ public class RepositoryBasedProvider imp
     private static final String URL = "url";
     private static final String NAME = "name";
     private static final String CUSTOMER = "customer";
-    
+
     /**
      * Key, intended to be used for artifacts which are bundles and will publish
      * a resource processor (see OSGi compendium section 114.10).
@@ -99,12 +100,13 @@ public class RepositoryBasedProvider imp
     public static final String KEY_RESOURCE_PROCESSOR_PID = "Deployment-ProvidesResourceProcessor";
 
     public static final String MIMETYPE = "application/vnd.osgi.bundle";
-    
+
     /**
      * Key, intended for configurations that specifies the maximum number of concurrent users
for this repository provider.
      */
     private static final String MAXIMUM_NUMBER_OF_USERS = "MaximumNumberOfUsers";
 
+    private volatile ArtifactDataHelper m_artifactDataHelper;
     private volatile LogService m_log;
 
     /** This variable is volatile since it can be changed by the Updated() method. */
@@ -116,7 +118,7 @@ public class RepositoryBasedProvider imp
      */
     private volatile Repository m_directRepository;
     private volatile DependencyManager m_manager;
-    
+
     private final SAXParserFactory m_saxParserFactory;
     private final Map<String,List<String>> m_cachedVersionLists;
 
@@ -124,7 +126,7 @@ public class RepositoryBasedProvider imp
     /** Maximum number of concurrent users. Values <= 0 are used for unlimited users.
*/
     private int m_maximumNumberOfUsers = 0;
     /** The default backoff time for each new user over the limit */
-    private static final int BACKOFF_TIME_PER_USER = 5; 
+    private static final int BACKOFF_TIME_PER_USER = 5;
 
     public RepositoryBasedProvider() {
         m_saxParserFactory = SAXParserFactory.newInstance();
@@ -158,7 +160,7 @@ public class RepositoryBasedProvider imp
 
             List<XmlDeploymentArtifact>[] pairs = null;
             try {
-                // ACE-240: do NOT allow local/remote repositories to be empty. If we're

+                // ACE-240: do NOT allow local/remote repositories to be empty. If we're
                 // asking for real artifacts, it means we must have a repository...
                 input = getRepositoryStream(true /* fail */);
                 if (versionFrom == null) {
@@ -204,7 +206,12 @@ public class RepositoryBasedProvider imp
                 dataVersionTo = getAllArtifactData(pairs[0]);
             }
 
-            return dataVersionTo != null ? dataVersionTo : new ArrayList<ArtifactData>();
+            if (dataVersionTo == null) {
+                return new ArrayList<>();
+            }
+
+            // ACE-627: allow a custom ordering to be specified for the artifacts to appear
in our DP...
+            return m_artifactDataHelper.process(dataVersionTo, targetId, versionFrom, versionTo);
         }
         finally {
             m_usageCounter.getAndDecrement();
@@ -233,8 +240,8 @@ public class RepositoryBasedProvider imp
             InputStream input = null;
 
             try {
-                // ACE-240: allow local/remote repositories to be empty; as the target 
-                // might be new & unregistered, it can have no repository yet... 
+                // ACE-240: allow local/remote repositories to be empty; as the target
+                // might be new & unregistered, it can have no repository yet...
                 input = getRepositoryStream(false /* fail */);
                 List<Version> versionList;
                 if (input == null) {
@@ -296,7 +303,7 @@ public class RepositoryBasedProvider imp
         // get the bundledata for each URL
         for (XmlDeploymentArtifact pair : deploymentArtifacts) {
             long artifactSize = pair.getSize();
-            
+
             Map<String, String> directives = pair.getDirective();
             if (directives.get(DIRECTIVE_KEY_PROCESSORID) == null) {
                 // this is a bundle.
@@ -317,8 +324,8 @@ public class RepositoryBasedProvider imp
                 String filename = directives.get(DIRECTIVE_KEY_RESOURCE_ID);
                 result.add(new ArtifactDataImpl(pair.getUrl(), directives, filename, artifactSize,
true /* hasChanged */));
             }
-
         }
+
         return result;
     }
 
@@ -383,10 +390,10 @@ public class RepositoryBasedProvider imp
      */
     private List<Version> getAvailableVersions(InputStream input, String targetId)
throws IllegalArgumentException {
         DeploymentPackageVersionCollector collector = new DeploymentPackageVersionCollector(targetId);
-        
+
         try {
             m_saxParserFactory.newSAXParser().parse(input, collector);
-            
+
             return collector.getVersions();
         }
         catch (Exception e) {
@@ -408,7 +415,7 @@ public class RepositoryBasedProvider imp
      */
     private List<XmlDeploymentArtifact>[] getDeploymentArtifactPairs(InputStream input,
String targetId, String[] versions) throws IllegalArgumentException {
         final DeploymentArtifactCollector collector = new DeploymentArtifactCollector(targetId,
versions);
-        
+
         try {
             m_saxParserFactory.newSAXParser().parse(input, collector);
 
@@ -460,7 +467,7 @@ public class RepositoryBasedProvider imp
         	return new GZIPInputStream(result);
         }
     }
-    
+
     private boolean isCacheUpToDate() {
         CachedRepository cachedRepository = m_cachedRepository;
         try {
@@ -478,7 +485,7 @@ public class RepositoryBasedProvider imp
             String name = getNotNull(settings, NAME, "RepositoryName not configured.");
             String customer = getNotNull(settings, CUSTOMER, "RepositoryCustomer not configured.");
             String maximumNumberOfUsers = (String) settings.get(MAXIMUM_NUMBER_OF_USERS);
-            
+
             if (maximumNumberOfUsers != null) {
                 try {
                     m_maximumNumberOfUsers = Integer.parseInt(maximumNumberOfUsers);
@@ -487,7 +494,7 @@ public class RepositoryBasedProvider imp
                     throw new ConfigurationException(MAXIMUM_NUMBER_OF_USERS, maximumNumberOfUsers
+ " is not a valid value for the maximum number of concurrent users.");
                 }
             }
-            
+
             // create the remote repository and set it.
             try {
                 BackupRepository backup = new FilebasedBackupRepository(File.createTempFile("currentrepository",
null), File.createTempFile("backuprepository", null));

Modified: ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderPerformanceTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderPerformanceTest.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderPerformanceTest.java
(original)
+++ ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderPerformanceTest.java
Tue Jul 25 11:58:04 2017
@@ -30,6 +30,7 @@ import javax.xml.transform.dom.DOMSource
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.repository.Repository;
 import org.apache.ace.test.utils.TestUtils;
 import org.osgi.framework.Constants;
@@ -101,8 +102,9 @@ public class RepositoryBasedProviderPerf
         m_backend = new RepositoryBasedProvider();
         TestUtils.configureObject(m_backend, Repository.class, mock);
         TestUtils.configureObject(m_backend, LogService.class);
+        TestUtils.configureObject(m_backend, ArtifactDataHelper.class, new NoOpArtifactDataHelper());
     }
-    
+
     /**
      * Test the getBundleData for a single version, returning a single bundle, for a huge
XML.
      */
@@ -181,7 +183,7 @@ public class RepositoryBasedProviderPerf
 
     /**
      * Helper method to create the description of a deploymentpacakge with given data.
-     * 
+     *
      * @param doc The document to add the version to.
      * @param targetText The targetId in the deploymentversion.
      * @param versionText The version in the deploymentversion.

Modified: ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java?rev=1802921&r1=1802920&r2=1802921&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
(original)
+++ ace/trunk/org.apache.ace.deployment/test/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProviderTest.java
Tue Jul 25 11:58:04 2017
@@ -39,6 +39,7 @@ import javax.xml.transform.dom.DOMSource
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.ArtifactDataHelper;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
 import org.apache.ace.deployment.util.test.BundleStreamGenerator;
 import org.apache.ace.repository.Repository;
@@ -144,6 +145,7 @@ public class RepositoryBasedProviderTest
         m_backend = new RepositoryBasedProvider();
         TestUtils.configureObject(m_backend, Repository.class, mock);
         TestUtils.configureObject(m_backend, LogService.class);
+        TestUtils.configureObject(m_backend, ArtifactDataHelper.class, new NoOpArtifactDataHelper());
     }
 
     /**
@@ -294,7 +296,7 @@ public class RepositoryBasedProviderTest
 
     /**
      * Helper method to create the description of a deploymentpacakge with given data.
-     * 
+     *
      * @param doc
      *            The document to add the version to.
      * @param targetText
@@ -354,7 +356,7 @@ public class RepositoryBasedProviderTest
 
     /**
      * Without any checked in data, we should just get back no version, but the provider
should not crash.
-     * 
+     *
      * @throws java.io.IOException
      */
     @Test()



Mime
View raw message