Skip to content

Instantly share code, notes, and snippets.

@lachlan
Created June 25, 2012 01:25
Show Gist options
  • Save lachlan/2985890 to your computer and use it in GitHub Desktop.
Save lachlan/2985890 to your computer and use it in GitHub Desktop.
What the webMethods Integration Server pipeline looks like as javascript
// Every webMethods Integration Server service has exactly one input
// argument: the pipeline.
//
// The pipeline is like a javascript object that gets passed to each
// service that gets called. (It's actually a com.wm.data.IData object,
// which is essentially a hash table.)
//
// Because objects are passed by reference, every service or function
// called can alter the keys and values in the pipeline.
//
// This is an example of how the webMethods Integration Server pipeline
// would work if it was implemented in javascript.
//
// $ node pipeline.js
var inspect = require('util').inspect;
function greet(pipeline) {
// convert the name argument to upper case
pipeline.instring = pipeline.name;
upcase(pipeline);
pipeline.name = pipeline.outstring;
// get honorific
honorific(pipeline);
// return greeting variable
pipeline.greeting = 'Hello ' + pipeline.honorific + ' ' + pipeline.name;
}
function upcase(pipeline) {
pipeline.outstring = pipeline.instring.toUpperCase();
}
function honorific(pipeline) {
if (pipeline.gender === 'male') {
pipeline.honorific = 'Mr';
} else if (pipeline.gender == 'female') {
pipeline.honorific = 'Ms';
} else {
pipeline.honorific = '';
}
}
// declare a pipeline
var pipeline = {
name: 'John Doe',
gender: 'male',
email: '[email protected]',
address: '123 Sycamore Street'
}
// call the greet function, passing in the pipeline
// => Hello Mr JOHN DOE
greet(pipeline);
console.log("greeting = " + pipeline.greeting);
console.log("pipeline = " + inspect(pipeline));
@chiragsanghavi
Copy link

Being a webMethods programmer - I did get the idea. In fact, I had to think like a js developer to understand what you are trying to explain here.

@lachlan
Copy link
Author

lachlan commented Aug 7, 2012

I've had trouble explaining the pipeline to people in the past, and hoped this would make it click for a js developer...I'm not sure it does though.

@lachlan
Copy link
Author

lachlan commented Aug 7, 2012

Here's a version of this gist in pure java: https://gist.github.com/3000140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment