incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r934020 - in /incubator/aries/trunk/subsystem: ./ subsystem-core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ subsystem-itests/ subsystem-itests/sr...
Date Wed, 14 Apr 2010 17:16:25 GMT
Author: linsun
Date: Wed Apr 14 17:16:25 2010
New Revision: 934020

URL: http://svn.apache.org/viewvc?rev=934020&view=rev
Log:
ARIES-283 Provide an implementation of ResourceResolver that can find resources in local .m2 repo or any other specified maven 2 repo.  resolve resources has not been implemented

Added:
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java   (with props)
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java   (with props)
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java   (with props)
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java   (with props)
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java   (with props)
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/MANIFEST.MF
Modified:
    incubator/aries/trunk/subsystem/pom.xml
    incubator/aries/trunk/subsystem/subsystem-core/pom.xml
    incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
    incubator/aries/trunk/subsystem/subsystem-itests/pom.xml
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java
    incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem1/META-INF/MANIFEST.MF

Modified: incubator/aries/trunk/subsystem/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/pom.xml?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/pom.xml (original)
+++ incubator/aries/trunk/subsystem/pom.xml Wed Apr 14 17:16:25 2010
@@ -56,6 +56,21 @@
                 <version>${version}</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.aries.application</groupId>
+                <artifactId>org.apache.aries.application.api</artifactId>
+                <version>${version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.aries.application</groupId>
+                <artifactId>org.apache.aries.application.utils</artifactId>
+                <version>${version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.aries</groupId>
+                <artifactId>org.apache.aries.util</artifactId>
+                <version>${version}</version>
+            </dependency>  
+            <dependency>
                 <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.core</artifactId>
                 <version>4.2.0</version>
@@ -75,6 +90,24 @@
                 <artifactId>osgi</artifactId>
                 <version>v43prototype-3.6.0.201003231329</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.osgi.service.obr</artifactId>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.felix</groupId>
+                        <artifactId>org.osgi.core</artifactId>
+                    </exclusion>
+                </exclusions>
+                <version>1.0.2</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.apache.felix.bundlerepository</artifactId>
+                <version>1.4.3</version>
+            </dependency>
+            
+            
 	    </dependencies>
 	</dependencyManagement>
 

Modified: incubator/aries/trunk/subsystem/subsystem-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/pom.xml?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/pom.xml (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/pom.xml Wed Apr 14 17:16:25 2010
@@ -48,6 +48,19 @@
             <artifactId>org.apache.aries.subsystem.api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.testsupport</groupId>
+            <artifactId>org.apache.aries.testsupport.unit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.eclipse</groupId>
             <artifactId>osgi</artifactId>
             <scope>provided</scope>
@@ -70,6 +83,16 @@
             <artifactId>slf4j-simple</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.service.obr</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java Wed Apr 14 17:16:25 2010
@@ -55,6 +55,9 @@ public class Activator implements Bundle
         register(ResourceResolver.class,
                  new NoOpResolver(),
                  DictionaryBuilder.build(Constants.SERVICE_RANKING, Integer.MIN_VALUE));
+        register(ResourceResolver.class,
+                new ResourceResolverImpl(this.context),
+                DictionaryBuilder.build(Constants.SERVICE_RANKING, 0));
         register(ResourceProcessor.class,
                 new BundleResourceProcessor(),
                 DictionaryBuilder.build(SubsystemConstants.SERVICE_RESOURCE_TYPE, SubsystemConstants.RESOURCE_TYPE_BUNDLE));

Added: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java Wed Apr 14 17:16:25 2010
@@ -0,0 +1,137 @@
+/*
+ * 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 WARRANTIESOR 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.aries.subsystem.core.obr;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.subsystem.core.obr.ContentImpl;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+public class BundleInfoImpl implements BundleInfo {
+
+    private Map<String, String> attributeMap = new HashMap<String, String>();
+    private String path;
+
+    public BundleInfoImpl(String pathToJar) {
+        this.path = pathToJar;
+        Manifest manifest = null;
+        try {
+            JarFile f = new JarFile(new File(pathToJar));
+            manifest = f.getManifest();
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        process(manifest);
+    }
+
+    private void process(Manifest manifest) {
+        if (manifest != null) {
+            Attributes attributes = manifest.getMainAttributes();
+            Set<Object> set = attributes.keySet();
+            for (Object entry : set) {
+                String key = entry.toString();
+                attributeMap.put(key, attributes.getValue(key));
+            }
+        }
+    }
+
+    public Map<String, String> getBundleAttributes() {
+        return attributeMap;
+    }
+
+    public Map<String, String> getBundleDirectives() {
+        // TODO Auto-generated method stub
+        return new HashMap<String, String>();
+    }
+
+    public Set<Content> getExportPackage() {
+        String exportPkgs = attributeMap.get(Constants.EXPORT_PACKAGE);
+        List<String> list = ManifestHeaderProcessor.split(exportPkgs, ",");
+        Set<Content> contents = new HashSet<Content>();
+        for (String content : list) {
+            contents.add(new ContentImpl(content));
+        }
+
+        return contents;
+    }
+
+    public Set<Content> getExportService() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Map<String, String> getHeaders() {
+        return attributeMap;
+    }
+
+    public Set<Content> getImportPackage() {
+        String importPkgs = attributeMap.get(Constants.IMPORT_PACKAGE);
+        List<String> list = ManifestHeaderProcessor.split(importPkgs, ",");
+        Set<Content> contents = new HashSet<Content>();
+        for (String content : list) {
+            contents.add(new ContentImpl(content));
+        }
+
+        return contents;
+    }
+
+    public Set<Content> getImportService() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getLocation() {
+        return path;
+    }
+
+    public Set<Content> getRequireBundle() {
+        String requireBundle = attributeMap.get(Constants.REQUIRE_BUNDLE);
+        List<String> list = ManifestHeaderProcessor.split(requireBundle, ",");
+        Set<Content> contents = new HashSet<Content>();
+        for (String content : list) {
+            contents.add(new ContentImpl(content));
+        }
+
+        return contents;
+    }
+
+    public String getSymbolicName() {
+        return attributeMap.get(Constants.BUNDLE_SYMBOLICNAME);
+    }
+
+    public Version getVersion() {
+        return Version.parseVersion(attributeMap.get(Constants.BUNDLE_VERSION));
+    }
+
+}

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/BundleInfoImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java Wed Apr 14 17:16:25 2010
@@ -0,0 +1,200 @@
+/*
+ * 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 WARRANTIESOR 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.aries.subsystem.core.obr;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+
+/**
+ * Implementation of Content, copied from org.apache.aries.application.utils folder with 
+ * intention to common this out to a common util folder
+ *
+ */
+public final class ContentImpl implements Content
+{
+  private String contentName;
+  protected Map<String, String> attributes;
+  private Map<String, String> directives;
+  private NameValueMap<String, String> nameValueMap;
+  
+  /**
+   * 
+   * @param content  Application-Content, Import-Package content
+   */
+  public ContentImpl(String content) {
+    Map<String, NameValueMap<String, String>> appContentsMap = ManifestHeaderProcessor.parseImportString(content);
+    if (appContentsMap.size() != 1) {
+      throw new IllegalArgumentException("Invalid content string " + content);
+    }
+    for (Map.Entry<String, NameValueMap<String, String>> entry : appContentsMap.entrySet()) {
+      this.contentName = entry.getKey();
+      this.nameValueMap= entry.getValue();
+      setup();
+      break;
+    }
+  }
+  
+  public ContentImpl (String bundleSymbolicName, Version version) { 
+    this.contentName = bundleSymbolicName;
+    this.nameValueMap = new NameValueMap<String, String>();
+    nameValueMap.put("version", version.toString());
+    setup();
+  }
+  
+  /**
+   * 
+   * @param contentName  
+   * @param nameValueMap
+   */
+  public ContentImpl(String contentName, NameValueMap<String, String> nameValueMap) {
+    this.contentName = contentName;
+    this.nameValueMap= nameValueMap;
+    setup();
+  }
+  
+  public String getContentName() {
+    return this.contentName;
+  }
+  
+  public Map<String, String> getAttributes() {
+    return Collections.unmodifiableMap(this.attributes);
+  }
+  
+  public Map<String, String> getDirectives() {
+    return Collections.unmodifiableMap(this.directives);
+  }
+  
+  public String getAttribute(String key) {
+    String toReturn = this.attributes.get(key);
+    return toReturn;
+  }
+  
+  /**
+   * add key value to the attributes map
+   * @param key
+   * @param value
+   */
+  public void addAttribute(String key, String value) {
+    this.attributes.put(key, value);
+  }
+  
+  public String getDirective(String key) {
+    String toReturn = this.directives.get(key);
+    return toReturn;
+  }
+  
+  public NameValueMap<String, String> getNameValueMap() {
+    NameValueMap<String, String> nvm = new NameValueMap<String, String>();
+    for (String key : this.nameValueMap.keySet()) {
+      nvm.addToCollection(key, this.nameValueMap.get(key));
+    }
+    return nvm;
+  }
+  
+  /**
+   * add key value to the directives map
+   * @param key
+   * @param value
+   */
+  public void addDirective(String key, String value) {
+    this.directives.put(key, value);
+  }
+  
+  public VersionRange getVersion() {
+    VersionRange vi = null;
+    if (this.attributes.get(Constants.VERSION_ATTRIBUTE) != null 
+        && this.attributes.get(Constants.VERSION_ATTRIBUTE).length() > 0) {
+      vi = ManifestHeaderProcessor.parseVersionRange(this.attributes.get(Constants.VERSION_ATTRIBUTE));
+    } else {
+      // what if version is not specified?  let's interpret it as 0.0.0 
+      vi = ManifestHeaderProcessor.parseVersionRange("0.0.0");
+    }
+    return vi;
+  }
+  
+  @Override
+  public String toString()
+  {
+    return this.contentName + ";" + this.nameValueMap.toString();
+  }
+  
+  @Override
+  public boolean equals(Object other)
+  {
+    if (other == this) return true;
+    if (other == null) return false;
+    
+    if (other instanceof ContentImpl) {
+      ContentImpl otherContent = (ContentImpl)other;
+      
+      Map<String,String> attributesWithoutVersion = attributes;
+      
+      if (attributes.containsKey("version")) {
+        attributesWithoutVersion = new HashMap<String, String>(attributes);
+        attributesWithoutVersion.remove("version");
+      }
+      
+      Map<String, String> otherAttributesWithoutVersion = otherContent.attributes;
+      
+      if (otherContent.attributes.containsKey("version")) {
+        otherAttributesWithoutVersion = new HashMap<String, String>(otherContent.attributes);
+        otherAttributesWithoutVersion.remove("version");
+      }
+      
+      return contentName.equals(otherContent.contentName) && 
+             attributesWithoutVersion.equals(otherAttributesWithoutVersion) &&
+             directives.equals(otherContent.directives) &&
+             getVersion().equals(otherContent.getVersion());
+    }
+    
+    return false;
+  }
+  
+  @Override
+  public int hashCode()
+  {
+    return contentName.hashCode();
+  }
+  
+  /**
+   * set up directives and attributes
+   */
+  protected void setup() {
+    this.attributes = new HashMap<String, String>();
+    this.directives = new HashMap<String, String>();
+    
+    for (String key : this.nameValueMap.keySet()) {
+      if (key.endsWith(":")) {
+        this.directives.put(key.substring(0, key.length() - 1), this.nameValueMap.get(key));
+      } else {
+        this.attributes.put(key, this.nameValueMap.get(key));
+      }
+    }
+  }
+}
+

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/ContentImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java Wed Apr 14 17:16:25 2010
@@ -0,0 +1,126 @@
+/*
+ * 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 WARRANTIESOR 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.aries.subsystem.core.obr;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+public class Manve2Repository {
+
+    private File rootFile;
+    public Manve2Repository(File rootFile) {
+        this.rootFile = rootFile;
+    }
+    // list jar files of the repository
+    public SortedSet<String> listFiles() {
+        SortedSet<String> artifacts = new TreeSet<String>();
+        File[] groupIds = rootFile.listFiles();
+        for (int i = 0; i < groupIds.length; i++) {
+            File groupId = groupIds[i];
+            if (groupId.canRead() && groupId.isDirectory()) {
+                File[] versionDirs = groupId.listFiles();
+                for (int j = 0; j < versionDirs.length; j++) {
+                    File versionDir = versionDirs[j];
+                    if (versionDir.canRead() && versionDir.isDirectory()) {
+                        artifacts.addAll(getArtifacts(null, versionDir, null, "jar", null));
+                    }
+                }
+            }
+        }
+        
+        return artifacts;
+    }
+    
+    // reuse code from apache geronimo with slight modification
+    private List<String> getArtifacts(String groupId, File versionDir, String artifactMatch, String typeMatch, String versionMatch) {
+        // org/apache/xbean/xbean-classpath/2.2-SNAPSHOT/xbean-classpath-2.2-SNAPSHOT.jar
+        List<String> artifacts = new ArrayList<String>();
+        String artifactId = versionDir.getParentFile().getName();
+
+        File[] files = versionDir.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File file = files[i];
+            if (file.canRead()) {
+                if (file.isDirectory()) {
+                    File test = new File(file, "META-INF");
+                    if(test.exists() && test.isDirectory() && test.canRead() && groupId != null) {
+                        String version = versionDir.getName();
+                        String fileHeader = artifactId + "-" + version + ".";
+
+                        String fileName = file.getName();
+                        if (fileName.startsWith(fileHeader)) {
+                            // type is everything after the file header
+                            String type = fileName.substring(fileHeader.length());
+
+                            if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
+                                if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
+                                    continue;
+                                }
+                                if(typeMatch != null && !typeMatch.equals(type)) {
+                                    continue;
+                                }
+                                if(versionMatch != null && !versionMatch.equals(version)) {
+                                    continue;
+                                }
+                                artifacts.add(file.getPath());
+                            }
+                        }
+                    } else { // this is just part of the path to the artifact
+                        String nextGroupId;
+                        if (groupId == null) {
+                            nextGroupId = artifactId;
+                        } else {
+                            nextGroupId = groupId + "." + artifactId;
+                        }
+
+                        artifacts.addAll(getArtifacts(nextGroupId, file, artifactMatch, typeMatch, versionMatch));
+                    }
+                } else if (groupId != null) {
+                    String version = versionDir.getName();
+                    String fileHeader = artifactId + "-" + version + ".";
+
+                    String fileName = file.getName();
+                    if (fileName.startsWith(fileHeader)) {
+                        // type is everything after the file header
+                        String type = fileName.substring(fileHeader.length());
+
+                        if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
+                            if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
+                                continue;
+                            }
+                            if(typeMatch != null && !typeMatch.equals(type)) {
+                                continue;
+                            }
+                            if(versionMatch != null && !versionMatch.equals(version)) {
+                                continue;
+                            }
+                            artifacts.add(file.getPath());
+                        }
+                    }
+                }
+            }
+        }
+        return artifacts;
+    }
+    
+}

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/Manve2Repository.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java Wed Apr 14 17:16:25 2010
@@ -0,0 +1,151 @@
+/*
+ * 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.aries.subsystem.core.obr;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.aries.application.Content;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.osgi.framework.Constants;
+import org.osgi.service.obr.Resource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+// copy from application obr with modification, intend to put this in common util folder when trunk becomes stable
+public final class RepositoryDescriptorGenerator
+{
+  public static Document generateRepositoryDescriptor(String name, Set<BundleInfo> bundles) throws ParserConfigurationException
+  {
+    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    Element root = doc.createElement("repository");
+    
+    root.setAttribute("name", name);
+    doc.appendChild(root);
+    
+    for (BundleInfo info : bundles) {
+      Element resource = doc.createElement("resource");
+      resource.setAttribute(Resource.VERSION, info.getVersion().toString());
+      resource.setAttribute("uri", info.getLocation());
+      resource.setAttribute(Resource.SYMBOLIC_NAME, info.getSymbolicName());
+      resource.setAttribute(Resource.PRESENTATION_NAME, info.getHeaders().get(Constants.BUNDLE_NAME));
+      resource.setAttribute(Resource.ID, info.getSymbolicName() + "/" + info.getVersion());
+      root.appendChild(resource);
+      
+      addBundleCapability(doc, resource, info);
+      
+      for (Content p : info.getExportPackage()) {
+        addPackageCapability(doc, resource, info, p);
+      }
+      
+      for (Content p : info.getImportPackage()) {
+        addPackageRequirement(doc, resource, info, p);
+      }
+      
+      for (Content p : info.getRequireBundle()) {
+        addBundleRequirement(doc, resource, info, p);
+      }
+      
+    }
+    
+    return doc;
+  }
+
+  private static void addBundleRequirement(Document doc, Element resource, BundleInfo info, Content p)
+  {
+    Element requirement = doc.createElement("require");
+    requirement.setAttribute("name", "bundle");
+    
+    requirement.setAttribute("extend", "false");
+    requirement.setAttribute("multiple", "false");
+    requirement.setAttribute("optional", "false");
+    
+    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("bundle", p.getContentName(), p.getAttributes()));
+    
+    resource.appendChild(requirement);
+  }
+
+  private static void addPackageRequirement(Document doc, Element resource, BundleInfo info, Content p)
+  {
+    Element requirement = doc.createElement("require");
+    requirement.setAttribute("name", "package");
+    
+    requirement.setAttribute("extend", "false");
+    requirement.setAttribute("multiple", "false");
+    
+    String optional = p.getDirective("optional");
+    if (optional == null) optional = "false";
+    
+    requirement.setAttribute("optional", optional);
+    
+    requirement.setAttribute("filter", ManifestHeaderProcessor.generateFilter("package", p.getContentName(), p.getAttributes()));
+    
+    resource.appendChild(requirement);
+  }
+
+  private static void addPackageCapability(Document doc, Element resource, BundleInfo info, Content p)
+  {
+    Element capability = doc.createElement("capability");
+    capability.setAttribute("name", "package");
+    resource.appendChild(capability);
+    
+    addProperty(doc, capability, "package", p.getContentName(), null);
+    addProperty(doc, capability, Constants.VERSION_ATTRIBUTE, p.getVersion().toString(), "version");
+    addProperty(doc, capability, Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, info.getSymbolicName(), null);
+    addProperty(doc, capability, Constants.BUNDLE_VERSION_ATTRIBUTE, info.getVersion().toString(), "version");
+    
+    for (Map.Entry<String, String> entry : p.getAttributes().entrySet()) {
+      if (!!!Constants.VERSION_ATTRIBUTE.equals(entry.getKey())) {
+        addProperty(doc, capability, entry.getKey(), entry.getValue(), null);
+      }
+    }
+    
+    String mandatory = p.getDirective(Constants.MANDATORY_DIRECTIVE);
+    if (mandatory == null) mandatory = "";
+    addProperty(doc, capability, Constants.MANDATORY_DIRECTIVE, mandatory, "set");
+  }
+
+  private static void addBundleCapability(Document doc, Element resource, BundleInfo info)
+  {
+    Element capability = doc.createElement("capability");
+    capability.setAttribute("name", "bundle");
+    resource.appendChild(capability);
+    
+    addProperty(doc, capability, Resource.SYMBOLIC_NAME, info.getSymbolicName(), null);
+    addProperty(doc, capability, Constants.VERSION_ATTRIBUTE, info.getVersion().toString(), "version");
+    addProperty(doc, capability, Resource.PRESENTATION_NAME, info.getHeaders().get(Constants.BUNDLE_NAME), null);
+    addProperty(doc, capability, Constants.BUNDLE_MANIFESTVERSION, "2", "version");
+    addProperty(doc, capability, Constants.FRAGMENT_ATTACHMENT_DIRECTIVE, info.getBundleDirectives().get(Constants.FRAGMENT_ATTACHMENT_DIRECTIVE), null);
+    addProperty(doc, capability, Constants.SINGLETON_DIRECTIVE, info.getBundleDirectives().get(Constants.SINGLETON_DIRECTIVE), null);
+  }
+
+  private static void addProperty(Document doc, Element capability, String name,
+      String value, String type)
+  {
+    Element p = doc.createElement("p");
+    p.setAttribute("n", name);
+    p.setAttribute("v", value);
+    if (type != null) p.setAttribute("t", type);
+    capability.appendChild(p);
+  }
+}
\ No newline at end of file

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/RepositoryDescriptorGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/aries/trunk/subsystem/subsystem-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/pom.xml?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/pom.xml (original)
+++ incubator/aries/trunk/subsystem/subsystem-itests/pom.xml Wed Apr 14 17:16:25 2010
@@ -63,6 +63,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.aries</groupId>
+            <artifactId>org.apache.aries.util</artifactId>
+            <scope>test</scope>
+        </dependency>        
+        <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam</artifactId>
             <scope>test</scope>
@@ -111,7 +116,21 @@
             <artifactId>pax-url-mvn</artifactId>
             <scope>test</scope>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.service.obr</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.bundlerepository</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

Added: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java (added)
+++ incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java Wed Apr 14 17:16:25 2010
@@ -0,0 +1,144 @@
+/*
+ * 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.aries.subsystem.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Currency;
+import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.aries.subsystem.Subsystem;
+import org.apache.aries.subsystem.SubsystemAdmin;
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.composite.CompositeAdmin;
+
+
+@RunWith(JUnit4TestRunner.class)
+public class SubsystemAdmin2Test extends AbstractIntegrationTest {
+
+    /* Use @Before not @BeforeClass so as to ensure that these resources
+     * are created in the paxweb temp directory, and not in the svn tree 
+     */
+    static boolean createdApplications = false;
+    @Before
+    public static void createApplications() throws Exception {
+      if (createdApplications) { 
+        return;
+      }
+
+      ZipFixture testEba = ArchiveFixture.newZip();
+      
+      testEba = testEba.binary("META-INF/MANIFEST.MF", 
+              SubsystemAdminTest.class.getClassLoader().getResourceAsStream("subsystem2/META-INF/MANIFEST.MF"))
+          .end();
+      FileOutputStream fout = new FileOutputStream("test.eba");
+      testEba.writeOut(fout);
+      fout.close();
+      createdApplications = true;
+    }
+    
+    @Test
+    public void test() throws Exception {
+        // make sure we are using a framework that provides composite admin service
+        CompositeAdmin ca = getOsgiService(CompositeAdmin.class);
+        assertNotNull("composite admin should not be null", ca);
+        System.out.println("able to get composite admin service");
+        
+        // obtain subsystem admin service
+        SubsystemAdmin sa = getOsgiService(SubsystemAdmin.class);
+        assertNotNull("subsystem admin should not be null", sa);
+        System.out.println("able to get subsytem admin service");
+        
+        File f = new File("test.eba");
+        Subsystem subsystem = sa.install(f.toURI().toURL().toExternalForm());
+        assertNotNull("subsystem should not be null", subsystem);
+        
+        assertTrue("subsystem should have a unique id", subsystem.getSubsystemId() > 0);
+        assertTrue(subsystem.getLocation().indexOf("test.eba") != -1);
+        assertEquals("felix-file-install2", subsystem.getSymbolicName());
+        assertEquals("2.0.8", subsystem.getVersion().toString());
+        Collection<Bundle> constituents = subsystem.getConstituents();
+        assertEquals("check constituents' size", 1, constituents.size());
+
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+            // Bundles
+            mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+            mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+            mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
+            mavenBundle("org.apache.aries.subsystem", "org.apache.aries.subsystem.api"),
+            mavenBundle("org.apache.aries.subsystem", "org.apache.aries.subsystem.core"),
+
+            //org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
+
+            equinox().version("v43prototype-3.6.0.201003231329")
+        );
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Propchange: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java (original)
+++ incubator/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java Wed Apr 14 17:16:25 2010
@@ -80,6 +80,8 @@ public class SubsystemAdminTest extends 
       testEba.writeOut(fout);
       fout.close();
       createdApplications = true;
+      
+      
     }
     
     @Test
@@ -100,8 +102,8 @@ public class SubsystemAdminTest extends 
         
         assertTrue("subsystem should have a unique id", subsystem.getSubsystemId() > 0);
         assertTrue(subsystem.getLocation().indexOf("test.eba") != -1);
-        assertEquals("woodstox", subsystem.getSymbolicName());
-        assertEquals("4.0.7", subsystem.getVersion().toString());
+        assertEquals("felix-file-install", subsystem.getSymbolicName());
+        assertEquals("2.0.8", subsystem.getVersion().toString());
         Collection<Bundle> constituents = subsystem.getConstituents();
         assertEquals("check constituents' size", 1, constituents.size());
 
@@ -123,9 +125,14 @@ public class SubsystemAdminTest extends 
             systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
 
             // Bundles
+            mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.application", "org.apache.aries.application.api"),
+            mavenBundle("org.apache.aries.application", "org.apache.aries.application.utils"),
+            mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
             mavenBundle("org.apache.aries.subsystem", "org.apache.aries.subsystem.api"),
             mavenBundle("org.apache.aries.subsystem", "org.apache.aries.subsystem.core"),
-            mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+
             //org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
 
             PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),

Modified: incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem1/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem1/META-INF/MANIFEST.MF?rev=934020&r1=934019&r2=934020&view=diff
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem1/META-INF/MANIFEST.MF (original)
+++ incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem1/META-INF/MANIFEST.MF Wed Apr 14 17:16:25 2010
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 Subsystem-ManifestVersion: 1.0
-Subsystem-SymbolicName: woodstox
-Subsystem-Version: 4.0.7
-Subsystem-Content: stax-api;location=mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.4.0
+Subsystem-SymbolicName: felix-file-install
+Subsystem-Version: 2.0.8
+Subsystem-Content: org.apache.felix.fileinstall;version=2.0.8;location=mvn:org.apache.felix/org.apache.felix.fileinstall/2.0.8
 

Added: incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/MANIFEST.MF?rev=934020&view=auto
==============================================================================
--- incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/subsystem/subsystem-itests/src/test/resources/subsystem2/META-INF/MANIFEST.MF Wed Apr 14 17:16:25 2010
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Subsystem-ManifestVersion: 1.0
+Subsystem-SymbolicName: felix-file-install2
+Subsystem-Version: 2.0.8
+Subsystem-Content: org.apache.felix.fileinstall;version=2.0.8
+
+



Mime
View raw message