Created
October 19, 2011 13:23
-
-
Save zubairov/1298271 to your computer and use it in GitHub Desktop.
Job with tXMLMap enabled that does not work on runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ============================================================================ | |
// | |
// Copyright (c) 2005-2010, Talend Inc. | |
// | |
// This source code has been automatically generated by_Talend Open Studio for ESB | |
// / JobDesigner (CodeGenerator version 5.0.0.NB_r70466) | |
// You can find more information about Talend products at www.talend.com. | |
// You may distribute this code under the terms of the GNU LGPL license | |
// http://www.gnu.org/licenses/lgpl.html). | |
// | |
// ============================================================================ | |
package demo1.airportsoap_getairportinformationbyisocountrycode_0_1; | |
import routines.Mathematical; | |
import routines.DataOperation; | |
import routines.Relational; | |
import routines.TalendDate; | |
import routines.TalendDataGenerator; | |
import routines.Numeric; | |
import routines.TalendString; | |
import routines.StringHandling; | |
import routines.system.*; | |
import routines.system.api.*; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.List; | |
import java.math.BigDecimal; | |
import java.io.ByteArrayOutputStream; | |
import java.io.ByteArrayInputStream; | |
import java.io.DataInputStream; | |
import java.io.DataOutputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.ObjectInputStream; | |
import java.io.IOException; | |
import java.util.Comparator; | |
/** | |
* Job: airportSoap_getAirportInformationByISOCountryCode Purpose: <br> | |
* Description: <br> | |
* | |
* @author test@talend.com | |
* @version 5.0.0.NB_r70466 | |
* @status | |
*/ | |
public class airportSoap_getAirportInformationByISOCountryCode implements | |
TalendESBJob { | |
public final Object obj = new Object(); | |
// for transmiting parameters purpose | |
private Object valueObject = null; | |
public Object getValueObject() { | |
return this.valueObject; | |
} | |
public void setValueObject(Object valueObject) { | |
this.valueObject = valueObject; | |
} | |
private final static String defaultCharset = java.nio.charset.Charset | |
.defaultCharset().name(); | |
private final static String utf8Charset = "UTF-8"; | |
// create and load default properties | |
private java.util.Properties defaultProps = new java.util.Properties(); | |
// create application properties with default | |
public class ContextProperties extends java.util.Properties { | |
public ContextProperties(java.util.Properties properties) { | |
super(properties); | |
} | |
public ContextProperties() { | |
super(); | |
} | |
public void synchronizeContext() { | |
} | |
} | |
private ContextProperties context = new ContextProperties(); | |
public ContextProperties getContext() { | |
return this.context; | |
} | |
private final String jobVersion = "0.1"; | |
private final String jobName = "airportSoap_getAirportInformationByISOCountryCode"; | |
private final String projectName = "DEMO1"; | |
public Integer errorCode = null; | |
private String currentComponent = ""; | |
private final java.util.Map<String, Long> start_Hash = new java.util.HashMap<String, Long>(); | |
private final java.util.Map<String, Long> end_Hash = new java.util.HashMap<String, Long>(); | |
private final java.util.Map<String, Boolean> ok_Hash = new java.util.HashMap<String, Boolean>(); | |
private final java.util.Map<String, Object> globalMap = new java.util.HashMap<String, Object>(); | |
public final java.util.List<String[]> globalBuffer = new java.util.ArrayList<String[]>(); | |
private RunStat runStat = new RunStat(); | |
public boolean isExportedAsOSGI = false; | |
private final java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); | |
private final java.io.PrintStream errorMessagePS = new java.io.PrintStream( | |
new java.io.BufferedOutputStream(baos)); | |
public String getExceptionStackTrace() { | |
if ("failure".equals(this.getStatus())) { | |
errorMessagePS.flush(); | |
return baos.toString(); | |
} | |
return null; | |
} | |
private Exception exception = null; | |
public Exception getException() { | |
if ("failure".equals(this.getStatus())) { | |
return this.exception; | |
} | |
return null; | |
} | |
private class TalendException extends Exception { | |
private java.util.Map<String, Object> globalMap = null; | |
private Exception e = null; | |
private String currentComponent = null; | |
private TalendException(Exception e, String errorComponent, | |
final java.util.Map<String, Object> globalMap) { | |
this.currentComponent = errorComponent; | |
this.globalMap = globalMap; | |
this.e = e; | |
} | |
@Override | |
public void printStackTrace() { | |
if (!(e instanceof TalendException || e instanceof TDieException)) { | |
globalMap.put(currentComponent + "_ERROR_MESSAGE", e | |
.getMessage()); | |
System.err | |
.println("Exception in component " + currentComponent); | |
} | |
if (!(e instanceof TDieException)) { | |
if (e instanceof TalendException) { | |
e.printStackTrace(); | |
} else { | |
e.printStackTrace(); | |
e.printStackTrace(errorMessagePS); | |
airportSoap_getAirportInformationByISOCountryCode.this.exception = e; | |
} | |
} | |
if (!(e instanceof TalendException)) { | |
try { | |
for (java.lang.reflect.Method m : this.getClass() | |
.getEnclosingClass().getMethods()) { | |
if (m.getName().compareTo(currentComponent + "_error") == 0) { | |
m.invoke( | |
airportSoap_getAirportInformationByISOCountryCode.this, | |
new Object[] { e, currentComponent, | |
globalMap }); | |
break; | |
} | |
} | |
if (!(e instanceof TDieException)) { | |
} | |
} catch (java.lang.SecurityException e) { | |
this.e.printStackTrace(); | |
} catch (java.lang.IllegalArgumentException e) { | |
this.e.printStackTrace(); | |
} catch (java.lang.IllegalAccessException e) { | |
this.e.printStackTrace(); | |
} catch (java.lang.reflect.InvocationTargetException e) { | |
this.e.printStackTrace(); | |
} | |
} | |
} | |
} | |
public void tLogRow_1_error(Exception exception, String errorComponent, | |
final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tLogRow_1", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tESBProviderResponse_1_error(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tESBProviderResponse_1", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tESBProviderRequest_1_Loop_error(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tESBProviderRequest_1_Loop", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tESBProviderRequest_1_In_error(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tESBProviderRequest_1_In", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tXMLMap_1_TXMLMAP_OUT_error(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tXMLMap_1_TXMLMAP_OUT", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tXMLMap_1_TXMLMAP_IN_error(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
end_Hash.put("tXMLMap_1_TXMLMAP_IN", System.currentTimeMillis()); | |
tESBProviderRequest_1_Loop_onSubJobError(exception, errorComponent, | |
globalMap); | |
} | |
public void tESBProviderRequest_1_Loop_onSubJobError(Exception exception, | |
String errorComponent, final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread | |
.currentThread().getId() | |
+ "", "FATAL", "", exception.getMessage(), ResumeUtil | |
.getExceptionStackTrace(exception), ""); | |
} | |
interface ESBProviderCallbackTalendJobInner extends ESBProviderCallback { | |
void setCustomProperties(java.util.Map<String, String> props); | |
void sendFault(Throwable e); | |
void sendBusinessFault(String faultString, | |
org.dom4j.Document faultDetail); | |
} | |
private ESBEndpointRegistry registry = null; | |
private ESBProviderCallback callback = null; | |
public void setEndpointRegistry(ESBEndpointRegistry registry) { | |
} | |
public void setProviderCallback(ESBProviderCallback callback) { | |
this.callback = callback; | |
} | |
public ESBEndpointInfo getEndpoint() { | |
return new ESBEndpointInfo() { | |
@SuppressWarnings("serial") | |
private java.util.Map<String, Object> props = new java.util.HashMap<String, Object>() { | |
{ | |
// "request-response" or "one-way" | |
put("COMMUNICATION_STYLE", "request-response"); | |
put("dataFormat", "PAYLOAD"); | |
put("portName", "{http://airportsoap.sopera.de}airportSoap"); | |
put("serviceName", "{http://airportsoap.sopera.de}airport"); | |
put("defaultOperationName", | |
"getAirportInformationByISOCountryCode"); | |
put("defaultOperationNameSpace", | |
"http://airportsoap.sopera.de"); | |
put("publishedEndpointUrl", | |
"http://localhost:8200/esb/AirportService"); | |
} | |
}; | |
public String getEndpointKey() { | |
return "cxf"; | |
} | |
public String getEndpointUri() { | |
// projectName + "_" + processName | |
return "DEMO1_airportSoap_getAirportInformationByISOCountryCode"; | |
} | |
public java.util.Map<String, Object> getEndpointProperties() { | |
return props; | |
} | |
}; | |
} | |
/** | |
* queued message exchange | |
*/ | |
public class QueuedExchangeContextImpl<T> { | |
/** | |
* Exchange timeout in seconds | |
*/ | |
private static final long EXCHANGE_TIMEOUT = 50; | |
private final java.util.concurrent.Exchanger<Exception> exceptionExchange = new java.util.concurrent.Exchanger<Exception>(); | |
private final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch( | |
1); | |
private final T input; | |
private T output = null; | |
private Throwable fault = null; | |
public QueuedExchangeContextImpl(T inMsg) { | |
this.input = inMsg; | |
} | |
/** | |
* Don't forget to call this method when you are done with processing of | |
* the {@link QueuedExchangeContext} | |
*/ | |
public void release() throws Exception { | |
latch.countDown(); | |
Exception exception; | |
try { | |
exception = exceptionExchange.exchange(null, EXCHANGE_TIMEOUT, | |
java.util.concurrent.TimeUnit.SECONDS); | |
} catch (InterruptedException e) { | |
throw new Exception(e); | |
} catch (java.util.concurrent.TimeoutException e) { | |
throw new Exception(e); | |
} | |
if (exception != null) { | |
throw exception; | |
} | |
} | |
/** | |
* This operation have to be called on the Web Service thread to send | |
* response if required | |
* | |
* @throws InterruptedException | |
*/ | |
public void completeQueuedProcessing() throws InterruptedException { | |
exceptionExchange.exchange(null); | |
} | |
/** | |
* @throws InterruptedException | |
*/ | |
void waitForRelease(long timeout, java.util.concurrent.TimeUnit unit) | |
throws InterruptedException { | |
latch.await(timeout, unit); | |
} | |
public T getInputMessage() { | |
return input; | |
} | |
public void serveOutputMessage(T response) { | |
output = response; | |
} | |
public void serveFault(Throwable fault) { | |
this.fault = fault; | |
} | |
public boolean isFault() { | |
return fault != null; | |
} | |
public T getResponse() { | |
return output; | |
} | |
public Throwable getFault() { | |
return fault; | |
} | |
} | |
/** | |
* message exchange controller | |
*/ | |
public class QueuedMessageHandlerImpl<T> implements ESBProviderCallback { | |
private final int MAX_QUEUE_SIZE = 1000; | |
private final int WAIT_TIMEOUT_SECONDS = 120; | |
private final java.util.concurrent.BlockingQueue<QueuedExchangeContextImpl<?>> queue = new java.util.concurrent.LinkedBlockingQueue<QueuedExchangeContextImpl<?>>( | |
MAX_QUEUE_SIZE); | |
/** | |
* This method add a newly created {@link QueuedExchangeContextImpl} | |
* into the internal blocking queue where consumer thread is waiting for | |
* it. Then it waits until the {@link QueuedExchangeContextImpl} will be | |
* completed for request-response operations | |
*/ | |
public QueuedExchangeContextImpl<T> invoke(T request) { | |
QueuedExchangeContextImpl<T> context = new QueuedExchangeContextImpl<T>( | |
request); | |
boolean inserted = queue.offer(context); | |
if (!inserted) { | |
try { | |
context.release(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
// context.serveFault("job pool overflow exceed", null); | |
throw new RuntimeException( | |
"Can't queue request, queue size of " + MAX_QUEUE_SIZE | |
+ " is exceeded"); | |
} else { | |
try { | |
context.waitForRelease(WAIT_TIMEOUT_SECONDS, | |
java.util.concurrent.TimeUnit.SECONDS); | |
} catch (InterruptedException ie) { | |
// context.serveFault("job execution timeout", ie); | |
throw new RuntimeException("job execution timeout: " | |
+ ie.getMessage()); | |
} | |
} | |
return context; | |
} | |
QueuedExchangeContextImpl<T> currentExchangeContext; | |
public T getRequest() throws ESBJobInterruptedException { | |
currentExchangeContext = null; | |
try { | |
currentExchangeContext = (QueuedExchangeContextImpl<T>) queue | |
.take(); | |
} catch (InterruptedException e) { | |
// e.printStackTrace(); | |
throw new RuntimeException(e); | |
} | |
return currentExchangeContext.getInputMessage(); | |
} | |
public void sendResponse(Object output) { | |
if (null == currentExchangeContext) { | |
throw new RuntimeException( | |
"sendResponse() invoked before getRequest()"); | |
} | |
if (output instanceof Throwable) { | |
// fault | |
currentExchangeContext.serveFault((Throwable) output); | |
} else { | |
// response | |
currentExchangeContext.serveOutputMessage((T) output); | |
} | |
try { | |
currentExchangeContext.release(); | |
} catch (Exception e) { | |
// e.printStackTrace(); | |
throw new RuntimeException(e); | |
} | |
} | |
} | |
/** | |
* web service provider implementation | |
*/ | |
@javax.jws.soap.SOAPBinding(parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.BARE) | |
@javax.xml.ws.ServiceMode(value = javax.xml.ws.Service.Mode.PAYLOAD) | |
@javax.xml.ws.WebServiceProvider(wsdlLocation = "/Users/zubairov/Downloads/TESB_SE-All-r70466-V5.0.0NB/workspace/DEMO1/services/DemoService_0.1.wsdl", targetNamespace = "http://airportsoap.sopera.de", serviceName = "airport", portName = "airportSoap") | |
public class ESBProvider_tESBProviderRequest_1 implements | |
javax.xml.ws.Provider<javax.xml.transform.Source> { | |
private final javax.xml.ws.WebServiceProvider annotation = ESBProvider_tESBProviderRequest_1.class | |
.getAnnotation(javax.xml.ws.WebServiceProvider.class); | |
private final String TARGET_NS = annotation.targetNamespace(); | |
private final String SERVICE_NAME = annotation.serviceName(); | |
private final String PORT_NAME = annotation.portName(); | |
private final javax.xml.namespace.QName serviceName = new javax.xml.namespace.QName( | |
TARGET_NS, SERVICE_NAME); | |
private final javax.xml.namespace.QName portName = new javax.xml.namespace.QName( | |
TARGET_NS, PORT_NAME); | |
private final javax.xml.namespace.QName operationName = new javax.xml.namespace.QName( | |
"http://airportsoap.sopera.de", | |
"getAirportInformationByISOCountryCode"); | |
private javax.xml.transform.TransformerFactory factory = javax.xml.transform.TransformerFactory | |
.newInstance(); | |
private QueuedMessageHandlerImpl<org.dom4j.Document> messageHandler; | |
@javax.annotation.Resource() | |
private javax.xml.ws.WebServiceContext context; | |
public ESBProvider_tESBProviderRequest_1( | |
QueuedMessageHandlerImpl<org.dom4j.Document> messageHandler) { | |
this.messageHandler = messageHandler; | |
} | |
public javax.xml.transform.Source invoke( | |
javax.xml.transform.Source request) { | |
// System.out.println(System.currentTimeMillis() + | |
// " -> handleMessage"); | |
try { | |
javax.xml.namespace.QName operation = (javax.xml.namespace.QName) context | |
.getMessageContext() | |
.get(javax.xml.ws.handler.MessageContext.WSDL_OPERATION); | |
javax.xml.namespace.QName port = (javax.xml.namespace.QName) context | |
.getMessageContext().get( | |
javax.xml.ws.handler.MessageContext.WSDL_PORT); | |
javax.xml.namespace.QName service = (javax.xml.namespace.QName) context | |
.getMessageContext() | |
.get(javax.xml.ws.handler.MessageContext.WSDL_SERVICE); | |
if (serviceName.equals(service) && portName.equals(port) | |
&& operationName.equals(operation)) { | |
// System.out.println("request to implemented operation"); | |
} else { | |
throw new RuntimeException( | |
"operation not implemented by job"); | |
} | |
org.dom4j.io.DocumentResult docResult = new org.dom4j.io.DocumentResult(); | |
factory.newTransformer().transform(request, docResult); | |
org.dom4j.Document requestDoc = docResult.getDocument(); | |
// System.out.println("request: " + requestDoc.asXML()); | |
QueuedExchangeContextImpl<org.dom4j.Document> messageExchange = messageHandler | |
.invoke(requestDoc); | |
try { | |
if (messageExchange.isFault()) { | |
throw messageExchange.getFault(); | |
} else { | |
org.dom4j.Document responseDoc = messageExchange | |
.getResponse(); | |
if (null == responseDoc) { | |
// System.out.println("response: empty"); | |
throw new RuntimeException( | |
"no response provided by Talend job"); | |
} | |
// System.out.println("response: " + | |
// responseDoc.asXML()); | |
return new org.dom4j.io.DocumentSource(responseDoc); | |
} | |
} finally { | |
messageExchange.completeQueuedProcessing(); | |
} | |
} catch (RuntimeException ex) { | |
throw ex; | |
} catch (Throwable ex) { | |
ex.printStackTrace(); | |
throw new RuntimeException(ex); | |
} finally { | |
// System.out.println(System.currentTimeMillis() + | |
// " <- handleMessage"); | |
} | |
} | |
} | |
public class ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1 | |
implements ESBProviderCallbackTalendJobInner { | |
private final String TNS = ESBProvider_tESBProviderRequest_1.class | |
.getAnnotation(javax.xml.ws.WebServiceProvider.class) | |
.targetNamespace(); | |
private ESBProviderCallback esbProviderCallback; | |
private java.util.Map<String, String> customProperty; | |
public ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1( | |
ESBProviderCallback callback) { | |
esbProviderCallback = callback; | |
} | |
public Object getRequest() throws ESBJobInterruptedException { | |
return esbProviderCallback.getRequest(); | |
} | |
public void setCustomProperties(java.util.Map<String, String> props) { | |
customProperty = props; | |
} | |
public void sendResponse(Object response) { | |
esbProviderCallback.sendResponse(wrapOutput(response)); | |
} | |
public void sendFault(Throwable error) { | |
RuntimeException talendJobError; | |
if (error instanceof RuntimeException) { | |
talendJobError = (RuntimeException) error; | |
} else { | |
talendJobError = new RuntimeException( | |
"Talend job execution error", error); | |
} | |
esbProviderCallback.sendResponse(talendJobError); | |
} | |
public void sendBusinessFault(String faultString, | |
org.dom4j.Document faultDetail) { | |
try { | |
javax.xml.soap.SOAPFactory soapFactory = javax.xml.soap.SOAPFactory | |
.newInstance(); | |
javax.xml.soap.SOAPFault soapFault = soapFactory.createFault( | |
faultString, new javax.xml.namespace.QName(TNS, | |
"businessFault")); | |
if (null != faultDetail) { | |
// System.out.println("business fault details: " + | |
// faultDoc.asXML()); | |
// A special version of DOMWriter that does not write | |
// xmlns:foo attributes | |
org.dom4j.io.DOMWriter writer = new org.dom4j.io.DOMWriter() { | |
protected void writeNamespace( | |
org.w3c.dom.Element domElement, | |
org.dom4j.Namespace namespace) { | |
// Do nothing | |
} | |
}; | |
org.w3c.dom.Document faultDetailDom = writer | |
.write(faultDetail); | |
soapFault.addDetail().appendChild( | |
soapFault.getOwnerDocument().importNode( | |
faultDetailDom.getDocumentElement(), true)); | |
} | |
esbProviderCallback | |
.sendResponse(wrapOutput(new javax.xml.ws.soap.SOAPFaultException( | |
soapFault))); | |
} catch (Exception e) { | |
this.sendFault(e); | |
} | |
} | |
private Object wrapOutput(Object output) { | |
if (esbProviderCallback instanceof QueuedMessageHandlerImpl) { | |
return output; | |
} | |
return wrapPayload(output, customProperty); | |
} | |
} | |
class HandlerThread_tESBProviderRequest_1 extends Thread { | |
private javax.xml.ws.Endpoint endpoint; | |
QueuedMessageHandlerImpl<org.dom4j.Document> handler; | |
String endpointUrl = "http://localhost:8200/esb/AirportService"; | |
public HandlerThread_tESBProviderRequest_1( | |
QueuedMessageHandlerImpl<org.dom4j.Document> handler) { | |
this.handler = handler; | |
} | |
public void run() { | |
// handle relative uri | |
String defaultPort = (String) System.getProperties().get( | |
"wsHttpPort"); | |
if (null == defaultPort || defaultPort.trim().isEmpty()) { | |
defaultPort = "8088"; | |
} | |
if (null == endpointUrl || endpointUrl.trim().isEmpty()) { | |
endpointUrl = "http://localhost:" + defaultPort + "/"; | |
} | |
if (!endpointUrl.contains("://")) { | |
if (!endpointUrl.startsWith("/")) { | |
endpointUrl = "/" + endpointUrl; | |
} | |
endpointUrl = "http://localhost:" + defaultPort + endpointUrl; | |
} | |
// test for busy | |
java.net.ServerSocket ss = null; | |
try { | |
java.net.URL endpointURL = new java.net.URL(endpointUrl); | |
String host = endpointURL.getHost(); | |
int port = endpointURL.getPort(); | |
if ("localhost".equals(host) || host.startsWith("127.0.0")) { | |
try { | |
ss = new java.net.ServerSocket(port); | |
} catch (IOException e) { | |
// rethrow exception | |
throw new IllegalArgumentException( | |
"Cannot start provider with uri: " | |
+ endpointUrl + ". Port " + port | |
+ " already in use."); | |
} finally { | |
if (ss != null) { | |
try { | |
ss.close(); | |
} catch (IOException e) { | |
// ignore | |
} | |
} | |
} | |
try { | |
// ok, let's doublecheck for silent listeners | |
java.net.Socket cs = new java.net.Socket(host, port); | |
// if succeed - somebody silently listening, fail! | |
cs.close(); | |
// rethrow exception | |
throw new IllegalArgumentException( | |
"Cannot start provider with uri: " | |
+ endpointUrl + ". Port " + port | |
+ " already in use."); | |
} catch (IOException e) { | |
// ok, nobody listens, proceed | |
} | |
} | |
} catch (java.net.MalformedURLException e) { | |
// rethrow exception | |
throw new IllegalArgumentException( | |
"Cannot start provider with uri: " + endpointUrl | |
+ ". Malformed URL."); | |
} | |
// Endpoint is always null now so that WSDL value should be used | |
endpoint = javax.xml.ws.Endpoint.publish(null, | |
new ESBProvider_tESBProviderRequest_1(handler)); | |
System.out.println("web service [endpoint: " + endpointUrl | |
+ "] published"); | |
} | |
public void stopEndpoint() { | |
if (null != endpoint) { | |
endpoint.stop(); | |
System.out.println("web service [endpoint: " + endpointUrl | |
+ "] unpublished"); | |
} | |
} | |
} | |
private Object wrapPayload(Object payload, Object customProperties) { | |
java.util.Map<String, Object> outputWrapped = new java.util.HashMap<String, Object>(); | |
outputWrapped.put("PAYLOAD", payload); | |
if (null != customProperties) { | |
outputWrapped.put("SAM-PROPS", customProperties); | |
} | |
return outputWrapped; | |
} | |
public static class responseStruct implements | |
routines.system.IPersistableRow<responseStruct> { | |
final static byte[] commonByteArrayLock = new byte[0]; | |
static byte[] commonByteArray = new byte[0]; | |
public Document payload; | |
public Document getPayload() { | |
return this.payload; | |
} | |
public java.util.Map<String, Object> documentLookupResult = new java.util.HashMap<String, Object>(); | |
public void readData(ObjectInputStream dis) { | |
synchronized (commonByteArrayLock) { | |
try { | |
int length = 0; | |
this.payload = (Document) dis.readObject(); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} catch (ClassNotFoundException eCNFE) { | |
throw new RuntimeException(eCNFE); | |
} | |
} | |
} | |
public void writeData(ObjectOutputStream dos) { | |
try { | |
// Document | |
dos.writeObject(this.payload); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
public String toString() { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(super.toString()); | |
sb.append("["); | |
sb.append("payload=" + String.valueOf(payload)); | |
sb.append("]"); | |
return sb.toString(); | |
} | |
/** | |
* Compare keys | |
*/ | |
public int compareTo(responseStruct other) { | |
int returnValue = -1; | |
return returnValue; | |
} | |
private int checkNullsAndCompare(Object object1, Object object2) { | |
int returnValue = 0; | |
if (object1 instanceof Comparable && object2 instanceof Comparable) { | |
returnValue = ((Comparable) object1).compareTo(object2); | |
} else if (object1 != null && object2 != null) { | |
returnValue = compareStrings(object1.toString(), object2 | |
.toString()); | |
} else if (object1 == null && object2 != null) { | |
returnValue = 1; | |
} else if (object1 != null && object2 == null) { | |
returnValue = -1; | |
} else { | |
returnValue = 0; | |
} | |
return returnValue; | |
} | |
private int compareStrings(String string1, String string2) { | |
return string1.compareTo(string2); | |
} | |
} | |
public static class row2Struct implements | |
routines.system.IPersistableRow<row2Struct> { | |
final static byte[] commonByteArrayLock = new byte[0]; | |
static byte[] commonByteArray = new byte[0]; | |
public Document payload; | |
public Document getPayload() { | |
return this.payload; | |
} | |
public java.util.Map<String, Object> documentLookupResult = new java.util.HashMap<String, Object>(); | |
public void readData(ObjectInputStream dis) { | |
synchronized (commonByteArrayLock) { | |
try { | |
int length = 0; | |
this.payload = (Document) dis.readObject(); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} catch (ClassNotFoundException eCNFE) { | |
throw new RuntimeException(eCNFE); | |
} | |
} | |
} | |
public void writeData(ObjectOutputStream dos) { | |
try { | |
// Document | |
dos.writeObject(this.payload); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
public String toString() { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(super.toString()); | |
sb.append("["); | |
sb.append("payload=" + String.valueOf(payload)); | |
sb.append("]"); | |
return sb.toString(); | |
} | |
/** | |
* Compare keys | |
*/ | |
public int compareTo(row2Struct other) { | |
int returnValue = -1; | |
return returnValue; | |
} | |
private int checkNullsAndCompare(Object object1, Object object2) { | |
int returnValue = 0; | |
if (object1 instanceof Comparable && object2 instanceof Comparable) { | |
returnValue = ((Comparable) object1).compareTo(object2); | |
} else if (object1 != null && object2 != null) { | |
returnValue = compareStrings(object1.toString(), object2 | |
.toString()); | |
} else if (object1 == null && object2 != null) { | |
returnValue = 1; | |
} else if (object1 != null && object2 == null) { | |
returnValue = -1; | |
} else { | |
returnValue = 0; | |
} | |
return returnValue; | |
} | |
private int compareStrings(String string1, String string2) { | |
return string1.compareTo(string2); | |
} | |
} | |
public static class row1Struct implements | |
routines.system.IPersistableRow<row1Struct> { | |
final static byte[] commonByteArrayLock = new byte[0]; | |
static byte[] commonByteArray = new byte[0]; | |
public Document payload; | |
public Document getPayload() { | |
return this.payload; | |
} | |
public java.util.Map<String, Object> documentLookupResult = new java.util.HashMap<String, Object>(); | |
public void readData(ObjectInputStream dis) { | |
synchronized (commonByteArrayLock) { | |
try { | |
int length = 0; | |
this.payload = (Document) dis.readObject(); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} catch (ClassNotFoundException eCNFE) { | |
throw new RuntimeException(eCNFE); | |
} | |
} | |
} | |
public void writeData(ObjectOutputStream dos) { | |
try { | |
// Document | |
dos.writeObject(this.payload); | |
} catch (IOException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
public String toString() { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(super.toString()); | |
sb.append("["); | |
sb.append("payload=" + String.valueOf(payload)); | |
sb.append("]"); | |
return sb.toString(); | |
} | |
/** | |
* Compare keys | |
*/ | |
public int compareTo(row1Struct other) { | |
int returnValue = -1; | |
return returnValue; | |
} | |
private int checkNullsAndCompare(Object object1, Object object2) { | |
int returnValue = 0; | |
if (object1 instanceof Comparable && object2 instanceof Comparable) { | |
returnValue = ((Comparable) object1).compareTo(object2); | |
} else if (object1 != null && object2 != null) { | |
returnValue = compareStrings(object1.toString(), object2 | |
.toString()); | |
} else if (object1 == null && object2 != null) { | |
returnValue = 1; | |
} else if (object1 != null && object2 == null) { | |
returnValue = -1; | |
} else { | |
returnValue = 0; | |
} | |
return returnValue; | |
} | |
private int compareStrings(String string1, String string2) { | |
return string1.compareTo(string2); | |
} | |
} | |
public void tESBProviderRequest_1_LoopProcess( | |
final java.util.Map<String, Object> globalMap) | |
throws TalendException { | |
globalMap.put("tESBProviderRequest_1_Loop_SUBPROCESS_STATE", 0); | |
final boolean execStat = this.execStat; | |
String iterateId = ""; | |
String currentComponent = ""; | |
try { | |
String currentMethodName = new Exception().getStackTrace()[0] | |
.getMethodName(); | |
boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); | |
if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start | |
// the | |
// resume | |
globalResumeTicket = true; | |
row1Struct row1 = new row1Struct(); | |
row1Struct row2 = row1; | |
responseStruct response = new responseStruct(); | |
/** | |
* [tESBProviderRequest_1_Loop begin ] start | |
*/ | |
int NB_ITERATE_tESBProviderRequest_1_In = 0; // for statistics | |
ok_Hash.put("tESBProviderRequest_1_Loop", false); | |
start_Hash.put("tESBProviderRequest_1_Loop", System | |
.currentTimeMillis()); | |
currentComponent = "tESBProviderRequest_1_Loop"; | |
int tos_count_tESBProviderRequest_1_Loop = 0; | |
// *** external processor(s) initialization | |
ESBProviderCallbackTalendJobInner providerCallback_tESBProviderRequest_1; | |
HandlerThread_tESBProviderRequest_1 handlerThread_tESBProviderRequest_1 = null; | |
if (null == this.callback) { | |
final QueuedMessageHandlerImpl<org.dom4j.Document> handler_tESBProviderRequest_1 = new QueuedMessageHandlerImpl<org.dom4j.Document>(); | |
handlerThread_tESBProviderRequest_1 = new HandlerThread_tESBProviderRequest_1( | |
handler_tESBProviderRequest_1); // | |
handlerThread_tESBProviderRequest_1.start(); | |
providerCallback_tESBProviderRequest_1 = new ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1( | |
handler_tESBProviderRequest_1); | |
} else { | |
providerCallback_tESBProviderRequest_1 = new ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1( | |
this.callback); | |
} | |
globalMap.put("esbHandler", | |
providerCallback_tESBProviderRequest_1); | |
// *** external processor(s) initialization finish | |
int nb_line_tESBProviderRequest_1 = 0; | |
try { | |
// This is a beginning of the ESB provider request component | |
// cycle | |
while (true) { | |
try { | |
ESBProviderCallbackTalendJobInner esbHandler_tESBProviderRequest_1 = (ESBProviderCallbackTalendJobInner) globalMap | |
.get("esbHandler"); | |
org.dom4j.Document requestMessage_tESBProviderRequest_1 = (org.dom4j.Document) esbHandler_tESBProviderRequest_1 | |
.getRequest(); | |
/** | |
* [tESBProviderRequest_1_Loop begin ] stop | |
*/ | |
/** | |
* [tESBProviderRequest_1_Loop main ] start | |
*/ | |
currentComponent = "tESBProviderRequest_1_Loop"; | |
tos_count_tESBProviderRequest_1_Loop++; | |
/** | |
* [tESBProviderRequest_1_Loop main ] stop | |
*/ | |
NB_ITERATE_tESBProviderRequest_1_In++; | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"row2", | |
3, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
} | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"response", | |
3, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
} | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"row1", | |
3, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
} | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"OnRowsEnd", | |
3, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
} | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"Iterate", | |
1, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
// Thread.sleep(1000); | |
} | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT begin ] start | |
*/ | |
ok_Hash.put("tXMLMap_1_TXMLMAP_OUT", false); | |
start_Hash.put("tXMLMap_1_TXMLMAP_OUT", System | |
.currentTimeMillis()); | |
currentComponent = "tXMLMap_1_TXMLMAP_OUT"; | |
if (execStat) { | |
runStat.updateStatOnConnection("row2" | |
+ iterateId, 0, 0); | |
} | |
int tos_count_tXMLMap_1_TXMLMAP_OUT = 0; | |
// ===============================input xml init | |
// part=============================== | |
class NameSpaceTool_tXMLMap_1_TXMLMAP_OUT { | |
public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>(); | |
private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>(); | |
public void countNSMap(org.dom4j.Element el) { | |
for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el | |
.declaredNamespaces()) { | |
if (ns.getPrefix().trim().length() == 0) { | |
xmlNameSpaceMap.put("pre" | |
+ defualtNSPath.size(), ns | |
.getURI()); | |
String path = ""; | |
org.dom4j.Element elTmp = el; | |
while (elTmp != null) { | |
if (elTmp.getNamespacePrefix() != null | |
&& elTmp.getNamespacePrefix() | |
.length() > 0) { | |
path = "/" | |
+ elTmp.getNamespacePrefix() | |
+ ":" | |
+ elTmp.getName() | |
+ path; | |
} else { | |
path = "/" | |
+ elTmp.getName() | |
+ path; | |
} | |
elTmp = elTmp.getParent(); | |
} | |
defualtNSPath.add(path); | |
} else { | |
xmlNameSpaceMap.put(ns.getPrefix(), | |
ns.getURI()); | |
} | |
} | |
for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el | |
.elements()) { | |
countNSMap(e); | |
} | |
} | |
public String addDefaultNSPrefix(String path, | |
String loopPath) { | |
if (defualtNSPath.size() > 0) { | |
String fullPath = loopPath; | |
if (!path.equals(fullPath)) { | |
for (String tmp : path.split("/")) { | |
if (("..").equals(tmp)) { | |
fullPath = fullPath | |
.substring( | |
0, | |
fullPath.lastIndexOf("/")); | |
} else { | |
fullPath += "/" + tmp; | |
} | |
} | |
} | |
int[] indexs = new int[fullPath | |
.split("/").length - 1]; | |
java.util.Arrays.fill(indexs, -1); | |
int length = 0; | |
for (int i = 0; i < defualtNSPath | |
.size(); i++) { | |
if (defualtNSPath.get(i).length() > length | |
&& fullPath | |
.startsWith(defualtNSPath | |
.get(i))) { | |
java.util.Arrays | |
.fill( | |
indexs, | |
defualtNSPath | |
.get(i) | |
.split( | |
"/").length - 2, | |
indexs.length, | |
i); | |
length = defualtNSPath.get(i) | |
.length(); | |
} | |
} | |
StringBuilder newPath = new StringBuilder(); | |
String[] pathStrs = path.split("/"); | |
for (int i = 0; i < pathStrs.length; i++) { | |
String tmp = pathStrs[i]; | |
if (newPath.length() > 0) { | |
newPath.append("/"); | |
} | |
if (tmp.length() > 0 | |
&& tmp.indexOf(":") == -1 | |
&& tmp.indexOf(".") == -1 /* | |
* && | |
* tmp | |
* . | |
* indexOf | |
* ( | |
* "@" | |
* ) | |
* == | |
* - | |
* 1 | |
*/) { | |
int index = indexs[i | |
+ indexs.length | |
- pathStrs.length]; | |
if (index >= 0) { | |
// ==== add by wliu to | |
// support both filter and | |
// functions== | |
if (tmp.indexOf("[") > 0 | |
&& tmp.indexOf("]") > tmp | |
.indexOf("[")) {// include | |
// filter | |
String tmpStr = replaceElementWithNS( | |
tmp, "pre" | |
+ index | |
+ ":"); | |
newPath.append(tmpStr); | |
} else { | |
if (tmp.indexOf("@") != -1 | |
|| tmp.indexOf("(") < tmp | |
.indexOf(")")) { // include | |
// attribute | |
newPath.append(tmp); | |
} else { | |
// ==add end======= | |
newPath.append( | |
"pre") | |
.append( | |
index) | |
.append(":") | |
.append(tmp); | |
} | |
} | |
} else { | |
newPath.append(tmp); | |
} | |
} else { | |
newPath.append(tmp); | |
} | |
} | |
return newPath.toString(); | |
} | |
return path; | |
} | |
private String matches = "@*\\b[a-z|A-Z|_]+[[-]*\\w]*\\b[^'|^\\(]"; | |
private java.util.regex.Pattern pattern = java.util.regex.Pattern | |
.compile(matches); | |
private String replaceElementWithNS( | |
String global, String pre) { | |
java.util.regex.Matcher match = pattern | |
.matcher(global); | |
StringBuffer sb = new StringBuffer(); | |
match.reset(); | |
while (match.find()) { | |
String group = match.group(); | |
String tmp = ""; | |
if (group.toLowerCase().matches( | |
"\\b(div|mod|and|or)\\b.*") | |
|| group.matches("@.*")) { | |
tmp = group; | |
} else { | |
tmp = tmp + pre + group; | |
} | |
match.appendReplacement(sb, tmp); | |
} | |
match.appendTail(sb); | |
return sb.toString(); | |
} | |
} | |
class XML_API_tXMLMap_1_TXMLMAP_OUT { | |
public boolean isDefNull(org.dom4j.Node node) | |
throws javax.xml.transform.TransformerException { | |
if (node != null | |
&& node instanceof org.dom4j.Element) { | |
org.dom4j.Attribute attri = ((org.dom4j.Element) node) | |
.attribute("nil"); | |
if (attri != null | |
&& ("true").equals(attri | |
.getText())) { | |
return true; | |
} | |
} | |
return false; | |
} | |
public boolean isMissing(org.dom4j.Node node) | |
throws javax.xml.transform.TransformerException { | |
return node == null ? true : false; | |
} | |
public boolean isEmpty(org.dom4j.Node node) | |
throws javax.xml.transform.TransformerException { | |
if (node != null) { | |
return node.getText().length() == 0; | |
} | |
return false; | |
} | |
} | |
class Var__tXMLMap_1_TXMLMAP_OUT__Struct { | |
} | |
Var__tXMLMap_1_TXMLMAP_OUT__Struct Var__tXMLMap_1_TXMLMAP_OUT = new Var__tXMLMap_1_TXMLMAP_OUT__Struct(); | |
// ############################### | |
// # Outputs initialization | |
responseStruct response_tmp = new responseStruct(); | |
responseStruct response_save = null; | |
// the aggregate variable | |
responseStruct response_aggregate = null; | |
// init the resultset for aggregate | |
java.util.List<Object> allOutsForAggregate_tXMLMap_1 = new java.util.ArrayList<Object>(); | |
// ############################### | |
class TreeNode_API_tXMLMap_1_TXMLMAP_OUT { | |
java.util.Map<String, String> xpath_value_map = new java.util.HashMap<String, String>(); | |
void clear() { | |
xpath_value_map.clear(); | |
} | |
void put(String xpath, String value) { | |
xpath_value_map.put(xpath, value); | |
} | |
String get_null(String xpath) { | |
return null; | |
} | |
String get_String(String xpath) { | |
return xpath_value_map.get(xpath); | |
} | |
} | |
TreeNode_API_tXMLMap_1_TXMLMAP_OUT treeNodeAPI_tXMLMap_1_TXMLMAP_OUT = new TreeNode_API_tXMLMap_1_TXMLMAP_OUT(); | |
NameSpaceTool_tXMLMap_1_TXMLMAP_OUT nsTool_tXMLMap_1_TXMLMAP_OUT = new NameSpaceTool_tXMLMap_1_TXMLMAP_OUT(); | |
int nb_line_tXMLMap_1_TXMLMAP_OUT = 0; | |
XML_API_tXMLMap_1_TXMLMAP_OUT xml_api_tXMLMap_1_TXMLMAP_OUT = new XML_API_tXMLMap_1_TXMLMAP_OUT(); | |
class NestXMLTool_tXMLMap_1_TXMLMAP_OUT { | |
public void parseAndAdd( | |
org.dom4j.Element nestRoot, String value) { | |
try { | |
org.dom4j.Document doc4Str = org.dom4j.DocumentHelper | |
.parseText("<root>" + value | |
+ "</root>"); | |
nestRoot.setContent(doc4Str | |
.getRootElement().content()); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
nestRoot.setText(value); | |
} | |
} | |
public void setText(org.dom4j.Element element, | |
String value) { | |
if (value.startsWith("<![CDATA[") | |
&& value.endsWith("]]>")) { | |
String text = value.substring(9, value | |
.length() - 3); | |
element.addCDATA(text); | |
} else { | |
element.setText(value); | |
} | |
} | |
public void replaceDefaultNameSpace( | |
org.dom4j.Element nestRoot) { | |
if (nestRoot != null) { | |
for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot | |
.elements()) { | |
if (("").equals(tmp.getQName() | |
.getNamespace().getURI()) | |
&& ("").equals(tmp | |
.getQName() | |
.getNamespace() | |
.getPrefix())) { | |
tmp.setQName(org.dom4j.DocumentHelper | |
.createQName( | |
tmp.getName(), | |
nestRoot.getQName() | |
.getNamespace())); | |
} | |
replaceDefaultNameSpace(tmp); | |
} | |
} | |
} | |
public void removeEmptyElement( | |
org.dom4j.Element root) { | |
if (root != null) { | |
for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) root | |
.elements()) { | |
removeEmptyElement(tmp); | |
} | |
if (root.content().size() == 0 | |
&& root.attributes().size() == 0 | |
&& root.declaredNamespaces() | |
.size() == 0) { | |
if (root.getParent() != null) { | |
root.getParent().remove(root); | |
} | |
} | |
} | |
} | |
} | |
// NestXMLTool_tXMLMap_1_TXMLMAP_OUT | |
// nestXMLTool_tXMLMap_1_TXMLMAP_OUT = new | |
// NestXMLTool_tXMLMap_1_TXMLMAP_OUT(); | |
// the map store the previous value of aggregate | |
// columns | |
java.util.Map<String, Object> aggregateCacheMap_tXMLMap_1_TXMLMAP_OUT = new java.util.HashMap<String, Object>(); | |
class GenerateDocument_response { | |
TreeNode_API_tXMLMap_1_TXMLMAP_OUT treeNodeAPI = null; | |
java.util.Map<String, Object> valueMap = null; | |
DocumentGenerateOrderHelper orderHelper = new DocumentGenerateOrderHelper( | |
1); | |
org.dom4j.Document doc = null; | |
NestXMLTool_tXMLMap_1_TXMLMAP_OUT nestXMLTool = null; | |
org.dom4j.Element root4Group = null; | |
org.dom4j.io.OutputFormat format = null; | |
java.util.List<java.util.List<String>> groupbyList = null; | |
java.util.List<org.dom4j.Element> groupElementList = null; | |
int order = 0; | |
boolean isFirst = true; | |
boolean needRoot = true; | |
public GenerateDocument_response() { | |
// this.treeNodeAPI = treeNodeAPI; | |
valueMap = new java.util.HashMap<String, Object>(); | |
nestXMLTool = new NestXMLTool_tXMLMap_1_TXMLMAP_OUT(); | |
groupbyList = new java.util.ArrayList<java.util.List<String>>(); | |
groupElementList = new java.util.ArrayList<org.dom4j.Element>(); | |
doc = org.dom4j.DocumentHelper | |
.createDocument(); | |
format = org.dom4j.io.OutputFormat | |
.createPrettyPrint(); | |
format.setTrimText(false); | |
} | |
public org.dom4j.Document getDocument() { | |
return this.doc; | |
} | |
// We generate the TreeNode_API object only if | |
// there is a document in the main input table. | |
void generateElements( | |
TreeNode_API_tXMLMap_1_TXMLMAP_OUT treeNodeAPI, | |
boolean isInnerJoin, row1Struct row2, | |
Var__tXMLMap_1_TXMLMAP_OUT__Struct Var) { | |
/* | |
* if(this.treeNodeAPI==null) { | |
* this.treeNodeAPI = treeNodeAPI; } | |
*/ | |
org.dom4j.Element subTreeRootParent = null; | |
// build root xml tree | |
if (needRoot) { | |
needRoot = false; | |
org.dom4j.Element root = doc | |
.addElement("tns:getAirportInformationByISOCountryCodeResponse"); | |
subTreeRootParent = root; | |
root.addNamespace( | |
"tns", | |
TalendString | |
.replaceSpecialCharForXML("http://airportsoap.sopera.de")); | |
root.setQName(org.dom4j.DocumentHelper | |
.createQName( | |
"getAirportInformationByISOCountryCodeResponse", | |
org.dom4j.DocumentHelper | |
.createNamespace( | |
"tns", | |
TalendString | |
.replaceSpecialCharForXML("http://airportsoap.sopera.de")))); | |
root4Group = subTreeRootParent; | |
} else { | |
subTreeRootParent = root4Group; | |
} | |
/* build group xml tree */ | |
boolean isNewElement = false; | |
isNewElement = false; | |
org.dom4j.Element loop; | |
if (subTreeRootParent | |
.getNamespaceForPrefix("tns") == null) { | |
loop = subTreeRootParent | |
.addElement("getAirportInformationByISOCountryCodeResult"); | |
} else { | |
loop = subTreeRootParent | |
.addElement("tns:getAirportInformationByISOCountryCodeResult"); | |
} | |
subTreeRootParent = loop; | |
valueMap.put( | |
"loop", | |
treeNodeAPI | |
.get_String("row2.payload:/tns:getAirportInformationByISOCountryCode/tns:CountryAbbrviation")); | |
if (valueMap.get("loop") != null) { | |
nestXMLTool | |
.setText( | |
loop, | |
String.valueOf(treeNodeAPI | |
.get_String("row2.payload:/tns:getAirportInformationByISOCountryCode/tns:CountryAbbrviation"))); | |
} | |
} | |
} | |
GenerateDocument_response gen_Doc_response_tXMLMap_1_TXMLMAP_OUT = new GenerateDocument_response(); | |
boolean docAlreadyInstanciate_response = false; | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT begin ] stop | |
*/ | |
/** | |
* [tLogRow_1 begin ] start | |
*/ | |
ok_Hash.put("tLogRow_1", false); | |
start_Hash.put("tLogRow_1", System | |
.currentTimeMillis()); | |
currentComponent = "tLogRow_1"; | |
if (execStat) { | |
runStat.updateStatOnConnection("row1" | |
+ iterateId, 0, 0); | |
} | |
int tos_count_tLogRow_1 = 0; | |
// ///////////////////// | |
final String OUTPUT_FIELD_SEPARATOR_tLogRow_1 = "|"; | |
java.io.PrintStream consoleOut_tLogRow_1 = null; | |
StringBuilder strBuffer_tLogRow_1 = null; | |
int nb_line_tLogRow_1 = 0; | |
// ///////////////////// | |
/** | |
* [tLogRow_1 begin ] stop | |
*/ | |
/** | |
* [tESBProviderRequest_1_In begin ] start | |
*/ | |
ok_Hash.put("tESBProviderRequest_1_In", false); | |
start_Hash.put("tESBProviderRequest_1_In", System | |
.currentTimeMillis()); | |
currentComponent = "tESBProviderRequest_1_In"; | |
int tos_count_tESBProviderRequest_1_In = 0; | |
/** | |
* [tESBProviderRequest_1_In begin ] stop | |
*/ | |
/** | |
* [tESBProviderRequest_1_In main ] start | |
*/ | |
currentComponent = "tESBProviderRequest_1_In"; | |
Document talendDocument_tESBProviderRequest_1 = new Document(); | |
talendDocument_tESBProviderRequest_1 | |
.setDocument(requestMessage_tESBProviderRequest_1); | |
row1.payload = talendDocument_tESBProviderRequest_1; | |
tos_count_tESBProviderRequest_1_In++; | |
/** | |
* [tESBProviderRequest_1_In main ] stop | |
*/ | |
/** | |
* [tLogRow_1 main ] start | |
*/ | |
currentComponent = "tLogRow_1"; | |
// row1 | |
// row1 | |
if (execStat) { | |
runStat.updateStatOnConnection("row1" | |
+ iterateId, 1, 1); | |
} | |
// ///////////////////// | |
strBuffer_tLogRow_1 = new StringBuilder(); | |
if (row1.payload != null) { // | |
strBuffer_tLogRow_1.append(String | |
.valueOf(row1.payload)); | |
} // | |
if (globalMap.get("tLogRow_CONSOLE") != null) { | |
consoleOut_tLogRow_1 = (java.io.PrintStream) globalMap | |
.get("tLogRow_CONSOLE"); | |
} else { | |
consoleOut_tLogRow_1 = new java.io.PrintStream( | |
new java.io.BufferedOutputStream( | |
System.out)); | |
globalMap.put("tLogRow_CONSOLE", | |
consoleOut_tLogRow_1); | |
} | |
consoleOut_tLogRow_1.println(strBuffer_tLogRow_1 | |
.toString()); | |
consoleOut_tLogRow_1.flush(); | |
nb_line_tLogRow_1++; | |
// //// | |
// //// | |
// ///////////////////// | |
row2 = row1; | |
tos_count_tLogRow_1++; | |
/** | |
* [tLogRow_1 main ] stop | |
*/ | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT main ] start | |
*/ | |
currentComponent = "tXMLMap_1_TXMLMAP_OUT"; | |
// row2 | |
// row2 | |
if (execStat) { | |
runStat.updateStatOnConnection("row2" | |
+ iterateId, 1, 1); | |
} | |
boolean rejectedInnerJoin_tXMLMap_1_TXMLMAP_OUT = false; | |
boolean rejectedDocInnerJoin_tXMLMap_1_TXMLMAP_OUT = false; | |
boolean mainRowRejected_tXMLMap_1_TXMLMAP_OUT = false; | |
boolean isMatchDocRowtXMLMap_1_TXMLMAP_OUT = false; | |
gen_Doc_response_tXMLMap_1_TXMLMAP_OUT = new GenerateDocument_response(); | |
response_tmp = new responseStruct(); | |
response_tmp.payload = null; | |
String xPathLoop_tXMLMap_1_TXMLMAP_OUT = "/tns:getAirportInformationByISOCountryCode/tns:CountryAbbrviation"; | |
org.dom4j.Document doc_tXMLMap_1_TXMLMAP_OUT = row2.payload | |
.getDocument(); | |
java.util.HashMap<String, String> xmlNameSpaceMap_tXMLMap_1_TXMLMAP_OUT = new java.util.HashMap<String, String>(); | |
xmlNameSpaceMap_tXMLMap_1_TXMLMAP_OUT.put("tns", | |
"http://airportsoap.sopera.de"); | |
org.dom4j.XPath x_tXMLMap_1_TXMLMAP_OUT = doc_tXMLMap_1_TXMLMAP_OUT | |
.createXPath(xPathLoop_tXMLMap_1_TXMLMAP_OUT); | |
x_tXMLMap_1_TXMLMAP_OUT | |
.setNamespaceURIs(xmlNameSpaceMap_tXMLMap_1_TXMLMAP_OUT); | |
java.util.List<org.dom4j.tree.AbstractNode> nodeList_tXMLMap_1_TXMLMAP_OUT = (java.util.List<org.dom4j.tree.AbstractNode>) x_tXMLMap_1_TXMLMAP_OUT | |
.selectNodes(doc_tXMLMap_1_TXMLMAP_OUT); | |
String str_tXMLMap_1_TXMLMAP_OUT = null; | |
org.dom4j.Node node_tXMLMap_1_TXMLMAP_OUT = null; | |
for (org.dom4j.tree.AbstractNode temp_tXMLMap_1_TXMLMAP_OUT : nodeList_tXMLMap_1_TXMLMAP_OUT) { // G_TXM_M_001 | |
nb_line_tXMLMap_1_TXMLMAP_OUT++; | |
rejectedInnerJoin_tXMLMap_1_TXMLMAP_OUT = false; | |
rejectedDocInnerJoin_tXMLMap_1_TXMLMAP_OUT = false; | |
mainRowRejected_tXMLMap_1_TXMLMAP_OUT = false; | |
isMatchDocRowtXMLMap_1_TXMLMAP_OUT = false; | |
treeNodeAPI_tXMLMap_1_TXMLMAP_OUT.clear(); | |
org.dom4j.XPath xTmp0_tXMLMap_1_TXMLMAP_OUT = temp_tXMLMap_1_TXMLMAP_OUT | |
.createXPath("."); | |
xTmp0_tXMLMap_1_TXMLMAP_OUT | |
.setNamespaceURIs(xmlNameSpaceMap_tXMLMap_1_TXMLMAP_OUT); | |
Object obj0_tXMLMap_1_TXMLMAP_OUT = xTmp0_tXMLMap_1_TXMLMAP_OUT | |
.evaluate(temp_tXMLMap_1_TXMLMAP_OUT); | |
if (obj0_tXMLMap_1_TXMLMAP_OUT instanceof String | |
|| obj0_tXMLMap_1_TXMLMAP_OUT instanceof Number) { | |
str_tXMLMap_1_TXMLMAP_OUT = String | |
.valueOf(obj0_tXMLMap_1_TXMLMAP_OUT); | |
} else { | |
node_tXMLMap_1_TXMLMAP_OUT = xTmp0_tXMLMap_1_TXMLMAP_OUT | |
.selectSingleNode(temp_tXMLMap_1_TXMLMAP_OUT); | |
str_tXMLMap_1_TXMLMAP_OUT = xTmp0_tXMLMap_1_TXMLMAP_OUT | |
.valueOf(temp_tXMLMap_1_TXMLMAP_OUT); | |
} | |
treeNodeAPI_tXMLMap_1_TXMLMAP_OUT | |
.put( | |
"row2.payload:/tns:getAirportInformationByISOCountryCode/tns:CountryAbbrviation", | |
str_tXMLMap_1_TXMLMAP_OUT); | |
{ // start of Var scope | |
// ############################### | |
// # Vars tables | |
Var__tXMLMap_1_TXMLMAP_OUT__Struct Var = Var__tXMLMap_1_TXMLMAP_OUT; | |
// ############################### | |
// # Output tables | |
response = null; | |
// # Output table : 'response' | |
gen_Doc_response_tXMLMap_1_TXMLMAP_OUT = new GenerateDocument_response(); | |
response_tmp = new responseStruct(); | |
gen_Doc_response_tXMLMap_1_TXMLMAP_OUT | |
.generateElements( | |
treeNodeAPI_tXMLMap_1_TXMLMAP_OUT, | |
rejectedDocInnerJoin_tXMLMap_1_TXMLMAP_OUT, | |
row2, Var); | |
if (response_tmp.payload == null) { | |
response_tmp.payload = new Document(); | |
response_tmp.payload | |
.setDocument(gen_Doc_response_tXMLMap_1_TXMLMAP_OUT | |
.getDocument()); | |
// construct the resultset when there is | |
// no aggregate column for the out table | |
allOutsForAggregate_tXMLMap_1 | |
.add(response_tmp); | |
} | |
// ############################### | |
} // end of Var scope | |
rejectedInnerJoin_tXMLMap_1_TXMLMAP_OUT = false; | |
tos_count_tXMLMap_1_TXMLMAP_OUT++; | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT main ] stop | |
*/ | |
} // G_TXM_M_001 close | |
/** | |
* [tESBProviderRequest_1_In end ] start | |
*/ | |
currentComponent = "tESBProviderRequest_1_In"; | |
ok_Hash.put("tESBProviderRequest_1_In", true); | |
end_Hash.put("tESBProviderRequest_1_In", System | |
.currentTimeMillis()); | |
/** | |
* [tESBProviderRequest_1_In end ] stop | |
*/ | |
/** | |
* [tLogRow_1 end ] start | |
*/ | |
currentComponent = "tLogRow_1"; | |
// //// | |
// //// | |
globalMap.put("tLogRow_1_NB_LINE", | |
nb_line_tLogRow_1); | |
// ///////////////////// | |
if (execStat) { | |
runStat.updateStatOnConnection("row1" | |
+ iterateId, 2, 0); | |
} | |
ok_Hash.put("tLogRow_1", true); | |
end_Hash.put("tLogRow_1", System | |
.currentTimeMillis()); | |
/** | |
* [tLogRow_1 end ] stop | |
*/ | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT end ] start | |
*/ | |
currentComponent = "tXMLMap_1_TXMLMAP_OUT"; | |
if (execStat) { | |
runStat.updateStatOnConnection("row2" | |
+ iterateId, 2, 0); | |
} | |
ok_Hash.put("tXMLMap_1_TXMLMAP_OUT", true); | |
end_Hash.put("tXMLMap_1_TXMLMAP_OUT", System | |
.currentTimeMillis()); | |
/** | |
* [tXMLMap_1_TXMLMAP_OUT end ] stop | |
*/ | |
/** | |
* [tESBProviderResponse_1 begin ] start | |
*/ | |
ok_Hash.put("tESBProviderResponse_1", false); | |
start_Hash.put("tESBProviderResponse_1", System | |
.currentTimeMillis()); | |
currentComponent = "tESBProviderResponse_1"; | |
if (execStat) { | |
runStat.updateStatOnConnection("response" | |
+ iterateId, 0, 0); | |
} | |
int tos_count_tESBProviderResponse_1 = 0; | |
/** | |
* [tESBProviderResponse_1 begin ] stop | |
*/ | |
/** | |
* [tXMLMap_1_TXMLMAP_IN begin ] start | |
*/ | |
ok_Hash.put("tXMLMap_1_TXMLMAP_IN", false); | |
start_Hash.put("tXMLMap_1_TXMLMAP_IN", System | |
.currentTimeMillis()); | |
currentComponent = "tXMLMap_1_TXMLMAP_IN"; | |
int tos_count_tXMLMap_1_TXMLMAP_IN = 0; | |
for (Object row_out_tXMLMap_1_TXMLMAP_IN : allOutsForAggregate_tXMLMap_1) {// TD512 | |
/** | |
* [tXMLMap_1_TXMLMAP_IN begin ] stop | |
*/ | |
/** | |
* [tXMLMap_1_TXMLMAP_IN main ] start | |
*/ | |
currentComponent = "tXMLMap_1_TXMLMAP_IN"; | |
response = null; | |
if (row_out_tXMLMap_1_TXMLMAP_IN != null | |
&& row_out_tXMLMap_1_TXMLMAP_IN instanceof responseStruct) { | |
response = (responseStruct) row_out_tXMLMap_1_TXMLMAP_IN; | |
} | |
tos_count_tXMLMap_1_TXMLMAP_IN++; | |
/** | |
* [tXMLMap_1_TXMLMAP_IN main ] stop | |
*/ | |
// Start of branch "response" | |
if (response != null) { | |
/** | |
* [tESBProviderResponse_1 main ] start | |
*/ | |
currentComponent = "tESBProviderResponse_1"; | |
// response | |
// response | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"response" + iterateId, 1, 1); | |
} | |
Document esbProviderResponseDoc_tESBProviderResponse_1 = response.payload; | |
ESBProviderCallbackTalendJobInner esbProviderCallback_tESBProviderResponse_1 = (ESBProviderCallbackTalendJobInner) globalMap | |
.get("esbHandler"); | |
if (null != esbProviderCallback_tESBProviderResponse_1) { | |
java.util.Map<String, String> customProps_tESBProviderResponse_1 = null; | |
esbProviderCallback_tESBProviderResponse_1 | |
.setCustomProperties(customProps_tESBProviderResponse_1); | |
esbProviderCallback_tESBProviderResponse_1 | |
.sendResponse(esbProviderResponseDoc_tESBProviderResponse_1 | |
.getDocument()); | |
} | |
tos_count_tESBProviderResponse_1++; | |
/** | |
* [tESBProviderResponse_1 main ] stop | |
*/ | |
} // End of branch "response" | |
/** | |
* [tXMLMap_1_TXMLMAP_IN end ] start | |
*/ | |
currentComponent = "tXMLMap_1_TXMLMAP_IN"; | |
}// TD512 | |
ok_Hash.put("tXMLMap_1_TXMLMAP_IN", true); | |
end_Hash.put("tXMLMap_1_TXMLMAP_IN", System | |
.currentTimeMillis()); | |
/** | |
* [tXMLMap_1_TXMLMAP_IN end ] stop | |
*/ | |
/** | |
* [tESBProviderResponse_1 end ] start | |
*/ | |
currentComponent = "tESBProviderResponse_1"; | |
if (execStat) { | |
runStat.updateStatOnConnection("response" | |
+ iterateId, 2, 0); | |
} | |
ok_Hash.put("tESBProviderResponse_1", true); | |
end_Hash.put("tESBProviderResponse_1", System | |
.currentTimeMillis()); | |
/** | |
* [tESBProviderResponse_1 end ] stop | |
*/ | |
if (execStat) { | |
runStat.updateStatOnConnection( | |
"Iterate", | |
2, | |
"exec" | |
+ NB_ITERATE_tESBProviderRequest_1_In); | |
} | |
/** | |
* [tESBProviderRequest_1_Loop end ] start | |
*/ | |
currentComponent = "tESBProviderRequest_1_Loop"; | |
} catch (ESBJobInterruptedException e) { | |
// job interrupted from outside | |
break; | |
} catch (Throwable e) { | |
((ESBProviderCallbackTalendJobInner) globalMap | |
.get("esbHandler")).sendFault(e); | |
} finally { | |
// Exit from this loop is made by the configuring | |
// "Keep listening" | |
// parameter to false. Then we will have a break | |
// before. | |
if ("false".equals("true")) { | |
break; | |
} | |
} | |
nb_line_tESBProviderRequest_1++; | |
globalMap.put("tESBProviderRequest_1_NB_LINE", | |
nb_line_tESBProviderRequest_1); | |
} // This is the end of the ESB Service Provider loop | |
} finally { | |
// for "keep listening" == false web service need a time to | |
// serve response | |
Thread.currentThread(); | |
Thread.sleep(500); | |
// unsubscribe | |
if (null != handlerThread_tESBProviderRequest_1) { | |
// stop endpoint in case it was opened by job | |
handlerThread_tESBProviderRequest_1.stopEndpoint(); | |
} | |
} | |
ok_Hash.put("tESBProviderRequest_1_Loop", true); | |
end_Hash.put("tESBProviderRequest_1_Loop", System | |
.currentTimeMillis()); | |
/** | |
* [tESBProviderRequest_1_Loop end ] stop | |
*/ | |
}// end the resume | |
} catch (Exception e) { | |
throw new TalendException(e, currentComponent, globalMap); | |
} catch (Error error) { | |
runStat.stopThreadStat(); | |
throw new Error(error); | |
} | |
globalMap.put("tESBProviderRequest_1_Loop_SUBPROCESS_STATE", 1); | |
} | |
public String resuming_logs_dir_path = null; | |
public String resuming_checkpoint_path = null; | |
public String parent_part_launcher = null; | |
private String resumeEntryMethodName = null; | |
private boolean globalResumeTicket = false; | |
public boolean watch = false; | |
// portStats is null, it means don't execute the statistics | |
public Integer portStats = null; | |
public int portTraces = 4334; | |
public String clientHost; | |
public String defaultClientHost = "localhost"; | |
public String contextStr = "Default"; | |
public boolean isDefaultContext = true; | |
public String pid = "0"; | |
public String rootPid = null; | |
public String fatherPid = null; | |
public String fatherNode = null; | |
public long startTime = 0; | |
public boolean isChildJob = false; | |
private boolean execStat = true; | |
private ThreadLocal threadLocal = new ThreadLocal(); | |
{ | |
java.util.Map threadRunResultMap = new java.util.HashMap(); | |
threadRunResultMap.put("errorCode", null); | |
threadRunResultMap.put("status", ""); | |
threadLocal.set(threadRunResultMap); | |
} | |
private java.util.Properties context_param = new java.util.Properties(); | |
public java.util.Map<String, Object> parentContextMap = new java.util.HashMap<String, Object>(); | |
public String status = ""; | |
public static void main(String[] args) { | |
final airportSoap_getAirportInformationByISOCountryCode airportSoap_getAirportInformationByISOCountryCodeClass = new airportSoap_getAirportInformationByISOCountryCode(); | |
int exitCode = airportSoap_getAirportInformationByISOCountryCodeClass | |
.runJobInTOS(args); | |
System.exit(exitCode); | |
} | |
public String[][] runJob(String[] args) { | |
int exitCode = runJobInTOS(args); | |
String[][] bufferValue = new String[][] { { Integer.toString(exitCode) } }; | |
return bufferValue; | |
} | |
public int runJobInTOS(String[] args) { | |
String lastStr = ""; | |
for (String arg : args) { | |
if (arg.equalsIgnoreCase("--context_param")) { | |
lastStr = arg; | |
} else if (lastStr.equals("")) { | |
evalParam(arg); | |
} else { | |
evalParam(lastStr + " " + arg); | |
lastStr = ""; | |
} | |
} | |
if (clientHost == null) { | |
clientHost = defaultClientHost; | |
} | |
if (pid == null || "0".equals(pid)) { | |
pid = TalendString.getAsciiRandomString(6); | |
} | |
if (rootPid == null) { | |
rootPid = pid; | |
} | |
if (fatherPid == null) { | |
fatherPid = pid; | |
} else { | |
isChildJob = true; | |
} | |
if (portStats != null) { | |
// portStats = -1; //for testing | |
if (portStats < 0 || portStats > 65535) { | |
// issue:10869, the portStats is invalid, so this client socket | |
// can't open | |
System.err.println("The statistics socket port " + portStats | |
+ " is invalid."); | |
execStat = false; | |
} | |
} else { | |
execStat = false; | |
} | |
try { | |
// call job/subjob with an existing context, like: | |
// --context=production. if without this parameter, there will use | |
// the default context instead. | |
java.io.InputStream inContext = airportSoap_getAirportInformationByISOCountryCode.class | |
.getClassLoader().getResourceAsStream( | |
"demo1/airportsoap_getairportinformationbyisocountrycode_0_1/contexts/" | |
+ contextStr + ".properties"); | |
if (isDefaultContext && inContext == null) { | |
} else { | |
if (inContext != null) { | |
// defaultProps is in order to keep the original context | |
// value | |
defaultProps.load(inContext); | |
inContext.close(); | |
context = new ContextProperties(defaultProps); | |
} else { | |
// print info and job continue to run, for case: | |
// context_param is not empty. | |
System.err.println("Could not find the context " | |
+ contextStr); | |
} | |
if (!context_param.isEmpty()) { | |
context.putAll(context_param); | |
} | |
} | |
} catch (java.io.IOException ie) { | |
System.err.println("Could not load context " + contextStr); | |
ie.printStackTrace(); | |
} | |
// get context value from parent directly | |
if (parentContextMap != null && !parentContextMap.isEmpty()) { | |
} | |
// Resume: init the resumeUtil | |
resumeEntryMethodName = ResumeUtil | |
.getResumeEntryMethodName(resuming_checkpoint_path); | |
resumeUtil = new ResumeUtil(resuming_logs_dir_path, isChildJob, rootPid); | |
resumeUtil.initCommonInfo(pid, rootPid, fatherPid, projectName, | |
jobName, contextStr, jobVersion); | |
// Resume: jobStart | |
resumeUtil.addLog("JOB_STARTED", "JOB:" + jobName, | |
parent_part_launcher, Thread.currentThread().getId() + "", "", | |
"", "", "", resumeUtil.convertToJsonText(context)); | |
if (execStat) { | |
try { | |
runStat.openSocket(!isChildJob); | |
runStat.setAllPID(rootPid, fatherPid, pid, jobName); | |
runStat.startThreadStat(clientHost, portStats); | |
runStat.updateStatOnJob(RunStat.JOBSTART, fatherNode); | |
} catch (java.io.IOException ioException) { | |
ioException.printStackTrace(); | |
} | |
} | |
long startUsedMemory = Runtime.getRuntime().totalMemory() | |
- Runtime.getRuntime().freeMemory(); | |
long endUsedMemory = 0; | |
long end = 0; | |
startTime = System.currentTimeMillis(); | |
this.globalResumeTicket = true;// to run tPreJob | |
this.globalResumeTicket = false;// to run others jobs | |
try { | |
errorCode = null; | |
tESBProviderRequest_1_LoopProcess(globalMap); | |
if (!"failure".equals(status)) { | |
status = "end"; | |
} | |
} catch (TalendException e_tESBProviderRequest_1_Loop) { | |
status = "failure"; | |
e_tESBProviderRequest_1_Loop.printStackTrace(); | |
globalMap.put("tESBProviderRequest_1_Loop_SUBPROCESS_STATE", -1); | |
} finally { | |
} | |
this.globalResumeTicket = true;// to run tPostJob | |
end = System.currentTimeMillis(); | |
if (watch) { | |
System.out.println((end - startTime) + " milliseconds"); | |
} | |
endUsedMemory = Runtime.getRuntime().totalMemory() | |
- Runtime.getRuntime().freeMemory(); | |
if (false) { | |
System.out | |
.println((endUsedMemory - startUsedMemory) | |
+ " bytes memory increase when running : airportSoap_getAirportInformationByISOCountryCode"); | |
} | |
if (execStat) { | |
runStat.updateStatOnJob(RunStat.JOBEND, fatherNode); | |
runStat.stopThreadStat(); | |
} | |
int returnCode = 0; | |
if (errorCode == null) { | |
returnCode = status != null && status.equals("failure") ? 1 : 0; | |
} else { | |
returnCode = errorCode.intValue(); | |
} | |
resumeUtil.addLog("JOB_ENDED", "JOB:" + jobName, parent_part_launcher, | |
Thread.currentThread().getId() + "", "", "" + returnCode, "", | |
"", ""); | |
return returnCode; | |
} | |
private void evalParam(String arg) { | |
if (arg.startsWith("--resuming_logs_dir_path")) { | |
resuming_logs_dir_path = arg.substring(25); | |
} else if (arg.startsWith("--resuming_checkpoint_path")) { | |
resuming_checkpoint_path = arg.substring(27); | |
} else if (arg.startsWith("--parent_part_launcher")) { | |
parent_part_launcher = arg.substring(23); | |
} else if (arg.startsWith("--watch")) { | |
watch = true; | |
} else if (arg.startsWith("--stat_port=")) { | |
String portStatsStr = arg.substring(12); | |
if (portStatsStr != null && !portStatsStr.equals("null")) { | |
portStats = Integer.parseInt(portStatsStr); | |
} | |
} else if (arg.startsWith("--trace_port=")) { | |
portTraces = Integer.parseInt(arg.substring(13)); | |
} else if (arg.startsWith("--client_host=")) { | |
clientHost = arg.substring(14); | |
} else if (arg.startsWith("--context=")) { | |
contextStr = arg.substring(10); | |
isDefaultContext = false; | |
} else if (arg.startsWith("--father_pid=")) { | |
fatherPid = arg.substring(13); | |
} else if (arg.startsWith("--root_pid=")) { | |
rootPid = arg.substring(11); | |
} else if (arg.startsWith("--father_node=")) { | |
fatherNode = arg.substring(14); | |
} else if (arg.startsWith("--pid=")) { | |
pid = arg.substring(6); | |
} else if (arg.startsWith("--context_param")) { | |
String keyValue = arg.substring(16); | |
int index = -1; | |
if (keyValue != null && (index = keyValue.indexOf('=')) > -1) { | |
context_param.put(keyValue.substring(0, index), | |
replaceEscapeChars(keyValue.substring(index + 1))); | |
} | |
} | |
} | |
private final String[][] escapeChars = { { "\\n", "\n" }, { "\\'", "\'" }, | |
{ "\\r", "\r" }, { "\\f", "\f" }, { "\\b", "\b" }, { "\\t", "\t" }, | |
{ "\\\\", "\\" } }; | |
private String replaceEscapeChars(String keyValue) { | |
if (keyValue == null || ("").equals(keyValue.trim())) { | |
return keyValue; | |
} | |
for (String[] strArray : escapeChars) { | |
keyValue = keyValue.replace(strArray[0], strArray[1]); | |
} | |
return keyValue; | |
} | |
public Integer getErrorCode() { | |
return errorCode; | |
} | |
public String getStatus() { | |
return status; | |
} | |
ResumeUtil resumeUtil = null; | |
} | |
/************************************************************************************************ | |
* 65547 characters generated by Talend Open Studio for ESB on the October 19, | |
* 2011 3:23:05 PM CEST | |
************************************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment