You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ga...@apache.org on 2010/06/24 04:23:39 UTC

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/

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>



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/

Posted by Jarek Gawor <jg...@gmail.com>.
FYI, I just committed some changes in revision 964138 that address
this issue (using the isLocals() { return false; } solution). Hope the
approach works for everybody.

Jarek

On Tue, Jun 29, 2010 at 4:26 AM, Alasdair Nottingham <no...@apache.org> wrote:
> I don't think a two step will work because the local repo results
> don't get added into the resolve result so it would still fail.
>
> I think if we took the locals repo and wrapped them to not be locals,
> I.e. IsLocal returns false, then we could do what we want.
>
> Alasdair
>
> On Monday, June 28, 2010, Lin Sun <li...@gmail.com> wrote:
>> Hi
>>
>> This seems reasonable to me.  Does this mean we need to run the felix
>> bundle repository Resolver.resolve() twice?
>>
>> 1. generate the required resource for deployment.mf, without using
>> local repo, assuming we need to run Resolver.resolve() then
>> Resolver.getRequiredResources() to get the required resource.
>> 2. after adding the local repo, try to see the result of Resolver.resolve().
>>
>> Thanks
>>
>> Lin
>>
>> On Mon, Jun 28, 2010 at 1:11 PM, Jarek Gawor <jg...@gmail.com> wrote:
>>> So, what I think OBRAriesResolver should really do, is use all three
>>> types of repositories (system, local, and user-defined) and configure
>>> the OBR resolver somehow to include local resources in the resolved
>>> set (instead of pruning them out).
>>>
>>> WDYT?
>>>
>>> Jarek
>>>
>>> On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
>>>> 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
>>>
>>
>
> --
> Alasdair Nottingham
> not@apache.org
>

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/

Posted by Jarek Gawor <jg...@gmail.com>.
Yes, I think that could work. Or better yet we could work on modifying
the bundlerepository code to add a flag so that it doesn't remove the
local resources. There are already a few flags defined so adding a new
one hopefully shouldn't be a problem.

Jarek

On Tue, Jun 29, 2010 at 4:26 AM, Alasdair Nottingham <no...@apache.org> wrote:
> I don't think a two step will work because the local repo results
> don't get added into the resolve result so it would still fail.
>
> I think if we took the locals repo and wrapped them to not be locals,
> I.e. IsLocal returns false, then we could do what we want.
>
> Alasdair
>
> On Monday, June 28, 2010, Lin Sun <li...@gmail.com> wrote:
>> Hi
>>
>> This seems reasonable to me.  Does this mean we need to run the felix
>> bundle repository Resolver.resolve() twice?
>>
>> 1. generate the required resource for deployment.mf, without using
>> local repo, assuming we need to run Resolver.resolve() then
>> Resolver.getRequiredResources() to get the required resource.
>> 2. after adding the local repo, try to see the result of Resolver.resolve().
>>
>> Thanks
>>
>> Lin
>>
>> On Mon, Jun 28, 2010 at 1:11 PM, Jarek Gawor <jg...@gmail.com> wrote:
>>> So, what I think OBRAriesResolver should really do, is use all three
>>> types of repositories (system, local, and user-defined) and configure
>>> the OBR resolver somehow to include local resources in the resolved
>>> set (instead of pruning them out).
>>>
>>> WDYT?
>>>
>>> Jarek
>>>
>>> On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
>>>> 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
>>>
>>
>
> --
> Alasdair Nottingham
> not@apache.org
>

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/

Posted by Lin Sun <li...@gmail.com>.
Right I agree, thanks!   step 1 would not resolve...

We could also create our own local repo like felix bundle repository
code does, then we would add it to repo admin as a regular repo.

Lin

On Tue, Jun 29, 2010 at 4:26 AM, Alasdair Nottingham <no...@apache.org> wrote:
> I don't think a two step will work because the local repo results
> don't get added into the resolve result so it would still fail.
>
> I think if we took the locals repo and wrapped them to not be locals,
> I.e. IsLocal returns false, then we could do what we want.
>
> Alasdair
>
> On Monday, June 28, 2010, Lin Sun <li...@gmail.com> wrote:
>> Hi
>>
>> This seems reasonable to me.  Does this mean we need to run the felix
>> bundle repository Resolver.resolve() twice?
>>
>> 1. generate the required resource for deployment.mf, without using
>> local repo, assuming we need to run Resolver.resolve() then
>> Resolver.getRequiredResources() to get the required resource.
>> 2. after adding the local repo, try to see the result of Resolver.resolve().
>>
>> Thanks
>>
>> Lin
>>
>> On Mon, Jun 28, 2010 at 1:11 PM, Jarek Gawor <jg...@gmail.com> wrote:
>>> So, what I think OBRAriesResolver should really do, is use all three
>>> types of repositories (system, local, and user-defined) and configure
>>> the OBR resolver somehow to include local resources in the resolved
>>> set (instead of pruning them out).
>>>
>>> WDYT?
>>>
>>> Jarek
>>>
>>> On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
>>>> 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
>>>
>>
>
> --
> Alasdair Nottingham
> not@apache.org
>

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/

Posted by Alasdair Nottingham <no...@apache.org>.
I don't think a two step will work because the local repo results
don't get added into the resolve result so it would still fail.

I think if we took the locals repo and wrapped them to not be locals,
I.e. IsLocal returns false, then we could do what we want.

Alasdair

On Monday, June 28, 2010, Lin Sun <li...@gmail.com> wrote:
> Hi
>
> This seems reasonable to me.  Does this mean we need to run the felix
> bundle repository Resolver.resolve() twice?
>
> 1. generate the required resource for deployment.mf, without using
> local repo, assuming we need to run Resolver.resolve() then
> Resolver.getRequiredResources() to get the required resource.
> 2. after adding the local repo, try to see the result of Resolver.resolve().
>
> Thanks
>
> Lin
>
> On Mon, Jun 28, 2010 at 1:11 PM, Jarek Gawor <jg...@gmail.com> wrote:
>> So, what I think OBRAriesResolver should really do, is use all three
>> types of repositories (system, local, and user-defined) and configure
>> the OBR resolver somehow to include local resources in the resolved
>> set (instead of pruning them out).
>>
>> WDYT?
>>
>> Jarek
>>
>> On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
>>> 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
>>
>

-- 
Alasdair Nottingham
not@apache.org

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/

Posted by Lin Sun <li...@gmail.com>.
Hi

This seems reasonable to me.  Does this mean we need to run the felix
bundle repository Resolver.resolve() twice?

1. generate the required resource for deployment.mf, without using
local repo, assuming we need to run Resolver.resolve() then
Resolver.getRequiredResources() to get the required resource.
2. after adding the local repo, try to see the result of Resolver.resolve().

Thanks

Lin

On Mon, Jun 28, 2010 at 1:11 PM, Jarek Gawor <jg...@gmail.com> wrote:
> So, what I think OBRAriesResolver should really do, is use all three
> types of repositories (system, local, and user-defined) and configure
> the OBR resolver somehow to include local resources in the resolved
> set (instead of pruning them out).
>
> WDYT?
>
> Jarek
>
> On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
>> 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
>

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/

Posted by Jarek Gawor <jg...@gmail.com>.
Alasdair,

I understand that we want the generate a complete deployment.mf but I
do think we should still consider the local repository. Take the
OBRResolverTest.testBlogApp() test as an example. To one of the
bundles I added an import on "org.apache.aries.util" package. The
bundle that provides the package is installed in the testing
framework. Now, the test will fail if the local repository is not
considered during obr resolution. But the application should resolve
and install just fine since the framework already has the dependency
installed. The test could work if I create a OBR repository for the
util bundle and register that with the OBR... but now I'm just
replicating what OBR does itself automatically.

So, what I think OBRAriesResolver should really do, is use all three
types of repositories (system, local, and user-defined) and configure
the OBR resolver somehow to include local resources in the resolved
set (instead of pruning them out).

WDYT?

Jarek

On Fri, Jun 25, 2010 at 12:43 PM, Alasdair Nottingham <no...@apache.org> wrote:
> 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

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/

Posted by Alasdair Nottingham <no...@apache.org>.
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,  <ga...@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