Author: pier Date: Wed Nov 3 09:19:45 2004 New Revision: 56491 Modified: cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Factory.java cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/description/Descriptor.java Log: Fail on inaccessible libraries AND provide a default "local.jar" which block relative to the descriptor which blocks can simply not declare
Modified: cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Factory.java ============================================================================== --- cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Factory.java (original) +++ cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Factory.java Wed Nov 3 09:19:45 2004 @@ -85,11 +85,11 @@ } /** - * <p>Configure the specified [EMAIL PROTECTED] Runtime} from a [EMAIL PROTECTED] Configuration}.</p> + * <p>Configure the specified [EMAIL PROTECTED] Deployer} from a [EMAIL PROTECTED] Configuration}.</p> */ - public static void configure(Deployer runtime, Configuration config) + public static void configure(Deployer deployer, Configuration config) throws DeployerException { - if (runtime == null) throw new NullPointerException("Null runtime"); + if (deployer == null) throw new NullPointerException("Null runtime"); if (config == null) throw new NullPointerException("Null configuration"); Iterator iterator = config.children("instance"); @@ -99,7 +99,7 @@ String name = current.getStringAttribute("name"); String block = current.getStringAttribute("block"); - Descriptor descriptor = runtime.getLibrary().get(block); + Descriptor descriptor = deployer.getLibrary().get(block); if (descriptor == null) { throw new DeployerException("Unable to retrieve descriptor for " + "block \"" + block + " declared at " + current.location()); @@ -108,8 +108,8 @@ throw new DeployerException("Unable to instantiate non-block \"" + block + " declared at " + current.location()); } - Instance instance = new Instance(runtime, (Block) descriptor, name); - runtime.putInstance(name, instance, current); + Instance instance = new Instance(deployer, (Block) descriptor, name); + deployer.putInstance(name, instance, current); } catch (DeployerException e) { throw e; } catch (Throwable t) { Modified: cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/description/Descriptor.java ============================================================================== --- cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/description/Descriptor.java (original) +++ cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/description/Descriptor.java Wed Nov 3 09:19:45 2004 @@ -12,6 +12,7 @@ * =============================================================================== */ package org.apache.cocoon.kernel.description; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.HashSet; @@ -86,15 +87,27 @@ while (iterator.hasNext()) try { current = (Configuration) iterator.next(); String url = current.getStringAttribute("href"); - collector.add(new URL(configuration.locationURL(), url)); - + URL lib = new URL(configuration.locationURL(), url); + lib.openStream().close(); + collector.add(lib); } catch (ConfigurationException exception) { throw new DeployerException("Library location not specified in " + "descriptor at " + current.location(), exception); - } catch (MalformedURLException exception) { throw new DeployerException("Invalid library location specified in " + " descriptor at " + current.location(), exception); + } catch (IOException exception) { + throw new DeployerException("Unable to access library location specified" + + " in descriptor at " + current.location(), exception); + } + + /* See if we have a "local" library as well */ + try { + URL local = new URL(configuration.locationURL(), "local.jar"); + local.openStream().close(); + collector.add(local); + } catch (IOException e) { + /* Swallow this, the block does not provide a local library. */ } this.libraries = (URL[]) collector.toArray(new URL[collector.size()]);