// general setup
String parameterName = param.getParameter("parameter-name",this.defaultParameterName);
boolean useGetValues = param.getParameterAsBoolean("use-getValues",this.useGetValues);
InputModule input = null;
OutputModule output = null;
ComponentSelector inputSelector = null;
ComponentSelector outputSelector = null;
try {
if (getLogger().isDebugEnabled()) getLogger().debug("start...");
// obtain input and output components
inputSelector=(ComponentSelector) this.manager.lookup(INPUT_MODULE_SELECTOR);
if (inputName != null && inputSelector != null && inputSelector.hasComponent(inputName)){
input = (InputModule) inputSelector.select(inputName);
}
outputSelector=(ComponentSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
if (outputName != null && outputSelector != null && outputSelector.hasComponent(outputName)){
output = (OutputModule) outputSelector.select(outputName);
}
if (input != null && output != null) {
if (getLogger().isDebugEnabled()) getLogger().debug("got input and output modules");
// do something
if (parameterName == null) {
if (getLogger().isDebugEnabled()) getLogger().debug("reading all parameter values");
// for a test, read all parameters from input and write them to outout
// get names first, then (one) value per name
Iterator iter = input.getAttributeNames(this.inputConf,objectModel);
while (iter.hasNext()) {
parameterName = (String) iter.next();
Object value = input.getAttribute(parameterName, this.inputConf, objectModel);
output.setAttribute(this.outputConf, objectModel, parameterName, value);
if (getLogger().isDebugEnabled())
getLogger().debug("["+parameterName+"] = ["+value+"]");
}
// ------------------------------------------------------------------------
} else {
if (useGetValues) {
// get all existing values
Object[] value = input.getAttributeValues(parameterName, this.inputConf, objectModel);
output.setAttribute(this.outputConf, objectModel, parameterName, value);
if (getLogger().isDebugEnabled())
for (int i=0; i<value.length; i++)
getLogger().debug("["+parameterName+"["+i+"]] = ["+value[i]+"]");
// ------------------------------------------------------------------------
} else {
// get just one parameter value
if (getLogger().isDebugEnabled())
getLogger().debug("reading parameter values for "+parameterName);
Object value = input.getAttribute(parameterName, this.inputConf, objectModel);
output.setAttribute(this.outputConf, objectModel, parameterName, value);
if (getLogger().isDebugEnabled()) getLogger().debug("["+parameterName+"] = ["+value+"]");
// ------------------------------------------------------------------------
}
}
output.commit(this.outputConf,objectModel);
if (getLogger().isDebugEnabled()) getLogger().debug("done commit");
// done
}
} catch (Exception e) {
throw e;
} finally {
// release components
if (getLogger().isDebugEnabled()) getLogger().debug("releasing components");
if (outputSelector != null) {
if (output != null)
outputSelector.release(output);
this.manager.release(outputSelector);
}
if (inputSelector != null) {
if (input != null)
inputSelector.release(input);