felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r912553 - in /felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr: FindCommand.java ResolveCommand.java util/IteratorToEnumeration.java util/MapToDictionary.java util/RequirementImpl.java util/ResourceImpl.java
Date Mon, 22 Feb 2010 13:04:37 GMT
Author: gnodet
Date: Mon Feb 22 13:04:37 2010
New Revision: 912553

URL: http://svn.apache.org/viewvc?rev=912553&view=rev
Log:
FELIX-2113: leverage FELIX-2110 to implement obr:resolve and obr:find commands

Removed:
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/IteratorToEnumeration.java
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/MapToDictionary.java
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/RequirementImpl.java
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/util/ResourceImpl.java
Modified:
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
    felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java

Modified: felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java?rev=912553&r1=912552&r2=912553&view=diff
==============================================================================
--- felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
(original)
+++ felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/FindCommand.java
Mon Feb 22 13:04:37 2010
@@ -21,9 +21,6 @@
 
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.karaf.shell.obr.util.RequirementImpl;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 import org.osgi.service.obr.Capability;
@@ -41,7 +38,7 @@
     protected void doExecute(RepositoryAdmin admin) throws Exception {
         List<Resource> matching = new ArrayList<Resource>();
         Repository[] repos = admin.listRepositories();
-        Requirement req = parseRequirement(requirement);
+        Requirement req = parseRequirement(admin, requirement);
         for (int repoIdx = 0; (repos != null) && (repoIdx < repos.length); repoIdx++)
{
             Resource[] resources = repos[repoIdx].getResources();
             for (int resIdx = 0; (resources != null) && (resIdx < resources.length);
resIdx++) {
@@ -65,7 +62,7 @@
         }
     }
 
-    private Requirement parseRequirement(String req) throws InvalidSyntaxException {
+    private Requirement parseRequirement(RepositoryAdmin admin, String req) throws InvalidSyntaxException
{
         int p = req.indexOf(':');
         String name;
         String filter;
@@ -83,8 +80,7 @@
         if (!filter.startsWith("(")) {
             filter = "(" + filter + ")";
         }
-        Filter flt = FrameworkUtil.createFilter(filter);
-        return new RequirementImpl(name, flt);
+        return admin.requirement(name, filter);
     }
 
 }
\ No newline at end of file

Modified: felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java?rev=912553&r1=912552&r2=912553&view=diff
==============================================================================
--- felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java
(original)
+++ felix/trunk/karaf/shell/obr/src/main/java/org/apache/felix/karaf/shell/obr/ResolveCommand.java
Mon Feb 22 13:04:37 2010
@@ -21,10 +21,6 @@
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
 import org.apache.felix.gogo.commands.Option;
-import org.apache.felix.karaf.shell.obr.util.RequirementImpl;
-import org.apache.felix.karaf.shell.obr.util.ResourceImpl;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.obr.RepositoryAdmin;
 import org.osgi.service.obr.Requirement;
@@ -41,9 +37,10 @@
     List<String> requirements;
 
     protected void doExecute(RepositoryAdmin admin) throws Exception {
-        Resource resource = new ResourceImpl(null, null, null, null, null, null, getRequirements(),
null, null, null);
         Resolver resolver = admin.resolver();
-        resolver.add(resource);
+        for (Requirement requirement : getRequirements(admin)) {
+            resolver.add(requirement);
+        }
         if (resolver.resolve()) {
             Resource[] resources;
             resources = resolver.getRequiredResources();
@@ -95,15 +92,15 @@
         }
     }
 
-    private Requirement[] getRequirements() throws InvalidSyntaxException {
+    private Requirement[] getRequirements(RepositoryAdmin admin) throws InvalidSyntaxException
{
         Requirement[] reqs = new Requirement[requirements.size()];
         for (int i = 0; i < reqs.length; i++) {
-            reqs[i] = parseRequirement(requirements.get(i));
+            reqs[i] = parseRequirement(admin, requirements.get(i));
         }
         return reqs;
     }
 
-    private Requirement parseRequirement(String req) throws InvalidSyntaxException {
+    private Requirement parseRequirement(RepositoryAdmin admin, String req) throws InvalidSyntaxException
{
         int p = req.indexOf(':');
         String name;
         String filter;
@@ -121,8 +118,7 @@
         if (!filter.startsWith("(")) {
             filter = "(" + filter + ")";
         }
-        Filter flt = FrameworkUtil.createFilter(filter);
-        return new RequirementImpl(name, flt);
+        return admin.requirement(name, filter);
     }
 
 }
\ No newline at end of file



Mime
View raw message