You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/07/19 07:34:15 UTC
svn commit: r795480 - in
/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container:
BlueprintContainerImpl.java BlueprintExtender.java
Author: gawor
Date: Sun Jul 19 05:34:15 2009
New Revision: 795480
URL: http://svn.apache.org/viewvc?rev=795480&view=rev
Log:
delay checking if a path explicitly specified in Bundle-Blueprint header exists or not
Modified:
geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
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/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=795480&r1=795479&r2=795480&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java Sun Jul 19 05:34:15 2009
@@ -18,6 +18,7 @@
*/
package org.apache.geronimo.blueprint.container;
+import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
@@ -106,7 +107,7 @@
private final Bundle extenderBundle;
private final BlueprintListener eventDispatcher;
private final NamespaceHandlerRegistry handlers;
- private final List<URL> urls;
+ private final List<Object> pathList;
private final ComponentDefinitionRegistryImpl componentDefinitionRegistry;
private final AggregateConverter converter;
private final ScheduledExecutorService executors;
@@ -127,12 +128,12 @@
private final AtomicBoolean running = new AtomicBoolean();
private List<ServiceRecipe> services;
- public BlueprintContainerImpl(BundleContext bundleContext, Bundle extenderBundle, BlueprintListener eventDispatcher, NamespaceHandlerRegistry handlers, ScheduledExecutorService executors, List<URL> urls) {
+ public BlueprintContainerImpl(BundleContext bundleContext, Bundle extenderBundle, BlueprintListener eventDispatcher, NamespaceHandlerRegistry handlers, ScheduledExecutorService executors, List<Object> pathList) {
this.bundleContext = bundleContext;
this.extenderBundle = extenderBundle;
this.eventDispatcher = eventDispatcher;
this.handlers = handlers;
- this.urls = urls;
+ this.pathList = pathList;
this.converter = new AggregateConverter(this);
this.componentDefinitionRegistry = new ComponentDefinitionRegistryImpl();
this.executors = executors;
@@ -223,7 +224,7 @@
eventDispatcher.blueprintEvent(new BlueprintEvent(BlueprintEvent.CREATING, getBundleContext().getBundle(), getExtenderBundle()));
parser = new Parser();
parser.setValidation(xmlValidation);
- parser.parse(urls);
+ parser.parse(getResources());
namespaces = parser.getNamespaces();
if (namespaces.size() > 0) {
handlers.addListener(this);
@@ -325,6 +326,25 @@
}
}
+ private List<URL> getResources() throws FileNotFoundException {
+ List<URL> resources = new ArrayList<URL>();
+ for (Object path : pathList) {
+ if (path instanceof URL) {
+ resources.add((URL) path);
+ } else if (path instanceof String) {
+ URL url = bundleContext.getBundle().getEntry((String) path);
+ if (url == null) {
+ throw new FileNotFoundException("Unable to find configuration file for " + path);
+ } else {
+ resources.add(url);
+ }
+ } else {
+ throw new IllegalArgumentException("Unexpected path type: " + path.getClass());
+ }
+ }
+ return resources;
+ }
+
public BlueprintRepository getRepository() {
if (repository == null) {
repository = new RecipeBuilder(this).createRepository();
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=795480&r1=795479&r2=795480&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 Sun Jul 19 05:34:15 2009
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Comparator;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -167,7 +166,7 @@
private void checkBundle(Bundle bundle) {
LOGGER.debug("Scanning bundle {} for blueprint application", bundle.getSymbolicName());
try {
- List<URL> urls = new ArrayList<URL>();
+ List<Object> pathList = new ArrayList<Object>();
String blueprintHeader = (String) bundle.getHeaders().get(BlueprintConstants.BUNDLE_BLUEPRINT_HEADER);
if (blueprintHeader == null) {
blueprintHeader = "OSGI-INF/blueprint/";
@@ -176,7 +175,7 @@
for (PathElement path : paths) {
String name = path.getName();
if (name.endsWith("/")) {
- addEntries(bundle, name, "*.xml", false, urls);
+ addEntries(bundle, name, "*.xml", pathList);
} else {
String baseName;
String filePattern;
@@ -189,21 +188,21 @@
filePattern = name.substring(pos + 1);
}
if (hasWildcards(filePattern)) {
- addEntries(bundle, baseName, filePattern, false, urls);
+ addEntries(bundle, baseName, filePattern, pathList);
} else {
- addEntry(bundle, name, urls);
+ addEntry(bundle, name, pathList);
}
}
}
- if (!urls.isEmpty()) {
- LOGGER.debug("Found blueprint application in bundle {} with urls: {}", bundle.getSymbolicName(), urls);
+ if (!pathList.isEmpty()) {
+ LOGGER.debug("Found blueprint application in bundle {} with paths: {}", bundle.getSymbolicName(), pathList);
// Check compatibility
// TODO: For lazy bundles, the class is either loaded from an imported package or not found, so it should
// not trigger the activation. If it does, we need to use something else like package admin or
// ServiceReference, or just not do this check, which could be quite harmful.
boolean compatible = isCompatible(bundle);
if (compatible) {
- final BlueprintContainerImpl blueprintContainer = new BlueprintContainerImpl(bundle.getBundleContext(), context.getBundle(), eventDispatcher, handlers, executors, urls);
+ final BlueprintContainerImpl blueprintContainer = new BlueprintContainerImpl(bundle.getBundleContext(), context.getBundle(), eventDispatcher, handlers, executors, pathList);
containers.put(bundle, blueprintContainer);
blueprintContainer.schedule();
} else {
@@ -239,30 +238,15 @@
return path.indexOf("*") >= 0;
}
- private void addEntry(Bundle bundle, String path, List<URL> urls) {
- URL url = bundle.getEntry(path);
- if (url != null) {
- urls.add(url);
- } else {
- throw new IllegalArgumentException("Unable to find configuration file for " + path);
- }
+ private void addEntry(Bundle bundle, String path, List<Object> pathList) {
+ pathList.add(path);
}
- private void addEntries(Bundle bundle, String path, String filePattern, boolean mustMatch, List<URL> urls) {
- boolean added = false;
+ private void addEntries(Bundle bundle, String path, String filePattern, List<Object> pathList) {
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);
+ pathList.add(u);
}
}
}