geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r785756 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
Date Wed, 17 Jun 2009 18:58:33 GMT
Author: gawor
Date: Wed Jun 17 18:58:33 2009
New Revision: 785756

URL: http://svn.apache.org/viewvc?rev=785756&view=rev
Log:
handle paths with wildcards

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.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=785756&r1=785755&r2=785756&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
Wed Jun 17 18:58:33 2009
@@ -136,19 +136,22 @@
             }
             List<PathElement> paths = HeaderParser.parseHeader(blueprintHeader);
             for (PathElement path : paths) {
-                // TODO: support OSGI-INF/blueprint/*.xml
-                if (path.getName().endsWith("/")) {
-                    Enumeration e = bundle.findEntries(path.getName(), "*.xml", false);
-                    while (e != null && e.hasMoreElements()) {
-                        URL u = (URL) e.nextElement();
-                        urls.add(u);
-                    }
+                String name = path.getName();
+                if (name.endsWith("/")) {
+                    addEntries(bundle, name, "*.xml", urls);
                 } else {
-                    URL url = bundle.getEntry(path.getName());
-                    if (url != null) {
-                        urls.add(url);
+                    int pos = name.lastIndexOf('/');
+                    if (pos < 0) {
+                        URL url = bundle.getEntry(name);
+                        if (url != null) {
+                            urls.add(url);
+                        } else {
+                            throw new IllegalArgumentException("Unable to find bundle entry
for config file " + name);
+                        }
                     } else {
-                        throw new IllegalArgumentException("Unable to find bundle entry for
config file " + path.getName());
+                        String baseName = name.substring(0, pos + 1);
+                        String filePattern = name.substring(pos + 1);
+                        addEntries(bundle, baseName, filePattern, urls);
                     }
                 }
             }
@@ -174,7 +177,7 @@
             eventDispatcher.blueprintEvent(new BlueprintEvent(BlueprintEvent.FAILURE, bundle,
context.getBundle(), t));
         }
     }
-
+    
     private boolean isCompatible(Bundle bundle) {
         // Check compatibility
         boolean compatible;
@@ -186,4 +189,12 @@
         }
         return compatible;
     }
+    
+    private void addEntries(Bundle bundle, String path, String filePattern, List<URL>
urls) {
+        Enumeration e = bundle.findEntries(path, filePattern, false);
+        while (e != null && e.hasMoreElements()) {
+            URL u = (URL) e.nextElement();
+            urls.add(u);
+        }
+    }
 }



Mime
View raw message