use of nl.nn.coolgen.proxy.CoolGenXMLProxy in project iaf by ibissource.
the class CoolGenWrapperPipe method doPipe.
/**
* Transform the input (optionally), check the conformance to the schema (optionally),
* call the required proxy, transform the output (optionally)
*/
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
Writer proxyResult;
String proxypreProc = null;
Variant inputVar;
String wrapperResult = "";
CoolGenXMLProxy proxy;
ActionListener actionListener = new ActionListener() {
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public String errorMessage;
public void actionPerformed(ActionEvent e) {
errorMessage = e.toString();
}
public String toString() {
return errorMessage;
}
};
Source in;
try {
log.info(getLogPrefix(session) + "instantiating proxy [" + proxyClassName + "] as a temporary fix for broken comm-bridge connections");
proxy = createProxy(proxyClassName);
} catch (ConfigurationException ce) {
String msg = getLogPrefix(session) + "cannot recreate proxy after exception";
log.error(msg, ce);
throw new PipeRunException(this, msg, ce);
}
proxy.addExceptionListener(actionListener);
try {
inputVar = new Variant(input);
in = inputVar.asXmlSource();
if (preProcTransformer != null) {
proxypreProc = XmlUtils.transformXml(preProcTransformer, in);
log.debug(getLogPrefix(session) + "] preprocessing transformed message into [" + proxypreProc + "]");
} else
proxypreProc = inputVar.asString();
if (proxyInputFixTransformer != null)
proxypreProc = XmlUtils.transformXml(proxyInputFixTransformer, proxypreProc);
proxyResult = new StringWriter(10 * 1024);
try {
proxy.clear();
} catch (PropertyVetoException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot clear CoolGen proxy", e);
}
try {
proxy.executeXML(new StringReader(proxypreProc), proxyResult);
proxy.removeExceptionListener(actionListener);
String err = actionListener.toString();
if (err != null) {
// if an error occurs, recreate the proxy and throw an exception
log.debug(getLogPrefix(session) + "got error, recreating proxy with class [" + proxyClassName + "]");
try {
proxy = createProxy(proxyClassName);
} catch (ConfigurationException e) {
throw new PipeRunException(this, getLogPrefix(session) + "cannot recreate proxy [" + proxyClassName + "]", e);
}
throw new PipeRunException(this, getLogPrefix(session) + "error excuting proxy [" + proxyClassName + "]:" + err);
}
} catch (XmlProxyException xpe) {
try {
proxy = createProxy(proxyClassName);
} catch (ConfigurationException ce) {
log.error(getLogPrefix(session) + "cannot recreate proxy", xpe);
}
throw new PipeRunException(this, getLogPrefix(session) + "error excecuting proxy", xpe);
}
if (postProcTransformer != null) {
log.debug(getLogPrefix(session) + " CoolGen proxy returned: [" + proxyResult.toString() + "]");
wrapperResult = XmlUtils.transformXml(postProcTransformer, proxyResult.toString());
} else
wrapperResult = proxyResult.toString();
} catch (DomBuilderException e) {
throw new PipeRunException(this, getLogPrefix(session) + "DomBuilderException excecuting proxy", e);
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + "IOException excecuting proxy", e);
} catch (TransformerException e) {
throw new PipeRunException(this, getLogPrefix(session) + "TransformerException excecuting proxy", e);
}
return new PipeRunResult(getForward(), wrapperResult);
}
use of nl.nn.coolgen.proxy.CoolGenXMLProxy in project iaf by ibissource.
the class CoolGenWrapperPipe method createProxy.
public CoolGenXMLProxy createProxy(String proxyName) throws ConfigurationException {
CoolGenXMLProxy proxy;
try {
Class klass = Class.forName(proxyName);
proxy = (CoolGenXMLProxy) klass.newInstance();
proxy.setClientId(getClientId());
proxy.setClientPassword(getClientPassword());
if (log.isDebugEnabled())
proxy.setTracing(1);
else
proxy.setTracing(0);
} catch (Exception e) {
throw new ConfigurationException(getLogPrefix(null) + "could not create proxy [" + proxyName + "]", e);
}
return proxy;
}
Aggregations