incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r989620 - in /incubator/aries/trunk/application/application-utils/src/main: java/org/apache/aries/application/impl/ java/org/apache/aries/application/utils/ java/org/apache/aries/application/utils/filesystem/impl/ java/org/apache/aries/appl...
Date Thu, 26 Aug 2010 11:58:36 GMT
Author: mnuttall
Date: Thu Aug 26 11:58:36 2010
New Revision: 989620

URL: http://svn.apache.org/viewvc?rev=989620&view=rev
Log:
ARIES-361: Provisioning changes required to support application isolation. From a patch submitted
by Emily Jiang.

Added:
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/FilterUtils.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/DefaultPlatformRepository.java
Modified:
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/ZipDirectory.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/management/SimpleBundleInfo.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/manifest/ManifestHeaderProcessor.java
    incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/NoOpResolver.java
    incubator/aries/trunk/application/application-utils/src/main/resources/OSGI-INF/blueprint/app-utils.xml

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ApplicationMetadataImpl.java
Thu Aug 26 11:58:36 2010
@@ -23,6 +23,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -36,8 +37,12 @@ import org.apache.aries.application.Appl
 import org.apache.aries.application.Content;
 import org.apache.aries.application.ServiceDeclaration;
 import org.apache.aries.application.utils.AppConstants;
-import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of ApplicationMetadata and DeploymentMetadata
@@ -45,6 +50,7 @@ import org.osgi.framework.Version;
  */
 public final class ApplicationMetadataImpl implements ApplicationMetadata
 {
+  private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management.impl");
   private String appSymbolicName;
   private Version appVersion;
   private String appName;
@@ -53,7 +59,7 @@ public final class ApplicationMetadataIm
   private List<ServiceDeclaration> importServices;
   private List<ServiceDeclaration> exportServices;
   private Manifest manifest;
-  
+  private List<Content> useBundle;
   /**
    * create the applicationMetadata from appManifest
    * @param appManifest   the Application.mf manifest
@@ -61,8 +67,9 @@ public final class ApplicationMetadataIm
   public ApplicationMetadataImpl(Manifest appManifest) {
 
     this.appContents = new ArrayList<Content>();
+    this.useBundle = new ArrayList<Content>();    
     this.importServices = new ArrayList<ServiceDeclaration>();
-    this.exportServices = new ArrayList<ServiceDeclaration>();
+    this.exportServices = new ArrayList<ServiceDeclaration>();    
     setup(appManifest);
     
     // As of 7 Jan 2010 we have no setter methods. Hence it's currently 
@@ -90,13 +97,42 @@ public final class ApplicationMetadataIm
     }
     
     // configure appContents
+ // use parseImportString as we don't allow appContents to be duplicate
     String applicationContents = appMap.get(AppConstants.APPLICATION_CONTENT);
-    List<String> appContentsArray = ManifestProcessor.split(applicationContents, ",");
-    for (String content : appContentsArray) {
-      this.appContents.add(new ContentImpl(content));
+    Map<String, NameValueMap<String, String>> appContentsMap = ManifestHeaderProcessor.parseImportString(applicationContents);
+    for (Map.Entry<String, NameValueMap<String, String>> e : appContentsMap.entrySet())
{
+      this.appContents.add(new ContentImpl(e.getKey(), e.getValue()));
+    }
+   
+    String useBundleStr = appMap.get(AppConstants.APPLICATION_USE_BUNDLE);
+    if (useBundleStr != null) {
+      Map<String, NameValueMap<String, String>> useBundleMap = ManifestHeaderProcessor.parseImportString(useBundleStr);
+    for (Map.Entry<String, NameValueMap<String, String>> e : useBundleMap.entrySet())
{
+        this.useBundle.add(new ContentImpl(e.getKey(), e.getValue()));
+      }
     }
     
-    // TODO: configure importServices + exportServices
+    String allServiceImports = appMap.get(AppConstants.APPLICATION_IMPORT_SERVICE);
+    List<String> serviceImports = ManifestHeaderProcessor.split(allServiceImports,
",");
+    for (String s: serviceImports) { 
+      try { 
+        ServiceDeclaration dec = new ServiceDeclarationImpl(s);
+        importServices.add(dec);
+      } catch (InvalidSyntaxException ise) { 
+        _logger.warn("APPUTILS0013E", new Object[] {s, appSymbolicName});
+      }
+    }
+    
+    String allServiceExports = appMap.get(AppConstants.APPLICATION_EXPORT_SERVICE);
+    List<String> serviceExports = ManifestHeaderProcessor.split(allServiceExports,
",");
+    for (String s: serviceExports) { 
+      try { 
+        ServiceDeclaration dec = new ServiceDeclarationImpl(s);
+        exportServices.add(dec);
+      } catch (InvalidSyntaxException ise) { 
+        _logger.warn("APPUTILS0014E", new Object[] {s, appSymbolicName});
+      }
+    }
     
   }
   
@@ -193,4 +229,9 @@ public final class ApplicationMetadataIm
       manifest.write(out);
     }
   }
+
+  public Collection<Content> getUseBundles()
+  {
+    return this.useBundle;
+  }
 }
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ContentImpl.java
Thu Aug 26 11:58:36 2010
@@ -66,6 +66,12 @@ public final class ContentImpl implement
     setup();
   }
   
+  public ContentImpl (String bundleSymbolicName, VersionRange version) { 
+    this.contentName = bundleSymbolicName;
+    this.nameValueMap = new NameValueMap<String, String>();
+    nameValueMap.put("version", version.toString());
+    setup();
+  }
   /**
    * 
    * @param contentName  

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataFactoryImpl.java
Thu Aug 26 11:58:36 2010
@@ -29,6 +29,7 @@ import org.apache.aries.application.Depl
 import org.apache.aries.application.filesystem.IFile;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.InvalidAttributeException;
 import org.apache.aries.application.management.ResolverException;
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
 
@@ -58,7 +59,11 @@ public class DeploymentMetadataFactoryIm
 
   public DeploymentMetadata createDeploymentMetadata(Manifest manifest) throws IOException
   {
-    return new DeploymentMetadataImpl(manifest);
+    try {
+      return new DeploymentMetadataImpl(manifest);
+    } catch (InvalidAttributeException iae) {
+      throw new IOException(iae);
+    }
   }
 
   public DeploymentMetadata createDeploymentMetadata(IFile src) throws IOException

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
Thu Aug 26 11:58:36 2010
@@ -25,8 +25,10 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -40,21 +42,33 @@ import org.apache.aries.application.Depl
 import org.apache.aries.application.VersionRange;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.InvalidAttributeException;
 import org.apache.aries.application.management.ResolverException;
 import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.FilterUtils;
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 
 public class DeploymentMetadataImpl implements DeploymentMetadata {
   private ApplicationMetadata _applicationMetadata;
   private List<DeploymentContent> _deploymentContent = new ArrayList<DeploymentContent>();
   private List<DeploymentContent> _provisionSharedContent = new ArrayList<DeploymentContent>();
+  private List<DeploymentContent> _deployedUseBundleContent = new ArrayList<DeploymentContent>();
+  
+  private Set<Content> _deploymentImportPackage = new HashSet<Content>();
+  private Map<String, String> _deploymentCustomEntries = new HashMap<String, String>();
 
+  private Map<String, String> _deploymentEntries = new HashMap<String, String>();
+  private Collection<Filter> _deployedImportService = new ArrayList<Filter>();
   
   public DeploymentMetadataImpl (AriesApplication app, Set<BundleInfo> bundlesRequired)
throws ResolverException
   {
     _applicationMetadata = app.getApplicationMetadata();
     _deploymentContent = new ArrayList<DeploymentContent>();
     _provisionSharedContent = new ArrayList<DeploymentContent>();
+    _deployedUseBundleContent = new ArrayList<DeploymentContent>();
     
     Map<String, VersionRange> appContent = new HashMap<String, VersionRange>();
     
@@ -62,18 +76,26 @@ public class DeploymentMetadataImpl impl
       appContent.put(c.getContentName(), c.getVersion());
     }
     
+    Map<String, VersionRange> useBundles = new HashMap<String, VersionRange>();
+    for (Content c : app.getApplicationMetadata().getUseBundles()) {
+      useBundles.put(c.getContentName(), c.getVersion());
+    }
+    
     for (BundleInfo info : bundlesRequired) {
       
-      VersionRange range = appContent.get(info.getSymbolicName());
-      
+      VersionRange appContentRange = appContent.get(info.getSymbolicName());
+      VersionRange useBundleRange = useBundles.get(info.getSymbolicName());
       DeploymentContent dp = new DeploymentContentImpl(info.getSymbolicName(), info.getVersion());
       
-      if (range == null) {
+      if ((appContentRange == null) && (useBundleRange == null)){
         _provisionSharedContent.add(dp);
-      } else if (range.matches(info.getVersion())) {
+      } else if (appContentRange.matches(info.getVersion())) {
         _deploymentContent.add(dp);
-      } else {
-        throw new ResolverException("Bundle " + info.getSymbolicName() + " at version " +
info.getVersion() + " is not in the range " + range);
+      }  else if (useBundleRange.matches(info.getVersion())) {
+        _deployedUseBundleContent.add(dp);
+      }
+      else {
+        throw new ResolverException("Bundle " + info.getSymbolicName() + " at version " +
info.getVersion() + " is not in the range " + appContentRange + " or " + useBundleRange);
       }
     }
   }
@@ -83,15 +105,86 @@ public class DeploymentMetadataImpl impl
    * @param src
    * @throws IOException
    */
-  public DeploymentMetadataImpl(Manifest mf) { 
+  public DeploymentMetadataImpl(Manifest mf) throws InvalidAttributeException{ 
     _applicationMetadata = new ApplicationMetadataImpl (mf);
 
     Attributes attributes = mf.getMainAttributes();
       
-    parseContent(attributes.getValue(AppConstants.DEPLOYMENT_CONTENT), _deploymentContent);
-    parseContent(attributes.getValue(AppConstants.PROVISION_CONTENT), _provisionSharedContent);
+    parseDeploymentContent(attributes.getValue(AppConstants.DEPLOYMENT_CONTENT), _deploymentContent);
+    parseDeploymentContent(attributes.getValue(AppConstants.DEPLOYMENT_PROVISION_BUNDLE),
_provisionSharedContent);
+    parseDeploymentContent(attributes.getValue(AppConstants.DEPLOYMENT_USE_BUNDLE), _deployedUseBundleContent);
+    parseContent(attributes.getValue(AppConstants.DEPLOYMENT_IMPORT_PACKAGES), _deploymentImportPackage);
+    
+    _deployedImportService = getFilters(attributes.getValue(AppConstants.DEPLOYMENTSERVICE_IMPORT));
+    _deploymentCustomEntries = getCustomEntries(attributes);
+    _deploymentEntries = getEntries(attributes);
+  }
+  
+  public DeploymentMetadataImpl(Map<String, String> map) throws InvalidAttributeException{

+
+    Attributes attributes = new Attributes();
+    if (map != null) {
+    for (Map.Entry<String, String> entry : map.entrySet()) {
+      attributes.putValue(entry.getKey(), entry.getValue());
+    }
+    }
+    parseDeploymentContent(map.get(AppConstants.DEPLOYMENT_CONTENT), _deploymentContent);
+    parseDeploymentContent(map.get(AppConstants.DEPLOYMENT_PROVISION_BUNDLE), _provisionSharedContent);
+    parseDeploymentContent(map.get(AppConstants.DEPLOYMENT_USE_BUNDLE), _deployedUseBundleContent);
+    parseContent(attributes.getValue(AppConstants.DEPLOYMENT_IMPORT_PACKAGES), _deploymentImportPackage);
+    _deployedImportService = getFilters(attributes.getValue(AppConstants.DEPLOYMENTSERVICE_IMPORT));
+    _deploymentCustomEntries = getCustomEntries(attributes);
+    _deploymentEntries = getEntries(attributes);
+    
+  }
+
+  private Collection<Attributes.Name> getDeploymentStandardHeaders() {
+    Collection<Attributes.Name> standardKeys = new HashSet<Attributes.Name> ();
+    standardKeys.add(new Attributes.Name(AppConstants.APPLICATION_MANIFEST_VERSION));
+    standardKeys.add(new Attributes.Name(AppConstants.DEPLOYMENT_CONTENT));
+    standardKeys.add(new Attributes.Name(AppConstants.DEPLOYMENT_PROVISION_BUNDLE));
+    standardKeys.add(new Attributes.Name(AppConstants.DEPLOYMENT_USE_BUNDLE));
+    standardKeys.add(new Attributes.Name(AppConstants.DEPLOYMENT_IMPORT_PACKAGES));
+    standardKeys.add(new Attributes.Name(AppConstants.DEPLOYMENTSERVICE_IMPORT));
+    standardKeys.add(new Attributes.Name(AppConstants.APPLICATION_SYMBOLIC_NAME));
+    standardKeys.add(new Attributes.Name(AppConstants.APPLICATION_VERSION));
+    return standardKeys;
   }
 
+  private Collection<String> getCustomHeaders(Attributes attrs) {
+    
+    Collection<String> customKeys = new HashSet<String>();
+    Collection<Attributes.Name> standardKeys = getDeploymentStandardHeaders();
+    if ((attrs != null) && (!!!attrs.isEmpty())) {
+     Set<Object> keys = attrs.keySet();
+     
+     if ((keys != null) && (!!!keys.isEmpty())) {
+       for (Object eachKey : keys) {
+         String key = eachKey.toString();
+         customKeys.add(key);
+       }
+       
+         customKeys.removeAll(standardKeys);
+       
+     }
+    }
+    return customKeys;
+  }
+  
+  private String getContentsAsString (Collection<Content> contents) {
+    StringBuilder builder = new StringBuilder();
+    boolean beginning = true;
+    for (Content c : contents) {
+      if (!!!beginning) {
+        builder.append(",");
+      }
+      builder.append(c);
+      beginning = false;
+      
+    }
+    return builder.toString();
+  }
+  
   public List<DeploymentContent> getApplicationDeploymentContents() {
     return Collections.unmodifiableList(_deploymentContent);
   }
@@ -126,11 +219,26 @@ public class DeploymentMetadataImpl impl
     attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), AppConstants.MANIFEST_VERSION);
     attributes.putValue(AppConstants.APPLICATION_VERSION, getApplicationVersion().toString());
     attributes.putValue(AppConstants.APPLICATION_SYMBOLIC_NAME, getApplicationSymbolicName());
-    if (!_deploymentContent.isEmpty()) {
+    if ((_deploymentContent != null) && (!_deploymentContent.isEmpty())) {
       attributes.putValue(AppConstants.DEPLOYMENT_CONTENT, getDeploymentContentsAsString(_deploymentContent));
     }
-    if (!_provisionSharedContent.isEmpty()) {
-      attributes.putValue(AppConstants.PROVISION_CONTENT, getDeploymentContentsAsString(_provisionSharedContent));
+    if ((_provisionSharedContent != null) && (!_provisionSharedContent.isEmpty()))
{
+      attributes.putValue(AppConstants.DEPLOYMENT_PROVISION_BUNDLE, getDeploymentContentsAsString(_provisionSharedContent));
+    }
+    if ((_deployedUseBundleContent != null) && (!_deployedUseBundleContent.isEmpty()))
{
+      attributes.putValue(AppConstants.DEPLOYMENT_USE_BUNDLE, getDeploymentContentsAsString(_deployedUseBundleContent));
+    }
+    if ((_deploymentImportPackage != null) && (!_deploymentImportPackage.isEmpty()))
{
+      attributes.putValue(AppConstants.DEPLOYMENT_IMPORT_PACKAGES, getContentsAsString(_deploymentImportPackage));
+    }
+    if ((_deployedImportService != null) && (!!!_deployedImportService.isEmpty()))
{
+      attributes.putValue(AppConstants.DEPLOYMENTSERVICE_IMPORT, convertFiltersToString(_deployedImportService,
",") );
+    }
+    // let's write out the custom headers
+    if ((_deploymentCustomEntries != null) && (_deploymentCustomEntries.isEmpty()))
{
+      for (Map.Entry<String, String> customEntry : _deploymentCustomEntries.entrySet())
{
+        attributes.putValue(customEntry.getKey(), customEntry.getValue());
+      }
     }
     mf.write(out);
   }
@@ -151,7 +259,7 @@ public class DeploymentMetadataImpl impl
     return builder.toString();
   }
 
-  private void parseContent(String content, List<DeploymentContent> contents)
+  private void parseDeploymentContent(String content, List<DeploymentContent> contents)
   {
     List<String> pcList = ManifestProcessor.split(content, ",");
     for (String s : pcList) {
@@ -159,13 +267,88 @@ public class DeploymentMetadataImpl impl
     }
   }
 
+  private void parseContent(String content, Collection<Content> contents)
+  {
+    List<String> pcList = ManifestProcessor.split(content, ",");
+    for (String s : pcList) {
+      contents.add(new ContentImpl(s));
+    }
+  }
+  
+
   public List<DeploymentContent> getDeployedUseBundle()
   {
-    return new ArrayList<DeploymentContent>();
+    return Collections.unmodifiableList(_deployedUseBundleContent);
   }
 
   public Set<Content> getImportPackage()
   {
-    return null;
+    return Collections.unmodifiableSet(_deploymentImportPackage);
   }
+
+  public Collection<Filter> getDeployedServiceImport() throws InvalidAttributeException
+  {
+    return Collections.unmodifiableCollection(_deployedImportService);
+  }
+
+  public Map<String, String> getHeaders()
+  {
+    return Collections.unmodifiableMap(_deploymentEntries);
+  }
+  
+  private Map<String, String> getEntries(Attributes attrs) {
+    Map<String, String> entries = new HashMap<String, String>();
+    if ((attrs != null) && (!attrs.isEmpty())) {
+      Set<Object> keys = attrs.keySet();
+      for (Object key : keys) {
+        entries.put(key.toString(),  attrs.getValue((Attributes.Name)key));
+      }
+    }
+    return entries;
+  }
+ 
+
+  private Map<String, String> getCustomEntries(Attributes attrs) {
+    Map<String, String> customEntry = new HashMap<String, String> ();
+    Collection<String> customHeaders = getCustomHeaders(attrs);
+    if ((customHeaders != null) && (customHeaders.isEmpty())) {
+      for (String customHeader : customHeaders)
+        customEntry.put(customHeader, attrs.getValue(customHeader));
+      
+    }
+    return customEntry;
+    
+  }
+  
+   private Collection<Filter> getFilters(String filterString) throws InvalidAttributeException{
+     Collection<Filter> filters = new ArrayList<Filter>();
+     List<String> fs = ManifestProcessor.split(filterString, ",");
+     if ((fs != null) && (!!!fs.isEmpty())) {
+       for (String filter : fs) {
+         try {
+         filters.add(FrameworkUtil.createFilter(FilterUtils.removeMandatoryFilterToken(filter)));
+         } catch (InvalidSyntaxException ise) {
+           InvalidAttributeException iae = new InvalidAttributeException(ise);
+           throw iae;
+         }
+       }
+     }
+     return filters;
+   }
+  
+   private  String convertFiltersToString(Collection<Filter> contents, String separator)
{
+     StringBuilder newContent = new StringBuilder();
+     if ((contents != null) && (!!!contents.isEmpty())) {
+       boolean beginning = true;
+       for (Filter content: contents) {
+         if (beginning)
+           newContent.append(separator);
+         newContent.append(content.toString());
+         beginning = false;
+       }
+     }
+     return newContent.toString();
+   }
+   
+   
 }
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/impl/ServiceDeclarationImpl.java
Thu Aug 26 11:58:36 2010
@@ -18,13 +18,12 @@
  */
 package org.apache.aries.application.impl;
 
+import org.apache.aries.application.Content;
+import org.apache.aries.application.ServiceDeclaration;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 
-import org.apache.aries.application.Content;
-import org.apache.aries.application.ServiceDeclaration;
-
 /**
  * this class represents the Import-Services and Export-Services
  * in the Application.mf file
@@ -70,4 +69,29 @@ public class ServiceDeclarationImpl impl
   {
     return this.filter;
   }
+  @Override
+  public int hashCode()
+  {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((filter == null) ? 0 : filter.hashCode());
+    result = prime * result + ((interfaceName == null) ? 0 : interfaceName.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj)
+  {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    ServiceDeclarationImpl other = (ServiceDeclarationImpl) obj;
+    if (filter == null) {
+      if (other.filter != null) return false;
+    } else if (!filter.equals(other.filter)) return false;
+    if (interfaceName == null) {
+      if (other.interfaceName != null) return false;
+    } else if (!interfaceName.equals(other.interfaceName)) return false;
+    return true;
+  }
 }

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
Thu Aug 26 11:58:36 2010
@@ -27,8 +27,9 @@ public interface AppConstants
   /** Trace group for this bundle */
   public String TRACE_GROUP = "Aries.app.utils";
 
-  /** The Provision-Content header for the deployment.mf */
-  public static final String PROVISION_CONTENT = "Provision-Bundle";
+
+  /** The Manifest version */
+  public static final String APPLICATION_MANIFEST_VERSION="Manifest-Version";
   
   /** The application scope (used to find the applications bundle repository */
   public static final String APPLICATION_SCOPE = "Application-Scope";
@@ -60,12 +61,24 @@ public interface AppConstants
   public static final String MANIFEST_MF = "META-INF/MANIFEST.MF";
   
   public static final String MANIFEST_VERSION="1.0";
-  
+  /** The application import service directive for the application manifest */
+  public static final String APPLICATION_IMPORT_SERVICE = "Application-ImportService";
+  /** The application export service directive for the application manifest */
+  public static final String APPLICATION_EXPORT_SERVICE = "Application-ExportService"; 
+  /** The use-bundle entry for the application manifest. */
+  public static final String APPLICATION_USE_BUNDLE = "Use-Bundle";
   /* The Deployed-Content header in DEPLOYMENT.MF records all the bundles
    * to be deployed for a particular application. 
    */
   public static final String DEPLOYMENT_CONTENT = "Deployed-Content";
-  
+  /** deployment.mf entry corresponding to application.mf Use-Bundle. */
+  public static final String DEPLOYMENT_USE_BUNDLE = "Deployed-Use-Bundle";
+  /** deployment.mf entry 'Import-Package' */
+  public static final String DEPLOYMENT_IMPORT_PACKAGES="Import-Package";
+  /** Bundle dependencies required by bundles listed in Deployed-Content or Deployed-Use-Bundle.
*/
+  public static final String DEPLOYMENT_PROVISION_BUNDLE = "Provision-Bundle";  
+  /** Blueprint managed services imported by the isolated bundles */ 
+  public static final String DEPLOYMENTSERVICE_IMPORT = "DeployedService-Import";
   /**
    * Logging insert strings
    */

Added: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/FilterUtils.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/FilterUtils.java?rev=989620&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/FilterUtils.java
(added)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/FilterUtils.java
Thu Aug 26 11:58:36 2010
@@ -0,0 +1,63 @@
+/*
+ * @start_prolog@
+ * ============================================================================
+ * IBM Confidential OCO Source Materials
+ *
+ * 5724-J08, 5724-I63, 5724-H88, 5724-H89, 5655-N02, 5733-W70 Copyright IBM Corp. 2010
+ *
+ * The source code for this program is not published or otherwise divested
+ * of its trade secrets, irrespective of what has been deposited with the
+ * U.S. Copyright Office.
+ * ============================================================================
+ * @end_prolog@
+ * 
+ * Change activity:
+ * 
+ * Issue       Date        Name        Description
+ * ----------- ----------- --------    ------------------------------------
+ */
+package org.apache.aries.application.utils;
+
+import static org.apache.aries.application.utils.AppConstants.LOG_ENTRY;
+import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;
+
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+public class FilterUtils
+{
+  private static final Pattern regexp = Pattern.compile("\\(mandatory:.*?\\)");
+
+  private static final  Logger logger = LoggerFactory.getLogger(FilterUtils.class);
+  /**
+   * Filters we generate may contain stanzas like (mandatory:<*symbolicname)
+   * These are for OBR, and are not OSGi friendly!!! This method removes them.
+   * 
+   * @param filter
+   * @return A filter with the mandatory stanzas removed or null if a null filter is supplied
+   */
+  public static String removeMandatoryFilterToken(String filter) {
+    logger.debug(LOG_ENTRY, "areMandatoryAttributesPresent", new Object[]{filter});
+    if(filter != null) {
+      filter = regexp.matcher(filter).replaceAll("");
+    
+      int openBraces = 0;
+      for (int i=0; openBraces < 3; i++) {
+        i = filter.indexOf('(', i);
+        if (i == -1) { 
+          break;
+        } else { 
+          openBraces++;
+        }
+      }
+      // Need to prune (& or (| off front and ) off end
+      if (openBraces < 3 && 
+          (filter.startsWith("(&") || filter.startsWith("(|"))) { 
+        filter = filter.substring(2, filter.length() - 1);
+      }
+    }
+    logger.debug(LOG_EXIT, "removeMandatoryFilterToken", filter);
+    return filter;
+  }
+}

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/DirectoryImpl.java
Thu Aug 26 11:58:36 2010
@@ -28,7 +28,6 @@ import java.util.List;
 
 import org.apache.aries.application.filesystem.IDirectory;
 import org.apache.aries.application.filesystem.IFile;
-import org.apache.aries.application.utils.AppConstants;
 
 /**
  * An IDirectory representing a java.io.File whose isDirectory method returns true.
@@ -81,6 +80,37 @@ public class DirectoryImpl extends FileI
     }
     return files;
   }
+  public List<IFile> listAllFiles()
+  {
+    List<IFile> files = new ArrayList<IFile>();
+    File[] filesInDir = file.listFiles();
+    if (filesInDir != null) {
+      for (File f : filesInDir) {
+        if (f.isFile()) {
+          files.add(new FileImpl(f, rootDirFile));
+        } else if (f.isDirectory()) {
+          files.add(new DirectoryImpl(f, rootDirFile));
+          listSubDirectoryFiles(files, f);
+        }
+      }
+    }
+    return files;
+  }
+  
+  private void listSubDirectoryFiles(List<IFile> lists, File file) {
+    File[] filesInDir = file.listFiles();
+    if (filesInDir != null) {
+      for (File f : filesInDir) {
+        if (f.isFile()) {
+          lists.add(new FileImpl(f, rootDirFile));
+        } else if (f.isDirectory()) {
+          lists.add(new DirectoryImpl(f, rootDirFile));
+          listSubDirectoryFiles(lists, f);
+        }
+      }
+    }
+    
+  }
 
   public Iterator<IFile> iterator()
   {

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/ZipDirectory.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/ZipDirectory.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/ZipDirectory.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/impl/ZipDirectory.java
Thu Aug 26 11:58:36 2010
@@ -141,6 +141,25 @@ public class ZipDirectory extends ZipFil
     return files;
   }
 
+  public List<IFile> listAllFiles()
+  {
+    List<IFile> files = new ArrayList<IFile>();
+
+    ZipFile z = openZipFile();
+    Enumeration<? extends ZipEntry> entries = z.entries();
+
+    while (entries.hasMoreElements()) {
+      ZipEntry possibleEntry = entries.nextElement();
+      if (possibleEntry.isDirectory()) {
+        files.add(new ZipDirectory(zip, possibleEntry, this));
+      } else {
+        files.add(new ZipFileImpl(zip, possibleEntry, this));
+      }
+      
+    }
+    closeZipFile(z);
+    return files;
+  }
   /**
    * This method works out if the provided entry is inside this directory. It
    * returns false if it is not, or if it is in a sub-directory.

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/management/SimpleBundleInfo.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/management/SimpleBundleInfo.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/management/SimpleBundleInfo.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/management/SimpleBundleInfo.java
Thu Aug 26 11:58:36 2010
@@ -161,4 +161,9 @@ public final class SimpleBundleInfo impl
   {
     return _contentName.getContentName() + "_" + getVersion();
   }
+  public Attributes getRawAttributes()
+  {
+    
+    return _attributes;
+  }
 }
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/manifest/ManifestHeaderProcessor.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/manifest/ManifestHeaderProcessor.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/manifest/ManifestHeaderProcessor.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/manifest/ManifestHeaderProcessor.java
Thu Aug 26 11:58:36 2010
@@ -28,7 +28,9 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.aries.application.Content;
 import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.impl.ContentImpl;
 import org.apache.aries.application.impl.VersionRangeImpl;
 import org.apache.aries.application.utils.internal.MessageUtil;
 import org.osgi.framework.Constants;
@@ -690,5 +692,26 @@ public class ManifestHeaderProcessor
     }
     return result;
   }
+  
+  /**
+   * Parse a content object
+   * @param bundleSymbolicName bundle symbolic name
+   * @param versionRange version range in the String format
+   * @return Content object
+   */
+  public static Content parseContent(String bundleSymbolicName, String versionRange) {
+    return new ContentImpl(bundleSymbolicName, parseVersionRange(versionRange));
+  }
+  
+  /**
+   * Parse a content
+   * @param contentName The content name
+   * @param nameValueMap The map containing the content attributes/directives
+   * @return a content object
+   */
+  public static Content parseContent(String contentName, NameValueMap<String, String>
nameValueMap) {
+    return new ContentImpl(contentName, nameValueMap);
+  }
+
 }
 

Added: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/DefaultPlatformRepository.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/DefaultPlatformRepository.java?rev=989620&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/DefaultPlatformRepository.java
(added)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/DefaultPlatformRepository.java
Thu Aug 26 11:58:36 2010
@@ -0,0 +1,35 @@
+
+
+/*
+ * 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.application.utils.runtime;
+import java.net.URI;
+import java.util.Collection;
+
+import org.apache.aries.application.management.PlatformRepository;
+
+public class DefaultPlatformRepository implements PlatformRepository
+{
+  public Collection<URI> getPlatformRepositoryURLs()
+  {
+    return null;
+  }
+
+}

Modified: incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/NoOpResolver.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/NoOpResolver.java?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/NoOpResolver.java
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/java/org/apache/aries/application/utils/runtime/NoOpResolver.java
Thu Aug 26 11:58:36 2010
@@ -18,17 +18,17 @@
  */
 package org.apache.aries.application.utils.runtime;
 
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collection;
 import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
+import org.apache.aries.application.Content;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.AriesApplicationResolver;
 import org.apache.aries.application.management.BundleInfo;
 import org.apache.aries.application.management.ResolveConstraint;
+import org.apache.aries.application.management.ResolverException;
+import org.apache.aries.application.modelling.ModelledResource;
 import org.osgi.framework.Version;
 
 /** AriesApplicationManager requires that there be at least one 
@@ -59,4 +59,12 @@ public class NoOpResolver implements Ari
     }
     return result;
   }
+
+  public Collection<ModelledResource> resolve(String appName, String appVersion,
+      Collection<ModelledResource> byValueBundles, Collection<Content> inputs)
+      throws ResolverException
+  {
+    
+    return byValueBundles;
+  }
 }
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-utils/src/main/resources/OSGI-INF/blueprint/app-utils.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-utils/src/main/resources/OSGI-INF/blueprint/app-utils.xml?rev=989620&r1=989619&r2=989620&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-utils/src/main/resources/OSGI-INF/blueprint/app-utils.xml
(original)
+++ incubator/aries/trunk/application/application-utils/src/main/resources/OSGI-INF/blueprint/app-utils.xml
Thu Aug 26 11:58:36 2010
@@ -37,5 +37,7 @@
   <service interface="org.apache.aries.application.management.AriesApplicationResolver"

             ref="no-op-resolver"
             ranking="-1" />
+  <bean id="default-platform-repository" class="org.apache.aries.application.utils.runtime.DefaultPlatformRepository"/>
+  <service interface="org.apache.aries.application.management.PlatformRepository" ref="default-platform-repository"
ranking="-1"/>
             
 </blueprint>



Mime
View raw message