?? simpleupes.java
字號:
/*BEGIN CMVC */
//*************************************************************************
//
// Workfile: mqwfupes/src/com/acme/sample/SimpleUpes.java, v3-upes, fmv3
// Last update: 03/11/18 10:34:42
// SCCS path, id: /home/flowmark/vc/0/5/5/7/s.98 1.1
//
//************************************************************************/
/*END CMVC */
/*BEGIN COPYRIGHT */
//*************************************************************************
//
// Licensed Materials - Property of IBM
// WA05 Support Pac - @sname@
// (c) Copyright IBM Corp. 2003
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract
// with IBM Corp.
//
//************************************************************************/
/*END COPYRIGHT */
/*BEGIN DISCLAIMER */
//*************************************************************************
// DISCLAIMER
// ----------
// This material contains programming source code for your consideration.
// These examples have not been thoroughly tested under all conditions.
// IBM, therefore, cannot guarantee or imply reliability, serviceability,
// or function of these programs.
// ALL PROGRAMS CONTAINED HEREIN ARE PROVIDED TO YOU "AS IS", WITHOUT ANY
// WARRANTIES (EXPRESS OR IMPLIED) OR SUPPORT WHATSOEVER, INCLUDING BUT
// NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE.
//************************************************************************/
/*END DISCLAIMER */
package com.acme.sample;
import com.ibm.workflow.upes.BasicContainer;
import com.ibm.workflow.util.msg.BasicResponder;
import com.ibm.workflow.util.msg.Message;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.w3c.dom.Element;
import org.apache.xml.serialize.XMLSerializer;
/**
* BasicUpes is the implementation of a simple standalone UPES. It can
* be launced via the main() method. The BasicTask class used by BasicUpes
* operates directly at the XML message level.
*/
public class SimpleUpes extends BasicResponder {
/**
* The BasicTask class used by BasicUpes. It will be instantiated as many
* times as the BasicResponder thread pool has threads.
* It deals with UPES messages directly. The onMessage() method skeleton
* needs to be completed to provide the intended semantics of the UPES.
*/
public class BasicTask extends Task {
/**
* A BasicTask does not convert messages to/from Java Beans but operates
* on the messages itself. The makeBean() method returns the
* <ActivityImplInvoke> element of the message instead of converting the
* <programInputData> it to a Java Bean. Also, since a BasicUpes does not
* provide an FdlGenerator, the 'endpointParameter' map (which otherwise
* would contain the PARAMETER and ENVIRONMENT settings from the generated
* PROGRAM) will always be empty.
*/
protected Object makeBean(Element programInputData, Map endpointParameter) throws InvocationTargetException {
System.out.println("makeBean: " + programInputData.toString());
return programInputData.getParentNode().getParentNode();
}
/**
* The onMessage skeleton.
*/
public Object onMessage(Object inputData, Map endpointParameter, Message.IntHolder rc) throws Exception {
Element invoke = (Element) inputData; // The <ActivityImplInvoke> element
String output = null; // The data for <ProgramOutputData>, already in WMQWF XML format
rc.value = 0; // The value for <ProgramRC>. To return a fatal <Exception>, throw an Exception instead
System.out.println("Sample1: the received message is:");
// print the xml message to standard out
XMLSerializer serializer = new XMLSerializer();
StringWriter writer = new StringWriter();
serializer.setOutputCharStream(writer);
serializer.asDOMSerializer();
serializer.serialize(invoke);
System.out.println(writer.toString() );
return output;
}
}
/**
* This method returns the TaskFactory singleton which will create the
* BasicTask instances.
*/
public TaskFactory getTaskFactory() {
return taskFactory;
}
/**
* One way to run this UPES.
* Here, a BasicContainer (which reads its
* configuration from the file given in args[0]). Once the UPES has been
* created. The name of the configuration file has to be passed to
* (newly created) the BasicContainer; the container is then passed to the
* init() method of the UPES. This call will never return but launch the
* UPES instead.
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.println("USAGE: startUpes <properties.file>");
System.exit(1);
}
new SimpleUpes().init(new BasicContainer(args[0]));
}
// The TaskFactory singleton
private final TaskFactory taskFactory = new TaskFactory() {
public final Task createTask() throws InvocationTargetException {
return new BasicTask();
}
};
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -