[jboss-cvs] JBossAS SVN: r96645 - in projects/jboss-osgi/trunk/reactor/framework/src: main/java/org/jboss/osgi/framework/metadata/internal and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 20 11:30:16 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-11-20 11:30:15 -0500 (Fri, 20 Nov 2009)
New Revision: 96645

Added:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/ManifestParser.java
Removed:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java
Modified:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedElementImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverSystemBundleImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
   projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
   projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl
Log:
Add packages exported by the system bundle to the resolver

Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/ManifestParser.java (from rev 96642, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/ManifestParser.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/ManifestParser.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -0,0 +1,266 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+// This class is based on some original classes from
+// Apache Felix which is licensed as below
+
+/* 
+ * 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.jboss.osgi.framework.metadata;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.osgi.framework.metadata.internal.AbstractPackageAttribute;
+import org.jboss.osgi.framework.metadata.internal.AbstractParameter;
+import org.jboss.osgi.framework.metadata.internal.AbstractParameterizedAttribute;
+
+/**
+ * ManifestParser.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManifestParser
+{
+   /**
+    * Parse packages
+    * 
+    * @param header the header
+    * @param list the list of packages to create
+    */
+   public static void parsePackages(String header, List<PackageAttribute> list)
+   {
+      parse(header, list, true);
+   }
+
+   /**
+    * Parse parameters
+    * 
+    * @param header the header
+    * @param list the list of parameters to create
+    */
+   public static void parseParameters(String header, List<ParameterizedAttribute> list)
+   {
+      parse(header, list, false);
+   }
+
+   /**
+    * Parse paths
+    * 
+    * @param header the header
+    * @param list the list of paths to create
+    */
+   public static void parsePaths(String header, List<ParameterizedAttribute> list)
+   {
+      parse(header, list, false);
+   }
+
+   /**
+    * Parse a header
+    * 
+    * @param header the header
+    * @param list the list to create
+    * @param packages whether to create packages
+    */
+   @SuppressWarnings("unchecked")
+   public static void parse(String header, List list, boolean packages)
+   {
+      if (header == null)
+         return;
+      if (header.length() == 0)
+         throw new IllegalArgumentException("Empty header");
+      
+      // Split the header into clauses using which are seperated by commas
+      // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2,
+      //            path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+      List<String> clauses = parseDelimitedString(header, ",");
+      
+      // Now parse each clause
+      for (String clause : clauses)
+      {
+         // Split the cause into paths, directives and attributes using the semi-colon
+         // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
+         List<String> pieces = parseDelimitedString(clause, ";");
+
+         // Collect the paths they should be first
+         List<String> paths = new ArrayList<String>();
+         for (String piece : pieces)
+         {
+            if (piece.indexOf('=') >= 0)
+               break;
+            paths.add(unquote(piece));
+         }
+         if (paths.isEmpty())
+            throw new IllegalArgumentException("No paths for " + clause);
+         
+         Map<String, Parameter> directives = null;
+         Map<String, Parameter> attributes = null;
+
+         for (int i = paths.size(); i < pieces.size(); ++i)
+         {
+            String piece = pieces.get(i);
+            int seperator = piece.indexOf(":=");
+            if (seperator >= 0)
+            {
+               String name = piece.substring(0, seperator);
+               String value = piece.substring(seperator + 2);
+               if (directives == null)
+                  directives = new HashMap<String, Parameter>();
+               String unquoted = unquote(name);
+               if (directives.containsKey(unquoted))
+                  throw new IllegalStateException("Dupicate directive: " + unquoted);
+               directives.put(unquoted, new AbstractParameter(unquote(value)));
+            }
+            else
+            {
+               seperator = piece.indexOf("=");
+               if (seperator >= 0)
+               {
+                  String name = piece.substring(0, seperator);
+                  String value = piece.substring(seperator + 1);
+                  if (attributes == null)
+                     attributes = new HashMap<String, Parameter>();
+                  String unquoted = unquote(name);
+                  if (attributes.containsKey(unquoted))
+                     throw new IllegalStateException("Dupicate attribute: " + unquoted);
+                  attributes.put(unquoted, new AbstractParameter(unquote(value)));
+               }
+               else
+               {
+                  throw new IllegalArgumentException("Path " + piece + " should appear before attributes and directives in " + clause);
+               }
+            }
+         }
+         
+         for (String path : paths)
+         {
+            ParameterizedAttribute metadata = null;
+            if (packages)
+               metadata = new AbstractPackageAttribute(path, attributes, directives);
+            else
+               metadata = new AbstractParameterizedAttribute(path, attributes, directives);
+            
+            list.add(metadata);
+         }
+    
+      }
+   }
+   
+   /**
+    * Remove around quotes around a string
+    * 
+    * @param string the string
+    * @return the unquoted string
+    */
+   private static String unquote(String string)
+   {
+      if (string.length() < 2)
+         return string;
+      if (string.charAt(0) == '\"' && string.charAt(string.length()-1) == '\"')
+         return string.substring(1, string.length()-1);
+      return string;
+   }
+
+   /**
+    * Parses delimited string and returns an array containing the tokens. This
+    * parser obeys quotes, so the delimiter character will be ignored if it is
+    * inside of a quote. This method assumes that the quote character is not
+    * included in the set of delimiter characters.
+    * @param value the delimited string to parse.
+    * @param delim the characters delimiting the tokens.
+    * @return an array of string tokens or null if there were no tokens.
+   **/
+   private static List<String> parseDelimitedString(String value, String delim)
+   {
+      if (value == null)
+         value = "";
+
+      List<String> list = new ArrayList<String>();
+
+      int CHAR = 1;
+      int DELIMITER = 2;
+      int STARTQUOTE = 4;
+      int ENDQUOTE = 8;
+
+      StringBuilder sb = new StringBuilder();
+
+      int expecting = (CHAR | DELIMITER | STARTQUOTE);
+
+      for (int i = 0; i < value.length(); i++)
+      {
+         char c = value.charAt(i);
+
+         boolean isDelimiter = (delim.indexOf(c) >= 0);
+         boolean isQuote = (c == '"');
+
+         if (isDelimiter && ((expecting & DELIMITER) > 0))
+         {
+            list.add(sb.toString().trim());
+            sb.delete(0, sb.length());
+            expecting = (CHAR | DELIMITER | STARTQUOTE);
+         }
+         else if (isQuote && ((expecting & STARTQUOTE) > 0))
+         {
+            sb.append(c);
+            expecting = CHAR | ENDQUOTE;
+         }
+         else if (isQuote && ((expecting & ENDQUOTE) > 0))
+         {
+            sb.append(c);
+            expecting = (CHAR | STARTQUOTE | DELIMITER);
+         }
+         else if ((expecting & CHAR) > 0)
+         {
+            sb.append(c);
+         }
+         else
+         {
+            throw new IllegalArgumentException("Invalid delimited string: '" + value + "' delimiter=" + delim);
+         }
+      }
+
+      if (sb.length() > 0)
+         list.add(sb.toString().trim());
+
+      return list;
+   }
+
+}

Deleted: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/ManifestParser.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -1,266 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-// This class is based on some original classes from
-// Apache Felix which is licensed as below
-
-/* 
- * 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.jboss.osgi.framework.metadata.internal;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-
-/**
- * ManifestParser.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ManifestParser
-{
-   /**
-    * Parse packages
-    * 
-    * @param header the header
-    * @param list the list of packages to create
-    */
-   public static void parsePackages(String header, List<PackageAttribute> list)
-   {
-      parse(header, list, true);
-   }
-
-   /**
-    * Parse parameters
-    * 
-    * @param header the header
-    * @param list the list of parameters to create
-    */
-   public static void parseParameters(String header, List<ParameterizedAttribute> list)
-   {
-      parse(header, list, false);
-   }
-
-   /**
-    * Parse paths
-    * 
-    * @param header the header
-    * @param list the list of paths to create
-    */
-   public static void parsePaths(String header, List<ParameterizedAttribute> list)
-   {
-      parse(header, list, false);
-   }
-
-   /**
-    * Parse a header
-    * 
-    * @param header the header
-    * @param list the list to create
-    * @param packages whether to create packages
-    */
-   @SuppressWarnings("unchecked")
-   public static void parse(String header, List list, boolean packages)
-   {
-      if (header == null)
-         return;
-      if (header.length() == 0)
-         throw new IllegalArgumentException("Empty header");
-      
-      // Split the header into clauses using which are seperated by commas
-      // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2,
-      //            path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
-      List<String> clauses = parseDelimitedString(header, ",");
-      
-      // Now parse each clause
-      for (String clause : clauses)
-      {
-         // Split the cause into paths, directives and attributes using the semi-colon
-         // Like this: path; path; dir1:=dirval1; dir2:=dirval2; attr1=attrval1; attr2=attrval2
-         List<String> pieces = parseDelimitedString(clause, ";");
-
-         // Collect the paths they should be first
-         List<String> paths = new ArrayList<String>();
-         for (String piece : pieces)
-         {
-            if (piece.indexOf('=') >= 0)
-               break;
-            paths.add(unquote(piece));
-         }
-         if (paths.isEmpty())
-            throw new IllegalArgumentException("No paths for " + clause);
-         
-         Map<String, Parameter> directives = null;
-         Map<String, Parameter> attributes = null;
-
-         for (int i = paths.size(); i < pieces.size(); ++i)
-         {
-            String piece = pieces.get(i);
-            int seperator = piece.indexOf(":=");
-            if (seperator >= 0)
-            {
-               String name = piece.substring(0, seperator);
-               String value = piece.substring(seperator + 2);
-               if (directives == null)
-                  directives = new HashMap<String, Parameter>();
-               String unquoted = unquote(name);
-               if (directives.containsKey(unquoted))
-                  throw new IllegalStateException("Dupicate directive: " + unquoted);
-               directives.put(unquoted, new AbstractParameter(unquote(value)));
-            }
-            else
-            {
-               seperator = piece.indexOf("=");
-               if (seperator >= 0)
-               {
-                  String name = piece.substring(0, seperator);
-                  String value = piece.substring(seperator + 1);
-                  if (attributes == null)
-                     attributes = new HashMap<String, Parameter>();
-                  String unquoted = unquote(name);
-                  if (attributes.containsKey(unquoted))
-                     throw new IllegalStateException("Dupicate attribute: " + unquoted);
-                  attributes.put(unquoted, new AbstractParameter(unquote(value)));
-               }
-               else
-               {
-                  throw new IllegalArgumentException("Path " + piece + " should appear before attributes and directives in " + clause);
-               }
-            }
-         }
-         
-         for (String path : paths)
-         {
-            ParameterizedAttribute metadata = null;
-            if (packages)
-               metadata = new AbstractPackageAttribute(path, attributes, directives);
-            else
-               metadata = new AbstractParameterizedAttribute(path, attributes, directives);
-            
-            list.add(metadata);
-         }
-    
-      }
-   }
-   
-   /**
-    * Remove around quotes around a string
-    * 
-    * @param string the string
-    * @return the unquoted string
-    */
-   private static String unquote(String string)
-   {
-      if (string.length() < 2)
-         return string;
-      if (string.charAt(0) == '\"' && string.charAt(string.length()-1) == '\"')
-         return string.substring(1, string.length()-1);
-      return string;
-   }
-
-   /**
-    * Parses delimited string and returns an array containing the tokens. This
-    * parser obeys quotes, so the delimiter character will be ignored if it is
-    * inside of a quote. This method assumes that the quote character is not
-    * included in the set of delimiter characters.
-    * @param value the delimited string to parse.
-    * @param delim the characters delimiting the tokens.
-    * @return an array of string tokens or null if there were no tokens.
-   **/
-   private static List<String> parseDelimitedString(String value, String delim)
-   {
-      if (value == null)
-         value = "";
-
-      List<String> list = new ArrayList<String>();
-
-      int CHAR = 1;
-      int DELIMITER = 2;
-      int STARTQUOTE = 4;
-      int ENDQUOTE = 8;
-
-      StringBuilder sb = new StringBuilder();
-
-      int expecting = (CHAR | DELIMITER | STARTQUOTE);
-
-      for (int i = 0; i < value.length(); i++)
-      {
-         char c = value.charAt(i);
-
-         boolean isDelimiter = (delim.indexOf(c) >= 0);
-         boolean isQuote = (c == '"');
-
-         if (isDelimiter && ((expecting & DELIMITER) > 0))
-         {
-            list.add(sb.toString().trim());
-            sb.delete(0, sb.length());
-            expecting = (CHAR | DELIMITER | STARTQUOTE);
-         }
-         else if (isQuote && ((expecting & STARTQUOTE) > 0))
-         {
-            sb.append(c);
-            expecting = CHAR | ENDQUOTE;
-         }
-         else if (isQuote && ((expecting & ENDQUOTE) > 0))
-         {
-            sb.append(c);
-            expecting = (CHAR | STARTQUOTE | DELIMITER);
-         }
-         else if ((expecting & CHAR) > 0)
-         {
-            sb.append(c);
-         }
-         else
-         {
-            throw new IllegalArgumentException("Invalid delimited string: '" + value + "' delimiter=" + delim);
-         }
-      }
-
-      if (sb.length() > 0)
-         list.add(sb.toString().trim());
-
-      return list;
-   }
-
-}

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PackageAttributeListValueCreator.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jboss.osgi.framework.metadata.ManifestParser;
 import org.jboss.osgi.framework.metadata.PackageAttribute;
 
 /**

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/PathAttributeListValueCreator.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -23,6 +23,7 @@
 
 import java.util.List;
 
+import org.jboss.osgi.framework.metadata.ManifestParser;
 import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
 
 /**

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/metadata/internal/QNameAttributeListValueCreator.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -23,6 +23,7 @@
 
 import java.util.List;
 
+import org.jboss.osgi.framework.metadata.ManifestParser;
 import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
 
 /**

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -165,7 +165,7 @@
    
    public String toShortString()
    {
-      ResolverBundleImpl owner = (ResolverBundleImpl)getOwner();
+      AbstractResolverBundle owner = (AbstractResolverBundle)getOwner();
       return owner.toShortString() + super.toShortString();
    }
    

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -89,7 +89,7 @@
 
    public String toShortString()
    {
-      ResolverBundleImpl owner = (ResolverBundleImpl)getOwner();
+      AbstractResolverBundle owner = (AbstractResolverBundle)getOwner();
       return owner.toShortString() + super.toShortString();
    }
    

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedElementImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedElementImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/NamedElementImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -24,8 +24,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
 import org.jboss.osgi.framework.metadata.Parameter;
 import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
 import org.jboss.osgi.framework.resolver.NamedElement;
@@ -40,7 +38,6 @@
 abstract class NamedElementImpl implements NamedElement
 {
    private ResolverBundle owner;
-   private OSGiMetaData metaData;
    private ParameterizedAttribute paramattr;
 
    public NamedElementImpl(ResolverBundle owner, ParameterizedAttribute attr)
@@ -52,9 +49,6 @@
 
       this.owner = owner;
       this.paramattr = attr;
-
-      OSGiBundleState bundleState = OSGiBundleState.assertBundleState(owner.getBundle());
-      this.metaData = bundleState.getOSGiMetaData();
    }
 
    public ResolverBundle getOwner()
@@ -67,11 +61,6 @@
       return paramattr.getAttribute();
    }
 
-   protected OSGiMetaData getMetaData()
-   {
-      return metaData;
-   }
-
    protected ParameterizedAttribute getParameterizedAttribute()
    {
       return paramattr;

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -30,7 +30,7 @@
 import org.osgi.framework.Bundle;
 
 /**
- * An abstraction of a resBundle bundle.
+ * A ResolverBundle implementation.
  * 
  * @author thomas.diesler at jboss.com
  * @since 09-Nov-2009

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverSystemBundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverSystemBundleImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverSystemBundleImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -21,23 +21,20 @@
  */
 package org.jboss.osgi.framework.resolver.internal;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.ManifestParser;
 import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
 import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
 import org.osgi.framework.Bundle;
 
-import aQute.lib.osgi.Constants;
-
 /**
- * An abstraction of a resBundle bundle.
+ * A ResolverBundle implementation for the system bundle.
  * 
  * @author thomas.diesler at jboss.com
- * @since 09-Nov-2009
+ * @since 20-Nov-2009
  */
 public class ResolverSystemBundleImpl extends AbstractResolverBundle
 {
@@ -48,12 +45,17 @@
       OSGiBundleManager bundleManager = bundleState.getBundleManager();
       SystemPackagesPlugin plugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
 
+      // Get the list of system packages
+      List<PackageAttribute> packageList = new ArrayList<PackageAttribute>();
+      String sysPackages = plugin.getSystemPackages(true).toString();
+      sysPackages = sysPackages.substring(1, sysPackages.length() - 1);
+      ManifestParser.parsePackages(sysPackages, packageList);
+      
       // Initialize exported packages
-      for (String packageName : plugin.getSystemPackages(true))
+      for (PackageAttribute attr : packageList)
       {
-         //int versionIndex = packageName.indexOf(";" + Constants.VERSION_ATTRIBUTE + "=");
-         //if (versionIndex > 0)
-         //exportedPackages.put(packageName, new ExportPackageImpl(this, attr));
+         String packageName = attr.getAttribute();
+         exportedPackages.put(packageName, new ExportPackageImpl(this, attr));
       }
    }
 

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -41,6 +41,7 @@
 import org.jboss.osgi.framework.resolver.ExportPackage;
 import org.jboss.osgi.framework.resolver.ImportPackage;
 import org.jboss.osgi.framework.resolver.ResolverBundle;
+import org.jboss.osgi.framework.resolver.internal.ResolverSystemBundleImpl;
 import org.osgi.framework.Bundle;
 
 /**
@@ -79,7 +80,14 @@
       ResolverBundle resBundle;
       if (bundle.getBundleId() == 0)
       {
-         resBundle = null;
+         resBundle = new ResolverSystemBundleImpl(bundle);
+         
+         // Insert the system bundle as a fact
+         FactHandle factHandle = ksession.insert(resBundle);
+         facts.put(resBundle, factHandle);
+         
+         // Fire all the rules
+         ksession.fireAllRules();
       }
       else
       {

Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -38,7 +38,6 @@
 import org.jboss.osgi.framework.resolver.ResolverBundle;
 import org.jboss.test.osgi.classloader.support.a.A;
 import org.jboss.virtual.VirtualFile;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 
@@ -1386,7 +1385,7 @@
       }
    }
 
-   @Ignore
+   @Test
    public void testSystemPackageImport() throws Exception
    {
       Resolver resolver = getTestResolver();
@@ -1398,9 +1397,6 @@
       Bundle bundleA = framework.installBundle(fileA);
       try
       {
-         // Resolve the compendium
-         resolver.resolve(null);
-
          // Resolve the logging bundle
          resolver.resolve(null);
 

Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java	2009-11-20 16:30:15 UTC (rev 96645)
@@ -43,6 +43,7 @@
       {
          OSGiBundleManager bundleManager = framework.getBundleManager();
          resolver = new RuleBasedResolverImpl(bundleManager);
+         resolver.addBundle(bundleManager.getSystemBundle());
       }
       return resolver;
    }

Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl	2009-11-20 16:15:50 UTC (rev 96644)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl	2009-11-20 16:30:15 UTC (rev 96645)
@@ -65,7 +65,7 @@
 rule "Add ExportPackage for new ResolverBundle"
 salience 2000
 when
-	$exporter : ResolverBundle( state == Bundle.INSTALLED, resolved == false )
+	$exporter : ResolverBundle( (state == Bundle.INSTALLED || bundleId == 0), resolved == false )
 	$export : ExportPackage( ) from $exporter.exportPackages
 	not ExportPackage( owner == $exporter, this == $export ) 
 then




More information about the jboss-cvs-commits mailing list