aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alasdair Nottingham <...@apache.org>
Subject Re: svn commit: r957403 - in /incubator/aries/trunk/application: ./ application-itests/src/test/java/org/apache/aries/application/runtime/itests/ application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/
Date Fri, 25 Jun 2010 16:43:51 GMT
Hi,

I had deliberately excluded the local repository from the resolve when
I update the resolver. The reason I excluded it is because if the
resource is local you don't get information about the bundle back so
you cannot store it in the deployment.mf. The result is that the
application cannot be deployed to a different framework. I want to go
back to removing the local repo so we can get the deployment.mf to
correctly reflect the bundles that are needed to run the application.

Alasdair

On 24 June 2010 03:23,  <gawor@apache.org> wrote:
> Author: gawor
> Date: Thu Jun 24 02:23:38 2010
> New Revision: 957403
>
> URL: http://svn.apache.org/viewvc?rev=957403&view=rev
> Log:
> ARIES-341: Add option for controlling whether optional resources should be included in
the resolved BundleInfo set. Also, ensure system and local repositories are included in repository
set used in resolver
>
> Modified:
>    incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
>    incubator/aries/trunk/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java
>    incubator/aries/trunk/application/pom.xml
>
> Modified: incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java?rev=957403&r1=957402&r2=957403&view=diff
> ==============================================================================
> --- incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
(original)
> +++ incubator/aries/trunk/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/OBRResolverTest.java
Thu Jun 24 02:23:38 2010
> @@ -80,7 +80,7 @@ public class OBRResolverTest extends Abs
>     ZipFixture bundle = ArchiveFixture.newJar().manifest()
>                             .attribute(Constants.BUNDLE_SYMBOLICNAME, CORE_BUNDLE_BY_VALUE)
>                             .attribute(Constants.BUNDLE_MANIFESTVERSION,
"2")
> -                            .attribute(Constants.IMPORT_PACKAGE, "p.q.r,
x.y.z")
> +                            .attribute(Constants.IMPORT_PACKAGE, "p.q.r,
x.y.z, javax.naming, org.apache.aries.util")
>                             .attribute(Constants.BUNDLE_VERSION, "1.0.0").end();
>
>
>
> Modified: incubator/aries/trunk/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java?rev=957403&r1=957402&r2=957403&view=diff
> ==============================================================================
> --- incubator/aries/trunk/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java
(original)
> +++ incubator/aries/trunk/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java
Thu Jun 24 02:23:38 2010
> @@ -17,7 +17,6 @@
>  * under the License.
>  */
>
> -
>  package org.apache.aries.application.resolver.obr;
>
>  import java.io.ByteArrayInputStream;
> @@ -29,7 +28,6 @@ import java.util.HashSet;
>  import java.util.List;
>  import java.util.Map;
>  import java.util.Set;
> -import java.util.jar.Attributes;
>
>  import javax.xml.transform.TransformerFactory;
>  import javax.xml.transform.dom.DOMSource;
> @@ -66,17 +64,24 @@ public class OBRAriesResolver implements
>  {
>   private static Logger log = LoggerFactory.getLogger(OBRAriesResolver.class);
>
> -  private final RepositoryAdmin repositoryAdmin;
> -
> +  private final RepositoryAdmin repositoryAdmin;
> +  private boolean returnOptionalResources = true;
> +
>   public OBRAriesResolver(RepositoryAdmin repositoryAdmin)
>   {
>     this.repositoryAdmin = repositoryAdmin;
>   }
>
> -  /**
> -   * This method is synchronized because it changes the repositories understood by
OBR, and we don't
> -   * want one apps by value content being used to resolve another. I'll ask for an
OBR enhancement.
> -   */
> +  public void setReturnOptionalResources(boolean optional)
> +  {
> +    this.returnOptionalResources = optional;
> +  }
> +
> +  public boolean getReturnOptionalResources()
> +  {
> +    return returnOptionalResources;
> +  }
> +
>   public Set<BundleInfo> resolve(AriesApplication app, ResolveConstraint... constraints)
throws ResolverException
>   {
>     log.trace("resolving {}", app);
> @@ -101,30 +106,38 @@ public class OBRAriesResolver implements
>     } catch (Exception e) {
>       throw new ResolverException(e);
>     }
> +
> +    List<Repository> resolveRepos = new ArrayList<Repository>();
>
> -    Repository[] repos = repositoryAdmin.listRepositories();
> +    // add system repository
> +    resolveRepos.add(repositoryAdmin.getSystemRepository());
>
> -    List<Repository> resolveRepos = new ArrayList<Repository>();
> +    // add local repository
> +    resolveRepos.add(repositoryAdmin.getLocalRepository());
> +
> +    // add application repository
>     resolveRepos.add(appRepo);
>
> +    // add user-defined repositories
> +    Repository[] repos = repositoryAdmin.listRepositories();
>     for (Repository r : repos) {
> -      if (!!!Repository.LOCAL.equals(r.getURI())) {
> -        resolveRepos.add(r);
> -      }
> +      resolveRepos.add(r);
>     }
> -
> +
>     Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
>     // add a resource describing the requirements of the application metadata.
>     obrResolver.add(createApplicationResource(helper, appName, appVersion, appContent));
>     if (obrResolver.resolve()) {
>       Set<BundleInfo> result = new HashSet<BundleInfo>();
>       for (Resource resource: obrResolver.getRequiredResources()) {
> -        BundleInfo bundleInfo = toBundleInfo(resource);
> +        BundleInfo bundleInfo = toBundleInfo(resource, false);
>         result.add(bundleInfo);
>       }
> -      for (Resource resource: obrResolver.getOptionalResources()) {
> -        BundleInfo bundleInfo = toBundleInfo(resource);
> -        result.add(bundleInfo);
> +      if (returnOptionalResources) {
> +        for (Resource resource: obrResolver.getOptionalResources()) {
> +          BundleInfo bundleInfo = toBundleInfo(resource, true);
> +          result.add(bundleInfo);
> +        }
>       }
>       return result;
>     } else {
> @@ -147,13 +160,12 @@ public class OBRAriesResolver implements
>     try {
>       resources = repositoryAdmin.discoverResources(filterString);
>       if (resources != null && resources.length > 0) {
> -        return toBundleInfo(resources[0]);
> +        return toBundleInfo(resources[0], false);
>       } else {
>         return null;
>       }
>     } catch (InvalidSyntaxException e) {
> -      // TODO Auto-generated catch block
> -      e.printStackTrace();
> +      log.error("Invalid filter", e);
>       return null;
>     }
>   }
> @@ -173,19 +185,24 @@ public class OBRAriesResolver implements
>     return null;
>   }
>
> -  private BundleInfo toBundleInfo(Resource resource)
> +  private BundleInfo toBundleInfo(Resource resource, boolean optional)
>   {
> +    Map<String, String> directives = null;
> +    if (optional) {
> +      directives = new HashMap<String, String>();
> +      directives.put(Constants.RESOLUTION_DIRECTIVE, Constants.RESOLUTION_OPTIONAL);
> +    }
>     String location = resource.getURI();
>     return new OBRBundleInfo(resource.getSymbolicName(),
> -            resource.getVersion(),
> -            location,
> -            null,
> -            null,
> -            null,
> -            null,
> -            null,
> -            null,
> -            null,
> -            null);
> +                             resource.getVersion(),
> +                             location,
> +                             null,
> +                             null,
> +                             null,
> +                             null,
> +                             null,
> +                             null,
> +                             directives,
> +                             null);
>   }
> -}
> \ No newline at end of file
> +}
>
> Modified: incubator/aries/trunk/application/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/pom.xml?rev=957403&r1=957402&r2=957403&view=diff
> ==============================================================================
> --- incubator/aries/trunk/application/pom.xml (original)
> +++ incubator/aries/trunk/application/pom.xml Thu Jun 24 02:23:38 2010
> @@ -69,7 +69,7 @@
>             <dependency>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>org.apache.felix.bundlerepository</artifactId>
> -                <version>1.6.2</version>
> +                <version>1.6.4</version>
>             </dependency>
>             <dependency>
>                 <groupId>org.apache.felix</groupId>
>
>
>



-- 
Alasdair Nottingham
not@apache.org

Mime
View raw message