TCP Connection
Generated Objects
@Property(name = "MyTCPConnection") public TCPConnectionAdminObject myTCPConnection;
myTCPConnection is an instance of
com.tibco.bw.sharedresource.tcpconnection.runtime.TCPConnectionAdminObject that represents the selected resource. You can use it to obtain configuration attributes from the resource.
Business Logic Example
class MyTCPSendActivityExecutor implements Runnable {
/**
* <!-- begin-custom-doc -->
*
* <!-- end-custom-doc -->
* @generated
*/
@Override
public void run() {
if(getActivityLogger().isDebugEnabled()) {
activityLogger.debug(RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_METHOD_CALLED
,new Object[] { "Executor run()"
,activityContext.getActivityName()
,activityContext.getProcessName()
,activityContext.getDeploymentUnitName()
,activityContext.getDeploymentUnitVersion() });
String serializedNode = XMLUtils.serializeNode(inputData,processContext.getXMLProcessingContext());
activityLogger.debug(RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_INPUT, new Object[] {activityContext.getActivityName(), serializedNode});
}
try {
// begin-custom-code
// add your own business code here
Socket s = null;
try {
// get the destination host and port from the resource
String host = myTCPConnection.getHost();
Integer port = Integer.valueOf(myTCPConnection.getPort());
// create a connected socket
s = new Socket(host, port);
// send a some data
OutputStream os = s.getOutputStream();
os.write(new String("Hello World!").getBytes());
} catch (IOException e) {
throw new ActivityFault(activityContext, e);
} finally
{
if (s != null){
s.close();
}
}
// end-custom-code
N output = null;
SerializableXMLDocument<N> wrapper = new
SerializableXMLDocument<N>(processContext.getXMLProcessingContext(), output);
notifier.setReady(wrapper);
} catch (Exception e) {
e.printStackTrace();
notifier.setReady(e);
}
}
}
Copyright © Cloud Software Group, Inc. All rights reserved.
