You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by je...@apache.org on 2003/05/17 08:00:26 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/modules/input AbstractMetaModule.java
jefft 2003/05/16 23:00:26
Modified: src/java/org/apache/cocoon/components/modules/input
AbstractMetaModule.java
Log:
Make exception handling more explicit. Instead of just returning null values
when configured invalidly, a meta module will now throw a
ConfigurationException.
Revision Changes Path
1.4 +30 -14 cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/AbstractMetaModule.java
Index: AbstractMetaModule.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/AbstractMetaModule.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractMetaModule.java 12 Mar 2003 14:51:51 -0000 1.3
+++ AbstractMetaModule.java 17 May 2003 06:00:26 -0000 1.4
@@ -60,6 +60,7 @@
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.thread.ThreadSafe;
/**
@@ -148,7 +149,7 @@
}
} catch (Exception e) {
if (getLogger().isWarnEnabled())
- getLogger().warn("A problem occurred setting up input modules :'" + e.getMessage());
+ getLogger().error("A problem occurred setting up input modules :'" + e.getMessage(), e);
}
}
@@ -237,7 +238,8 @@
* @see InputModule#getAttributeNames
*/
protected Iterator getNames(Map objectModel,
- InputModule staticMod, String staticModName, Configuration staticModConf) {
+ InputModule staticMod, String staticModName, Configuration staticModConf)
+ throws ConfigurationException {
return (Iterator) this.get(OP_NAMES, null, objectModel, staticMod, staticModName, staticModConf, null, null, null);
}
@@ -250,7 +252,8 @@
*/
protected Iterator getNames(Map objectModel,
InputModule staticMod, String staticModName, Configuration staticModConf,
- InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf) {
+ InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf)
+ throws ConfigurationException {
return (Iterator) this.get(OP_NAMES, null, objectModel, staticMod, staticModName, staticModConf, dynamicMod, dynamicModName, dynamicModConf);
}
@@ -262,7 +265,8 @@
* @see InputModule#getAttribute
*/
protected Object getValue(String attr, Map objectModel,
- InputModule staticMod, String staticModName, Configuration staticModConf) {
+ InputModule staticMod, String staticModName, Configuration staticModConf)
+ throws ConfigurationException {
return this.get(OP_GET, attr, objectModel, staticMod, staticModName, staticModConf, null, null, null);
}
@@ -276,7 +280,8 @@
*/
protected Object getValue(String attr, Map objectModel,
InputModule staticMod, String staticModName, Configuration staticModConf,
- InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf) {
+ InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf)
+ throws ConfigurationException {
return this.get(OP_GET, attr, objectModel, staticMod, staticModName, staticModConf, dynamicMod, dynamicModName, dynamicModConf);
}
@@ -287,7 +292,8 @@
* @see InputModule#getAttributeValues
*/
protected Object[] getValues(String attr, Map objectModel,
- InputModule staticMod, String staticModName, Configuration staticModConf) {
+ InputModule staticMod, String staticModName, Configuration staticModConf)
+ throws ConfigurationException {
return (Object[]) this.get(OP_VALUES, attr, objectModel, staticMod, staticModName, staticModConf, null, null, null);
}
@@ -300,7 +306,8 @@
*/
protected Object[] getValues(String attr, Map objectModel,
InputModule staticMod, String staticModName, Configuration staticModConf,
- InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf) {
+ InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf)
+ throws ConfigurationException {
return (Object[]) this.get(OP_VALUES, attr, objectModel, staticMod, staticModName, staticModConf, dynamicMod, dynamicModName, dynamicModConf);
}
@@ -317,7 +324,8 @@
*/
private Object get(int op, String attr, Map objectModel,
InputModule staticMod, String staticModName, Configuration staticModConf,
- InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf) {
+ InputModule dynamicMod, String dynamicModName, Configuration dynamicModConf)
+ throws ConfigurationException {
ComponentSelector cs = this.inputSelector;
Object value = null;
@@ -327,9 +335,13 @@
boolean release = false;
try {
-
- if (cs == null)
+ if (cs == null) {
+ try {
cs = (ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
+ } catch (ComponentException e) {
+ throw new ConfigurationException("Could not find MetaModule's module selector", e);
+ }
+ }
boolean useDynamic;
if (dynamicMod == null && dynamicModName == null) {
@@ -354,7 +366,14 @@
if (input == null) {
if (cs.hasComponent(name)) {
release = true;
+ try {
input = (InputModule) cs.select(name);
+ } catch (ComponentException e) {
+ throw new ConfigurationException(
+ "MetaModule unable to create "+
+ (useDynamic ? "dynamically" : "statically")+
+ " specified internal module '"+name+"'", e);
+ }
} else {
if (getLogger().isWarnEnabled())
getLogger().warn("No such InputModule: "+name);
@@ -376,9 +395,6 @@
if (getLogger().isDebugEnabled())
getLogger().debug("using "+name+" as "+input+" for "+op+" ("+attr+") and "+conf+" gives "+value);
- } catch (Exception e) {
- if (getLogger().isWarnEnabled())
- getLogger().warn("A problem obtaining a value from "+name+" occurred : "+e.getMessage());
} finally {
if (release)
cs.release(input);