Yes, the problem you have is that the Tundra/tundra.pipeline:emit and Tundra/tundra.pipeline:parse services make use of other Java methods in the Tundra package for its implementation, so you can’t just copy those two services into another package without all the other dependencies and have them compile.
I’ve created standalone versions of just those two services for you into the attached package Pipeline-v0.0.1.zip. You should be able to copy/paste/move/rename these services and have it compile because all the dependent code is in the Java shared source for the services.
I created this package on Integration Server 8.2.2 and compiled the services for Java 1.6. Let me know if you have any issues running or recompiling these services on Integration Server 9.x and Java 1.7.
And just for completeness, here is the pipeline.java source file from the attached Pipeline-v0.0.1.zip package for the two services pipeline:emit and pipeline:parse inline for your perusal:
// -----( IS Java Code Template v1.2
// -----( CREATED: 2014-08-28 07:37:31 EST
// -----( ON-HOST: 172.16.189.132
import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
// --- <<IS-START-IMPORTS>> ---
// --- <<IS-END-IMPORTS>> ---
public final class pipeline
{
// ---( internal utility methods )---
final static pipeline _instance = new pipeline();
static pipeline _newInstance() { return new pipeline(); }
static pipeline _cast(Object o) { return (pipeline)o; }
// ---( server methods )---
public static final void emit (IData pipeline)
throws ServiceException
{
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
String encoding = IDataUtil.getString(cursor, "$encoding");
String mode = IDataUtil.getString(cursor, "$mode");
IDataUtil.remove(cursor, "$encoding");
IDataUtil.remove(cursor, "$mode");
IDataUtil.put(cursor, "$content", tundra.document.emit(pipeline, encoding, mode));
} catch(java.io.IOException ex) {
tundra.exception.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
public static final void parse (IData pipeline)
throws ServiceException
{
// --- <<IS-START(parse)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $content
// [i] field:0:optional $encoding
IDataCursor cursor = pipeline.getCursor();
try {
Object content = IDataUtil.get(cursor, "$content");
String encoding = IDataUtil.getString(cursor, "$encoding");
IDataUtil.merge(tundra.document.parse(content, encoding), pipeline);
} catch(java.io.IOException ex) {
tundra.exception.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
// --- <<IS-START-SHARED>> ---
public static class tundra {
public static class document {
// parses an IData XML input stream to an IData object
public static IData parse(java.io.InputStream in) throws java.io.IOException {
com.wm.util.coder.XMLCoderWrapper codec = new com.wm.util.coder.XMLCoderWrapper();
return codec.decode(in);
}
// parses an IData XML string, byte array or input stream to an IData object
public static IData parse(Object content, String encoding) throws java.io.IOException {
return parse((java.io.InputStream)tundra.object.convert(content, encoding, "stream"));
}
// emits an IData object as a an IData XML string, byte array or stream
public static Object emit(IData document, String encoding, String mode) throws java.io.IOException {
com.wm.util.coder.IDataXMLCoder codec = null;
if (encoding == null) {
codec = new com.wm.util.coder.IDataXMLCoder();
} else {
codec = new com.wm.util.coder.IDataXMLCoder(encoding);
}
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
codec.encode(out, document);
return tundra.object.convert(out.toByteArray(), encoding, mode);
}
}
public static class object {
// converts a string, byte array or stream to a string, byte array or stream
public static Object convert(Object object, String encoding, String mode) throws java.io.IOException {
if (mode == null) mode = "stream";
if (mode.equals("bytes")) {
object = tundra.bytes.normalize(object, encoding);
} else if (mode.equals("string")) {
object = tundra.string.normalize(object, encoding);
} else {
object = tundra.stream.normalize(object, encoding);
}
return object;
}
}
public static class bytes {
// converts a string, bytes or input stream to bytes
public static byte[] normalize(Object object, String encoding) throws java.io.IOException {
if (encoding == null) encoding = tundra.support.constant.DEFAULT_CHARACTER_ENCODING;
byte[] bytes = null;
if (object != null) {
if (object instanceof byte[]) {
bytes = (byte[])object;
} else if (object instanceof String) {
bytes = ((String)object).getBytes(encoding);
} else if (object instanceof java.io.InputStream) {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
tundra.stream.copy((java.io.InputStream)object, out);
bytes = out.toByteArray();
} else {
throw new IllegalArgumentException("object must be a string, byte[] or java.io.InputStream: " + object.getClass().getName());
}
}
return bytes;
}
}
public static class exception {
// throws a new ServiceException with the class and message from the given Throwables, which
// is useful because java services are hard-wired to only throw ServiceExceptions
public static void raise(Throwable[] exceptions) throws ServiceException {
if (exceptions != null) raise(message(exceptions));
}
// throws a new ServiceException with the class and message from the given Throwables, which
// is useful because java services are hard-wired to only throw ServiceExceptions
public static void raise(java.util.Collection<Throwable> exceptions) throws ServiceException {
if (exceptions != null) raise(message((Throwable[])exceptions.toArray(new Throwable[0])));
}
// throws a new ServiceException with the class and message from the given Throwable, which
// is useful because java services are hard-wired to only throw ServiceExceptions
public static void raise(Throwable exception) throws ServiceException {
if (exception != null) {
if (exception instanceof ServiceException) {
throw (ServiceException)exception;
} else {
raise(message(exception));
}
}
}
// throws a new ServiceException with the given message
public static void raise(String message) throws ServiceException {
throw new ServiceException(message == null ? "" : message);
}
// returns an exception as a string
public static String message(Throwable exception) {
String message = "";
if (exception != null) {
if (exception instanceof ServiceException) {
message = exception.getMessage();
} else {
message = exception.getClass().getName() + ": " + exception.getMessage();
}
}
return message;
}
// returns a list of exceptions as a string
public static String message(java.util.Collection<Throwable> exceptions) {
return message((Throwable[])exceptions.toArray(new Throwable[0]));
}
// returns a list of exceptions as a string
public static String message(Throwable[] exceptions) {
StringBuilder msg = new StringBuilder();
if (exceptions != null) {
if (exceptions.length == 1 && exceptions[0] != null) {
msg.append(message(exceptions[0]));
} else {
for (int i = 0; i < exceptions.length; i++) {
if (exceptions[i] != null) {
msg.append("[").append(i).append("]: ").append(message(exceptions[i]));
if (i < exceptions.length - 1) msg.append("\n");
}
}
}
}
return msg.toString();
}
// returns the call stack associated with the given exception
public static IData[] stack(Throwable exception) {
IData[] output = null;
if (exception != null) {
StackTraceElement[] stack = exception.getStackTrace();
output = new IData[stack.length];
for (int i = 0; i < stack.length; i++) {
output[i] = IDataFactory.create();
IDataCursor cursor = output[i].getCursor();
IDataUtil.put(cursor, "description", stack[i].toString());
IDataUtil.put(cursor, "file", stack[i].getFileName());
IDataUtil.put(cursor, "class", stack[i].getClassName());
IDataUtil.put(cursor, "method", stack[i].getMethodName());
IDataUtil.put(cursor, "line", "" + stack[i].getLineNumber());
IDataUtil.put(cursor, "native?", "" + stack[i].isNativeMethod());
cursor.destroy();
}
}
return output;
}
}
public static class stream {
// converts the given object, which must be either an input stream, byte array, or string, to an input stream, using the
// given encoding if the object was a string
public static java.io.InputStream normalize(Object object, String encoding) throws java.io.UnsupportedEncodingException {
if (encoding == null) encoding = tundra.support.constant.DEFAULT_CHARACTER_ENCODING;
java.io.InputStream stream = null;
if (object != null) {
if (object instanceof java.io.BufferedInputStream) {
stream = (java.io.BufferedInputStream)object;
} else if (object instanceof java.io.InputStream) {
stream = new java.io.BufferedInputStream((java.io.InputStream)object, tundra.support.constant.DEFAULT_BUFFER_SIZE);
} else if (object instanceof byte[]) {
stream = new java.io.ByteArrayInputStream((byte[])object);
} else if (object instanceof String) {
stream = new java.io.ByteArrayInputStream(((String)object).getBytes(encoding));
} else {
throw new IllegalArgumentException("object must be a string, byte[] or java.io.InputStream: " + object.getClass().getName());
}
}
return stream;
}
// copies all data from the input stream to the output stream, then closes both streams
public static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException {
copy(in, out, true);
}
// copies all data from the input stream to the output stream, and optionally closes both streams
public static void copy(java.io.InputStream in, java.io.OutputStream out, boolean close) throws java.io.IOException {
try {
if (in == null || out == null) return;
byte[] buffer = new byte[tundra.support.constant.DEFAULT_BUFFER_SIZE];
int length = 0;
if (!(in instanceof java.io.BufferedInputStream)) in = new java.io.BufferedInputStream(in, tundra.support.constant.DEFAULT_BUFFER_SIZE);
if (!(out instanceof java.io.BufferedOutputStream)) out = new java.io.BufferedOutputStream(out, tundra.support.constant.DEFAULT_BUFFER_SIZE);
while((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
} finally {
if (close) close(in, out);
}
}
// copies all the data from the reader to the writer, then closes both
public static void copy(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException {
try {
if (reader == null || writer == null) return;
char[] buffer = new char[tundra.support.constant.DEFAULT_BUFFER_SIZE];
int length = 0;
if (!(reader instanceof java.io.BufferedReader)) reader = new java.io.BufferedReader(reader, tundra.support.constant.DEFAULT_BUFFER_SIZE);
if (!(writer instanceof java.io.BufferedWriter)) writer = new java.io.BufferedWriter(writer, tundra.support.constant.DEFAULT_BUFFER_SIZE);
while((length = reader.read(buffer)) > 0) {
writer.write(buffer, 0, length);
}
} finally {
close(reader, writer);
}
}
// closes the given list of objects, which must be one of the following types: java.io.InputStream,
// java.io.OutputStream, java.io.Reader, or java.io.Writer
public static void close(Object ... streams) {
if (streams == null) return;
for (int i = 0; i < streams.length; i++) {
Object stream = streams[i];
try {
if (stream != null) {
if (stream instanceof java.io.InputStream) {
((java.io.InputStream)stream).close();
} else if (stream instanceof java.io.OutputStream) {
((java.io.OutputStream)stream).close();
} else if (stream instanceof java.io.Reader) {
((java.io.Reader)stream).close();
} else if (stream instanceof java.io.Writer) {
((java.io.Writer)stream).close();
}
}
} catch (java.io.IOException ex) {}
}
}
}
public static class string {
// converts a byte array, input stream or string to a string
public static String normalize(Object object, String encoding) throws java.io.IOException {
if (encoding == null) encoding = tundra.support.constant.DEFAULT_CHARACTER_ENCODING;
String string = null;
if (object != null) {
if (object instanceof String) {
string = (String)object;
} else if (object instanceof byte[]) {
string = new String((byte[])object, encoding);
} else if (object instanceof java.io.InputStream) {
java.io.Writer writer = new java.io.StringWriter();
tundra.stream.copy(new java.io.InputStreamReader((java.io.InputStream)object, encoding), writer);
string = writer.toString();
} else {
throw new IllegalArgumentException("object must be a string, byte[] or java.io.InputStream: " + object.getClass().getName());
}
}
return string;
}
}
public static class support {
public static class constant {
public static final String DEFAULT_CHARACTER_ENCODING = java.nio.charset.Charset.defaultCharset().name();
public static final int DEFAULT_BUFFER_SIZE = 4096;
}
}
}
// --- <<IS-END-SHARED>> ---
}
Pipeline-v0.0.1.zip (23.9 KB)