geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r786132 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: container/BlueprintExtender.java utils/HeaderParser.java
Date Thu, 18 Jun 2009 15:47:59 GMT
Author: gawor
Date: Thu Jun 18 15:47:58 2009
New Revision: 786132

URL: http://svn.apache.org/viewvc?rev=786132&view=rev
Log:
even more improvements for Bundle-Blueprint header handling

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java?rev=786132&r1=786131&r2=786132&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
Thu Jun 18 15:47:58 2009
@@ -133,27 +133,30 @@
             String blueprintHeader = (String) bundle.getHeaders().get(BlueprintConstants.BUNDLE_BLUEPRINT_HEADER);
             if (blueprintHeader == null) {
                 blueprintHeader = "OSGI-INF/blueprint/";
-            }
+            } 
             List<PathElement> paths = HeaderParser.parseHeader(blueprintHeader);
             for (PathElement path : paths) {
                 String name = path.getName();
                 if (name.endsWith("/")) {
-                    addEntries(bundle, name, "*.xml", urls);
+                    addEntries(bundle, name, "*.xml", false, urls);
                 } else {
+                    String baseName;
+                    String filePattern;
                     int pos = name.lastIndexOf('/');
                     if (pos < 0) {
-                        addEntry(bundle, name, urls);
+                        baseName = "/";
+                        filePattern = name;
                     } else {
-                        String baseName = name.substring(0, pos + 1);
-                        String filePattern = name.substring(pos + 1);
-                        if (hasWildcards(filePattern)) {
-                            addEntries(bundle, baseName, filePattern, urls);
-                        } else {
-                            addEntry(bundle, name, urls);
-                        }
+                        baseName = name.substring(0, pos + 1);
+                        filePattern = name.substring(pos + 1);
                     }
+                    if (hasWildcards(filePattern)) {
+                        addEntries(bundle, baseName, filePattern, true, urls);
+                    } else {
+                        addEntry(bundle, name, urls);
+                    }                    
                 }
-            }
+            }            
             if (!urls.isEmpty()) {
                 LOGGER.debug("Found blueprint application in bundle {} with urls: {}", bundle.getSymbolicName(),
urls);
                 // Check compatibility
@@ -198,15 +201,25 @@
         if (url != null) {
             urls.add(url);
         } else {
-            throw new IllegalArgumentException("Unable to find bundle entry for config file
" + path);
+            throw new IllegalArgumentException("Unable to find configuration file for " +
path);
         }
     }
     
-    private void addEntries(Bundle bundle, String path, String filePattern, List<URL>
urls) {
+    private void addEntries(Bundle bundle, String path, String filePattern, boolean mustMatch,
List<URL> urls) {
+        boolean added = false;
         Enumeration e = bundle.findEntries(path, filePattern, false);
         while (e != null && e.hasMoreElements()) {
             URL u = (URL) e.nextElement();
             urls.add(u);
+            added = true;
+        }
+        if (!added && mustMatch) {
+            String query = path;
+            if (!path.endsWith("/")) {
+                query += "/";
+            }
+            query += filePattern;
+            throw new IllegalArgumentException("Unable to find any configuration files for
" + query);
         }
     }
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java?rev=786132&r1=786131&r2=786132&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
Thu Jun 18 15:47:58 2009
@@ -39,6 +39,9 @@
      */
     public static List<PathElement> parseHeader(String header) {
         List<PathElement> elements = new ArrayList<PathElement>();
+        if (header == null || header.trim().length() == 0) {
+            return elements;
+        }
         String[] clauses = header.split(",");
         for (String clause : clauses) {
             String[] tokens = clause.split(";");



Mime
View raw message