Imported from svn by Bitbucket

master
pymma 2012-11-08 17:12:01 +01:00 committed by bitbucket
commit 8aeb7bc8d3
61767 changed files with 8245612 additions and 0 deletions

1
bb/src/cmn/bdb/bdb.bdb Executable file
View File

@ -0,0 +1 @@
bb/src/cmn/bdb

31
bb/src/cmn/bdb/install.map Executable file
View File

@ -0,0 +1,31 @@
#note - don't do the bdb munge on these files or you will be sorry!
TARGET_OS=cmn & substvar
projects.bdb bdb/projects 0444
TARGET_OS=cmn
services.bdb bdb/services 0444
suffix.dat bdb/suffix.dat 0444
#environment definitions for the release build:
mmf.rc bdb/mmf.rc 0444
mmf.rc bdb/printmap.rc 0444
#note that bdb also processes includes.
TARGET_OS=cmn & bdb
bdb.bdb bdb/bdb.cmn 0444
mmf.bdb bdb/mmf.cmn 0444
#these bdb's must match the project names in projects.bdb:
maintools.bdb bdb/maintools.cmn 0444
maintools.bdb bdb/jbicomptools.cmn 0444
maintools.bdb bdb/rttl.cmn 0444
maintools.bdb bdb/myktl.cmn 0444
maintools.bdb bdb/khtl.cmn 0444
maintools.bdb bdb/retools.cmn 0444
#these bdb's are of the form <project>_ant.bdb
#for a project name in the projects.bdb:
maintools_ant.bdb bdb/maintools_ant.cmn 0444
maintools_ant.bdb bdb/rttl_ant.cmn 0444
maintools_ant.bdb bdb/myktl_ant.cmn 0444
maintools_ant.bdb bdb/khtl_ant.cmn 0444
maintools_ant.bdb bdb/retools_ant.cmn 0444

51
bb/src/cmn/bdb/maintools.bdb Executable file
View File

@ -0,0 +1,51 @@
#put prlskel first:
tl/src/cmn/prlskel
t3/src/gnu/cvsdist
t3/src/gnu/diffutil
t3/src/gnu/ed
t3/src/gnu/gzip
t3/src/gnu/make
t3/src/gnu/patch
t3/src/gnu/perl
#check in perl modules here:
t3/src/gnu/perlcmn
t3/src/gnu/rsync
t3/src/gnu/sinc32
t3/src/gnu/wget
t3/src/jakarta/ant1_6
t3/src/jakarta/ant1_6ext
#t3/src/jakarta/maven1
#this is 2.0.5:
t3/src/jakarta/maven2
#this is 2.0.9:
t3/src/jakarta/maven209
t3/src/gnu/rcs5
t3/src/gnu/tar
t3/src/xmltools/trang
t3/src/xmltools/xmlindent
t3/src/xref
tl/src/cmn/applyinf
tl/src/cmn/bldres
tl/src/cmn/cgutil
tl/src/cmn/cvsboot
tl/src/cmn/cvslib
tl/src/cmn/cvsutil
tl/src/cmn/email
tl/src/cmn/fileio
tl/src/cmn/fwhich
tl/src/cmn/genbld
#this is rj, jartoc, jxtohml:
tl/src/cmn/javautil
tl/src/cmn/maven-plugins/jregress
#tl/src/cmn/maven-plugins/unjar
tl/src/cmn/maven-util
tl/src/cmn/psutil
tl/src/cmn/time
tl/src/cmn/toolinfo
tl/src/cmn/util
#java tools and scripts:
tl/src/java/cmdutil
#####
#Include jnet tools
#####
include maintools_common.bdb

View File

@ -0,0 +1,2 @@
tl/src/java/canonxml
tl/src/java/cmdutil

View File

@ -0,0 +1,34 @@
tl/src/cmn/makedrv
tl/src/cmn/minstall
tl/src/cmn/codegen
tl/src/cmn/codegen/templates
tl/src/cmn/codegen/templates/licenses
tl/src/cmn/codegen/templategen/maven
tl/src/cmn/codegen/templategen/maven2
tl/src/cmn/codegen/templates/perl
tl/src/cmn/codegen/templategen/xml
tl/src/cmn/commitd
tl/src/cmn/bom
tl/src/cmn/libmmf
tl/src/cmn/libmisc
tl/src/cmn/os
tl/src/cmn/support
tl/src/cmn/parse
tl/src/cmn/mmfdrv
tl/src/cmn/whatport
t3/src/misc/crc
t3/src/trelab/makemf
#java tools and scripts:
tl/src/java/canonxml
#these projects install readme.txt files to avoid empty package & lib dirs:
tl/src/cygwin/packages
tl/src/linux/packages
tl/src/macosx/packages
tl/src/nt/lib
tl/src/nt/packages
tl/src/solsparc/packages
tl/src/solx86/packages
#this requires that you set CVSDIST_LOCALE, e.g. "generic" or "oakland"
#also, it is a good idea to do this last, so that the cvs module
#defs are not visible until the tools finish building.
admin/src/cvsdist/$CVSDIST_LOCALE

12
bb/src/cmn/bdb/make.mmf Executable file
View File

@ -0,0 +1,12 @@
TEMPLATE = file.mmf
DESTRULE = dist_except_cmn
BASE = $(SRCROOT)
PKG = bdb
UPDATE=-udiff
#we don't want transactions
TRANSACT =
#FILES = bdb.bdb maintools.bdb maintools_ant.bdb mmf.bdb projects.bdb services.bdb suffix.dat jbiroot.bdb mmf.rc
FILES = bdb.bdb maintools.bdb maintools_ant.bdb mmf.bdb projects.bdb services.bdb suffix.dat

27
bb/src/cmn/bdb/mmf.bdb Executable file
View File

@ -0,0 +1,27 @@
#directories build during toolsBuild (makedrv -c mmf)
tl/src/cmn/build
tl/src/cmn/codeline
tl/src/cmn/setup
#tl/src/cmn/jbiutil
#netbeans ide, needed by ui tools:
#t3/src/netbeans/ide/cmn
#netbeans xtest, needed by ui tools:
#t3/src/netbeans/xtest/cmn
#appserver 8.x auto-install configuration:
#t3/src/sun/as8/cmn
#t3/src/sun/as8/linux
#t3/src/sun/as8/nt
#t3/src/sun/as8/solsparc
#t3/src/sun/as8/solx86
#t3/src/sun/as8/macosx
#jboss auto-install configuration:
#t3/src/other/jboss/cmn
#t3/src/other/jboss/linux
#t3/src/other/jboss/nt
#t3/src/other/jboss/solsparc
#t3/src/other/jboss/solx86
#t3/src/other/jboss/macosx
#ant libs used exclusively by this project:
#t3/src/jakarta/antext
#build release staging dirs:
#include jbiroot.bdb

23
bb/src/cmn/bdb/projects.bdb Executable file
View File

@ -0,0 +1,23 @@
#list of projects related to this path.
#used by tools build, if found in the AUX_TOOLS_PJLIST
#environment variable.
#NOTE - this project name must agree with corresponding bdb,
#e.g., a project "footools" will look for a bdb named "footools.cmn"
#you must create the footools.bdb source bdb in this directory
#(perhaps by including another bdb file, like "maintools.bdb" OR
#by simply adding your new bdb name to the install.map file).
#########
#generic RE tools setup:
#########
retools /localdevroot/{=PRODUCT=}/{=CODELINE=}/devtools
######
#these projects are for tools development only:
######
rttl /localdevroot/russt/{=CODELINE=}/devtools
myktl /localdevroot/myk/{=CODELINE=}/devtools
khtl /localdevroot/karl/{=CODELINE=}/devtools

2
bb/src/cmn/bdb/services.bdb Executable file
View File

@ -0,0 +1,2 @@
## this is service list for makedrv-based stuff only
bb tl t3 rl

293
bb/src/cmn/bdb/suffix.dat Executable file
View File

@ -0,0 +1,293 @@
1 text
2 text
3 text
4gl text
5 text
LIB binary
VER text
a text
acf text
adf binary
ant text
api binary
app binary
asm text
attributes binary
aux text
awk text
axp text
bas text
bat text
bdb text
bmp binary
bom text
bsh text
btd binary
btx binary
btz binary
bug text
c text
c64 text
cat binary
cc text
ccg text
cdf text
cdg text
cdr binary
cer binary
cex text
cfg text
cif text
cl text
cla binary
class binary
cld text
clf text
cls binary
clw binary
cmd text
cmn text
cmp text
cnf text
cnt binary
col text
cob text
com text
cp text
cpp text
cps text
crl text
csc text
csh text
css text
ctl text
cur binary
daf binary
dat text
db2 text
dc text
dct binary
ddl text
def binary
dep text
der binary
dlg text
dll binary
doc binary
drw binary
dsp text
dsw text
dtd text
e text
ec text
edf binary
ejb text
ejbj2eeri text
ejbmodule text
ejbtestAS1 text
ejbtestAS2 text
env text
es1 text
es2 text
es3 text
esc text
ex binary
exe binary
exp text
fdb binary
fdd binary
fdl text
fff binary
fmf binary
fml text
fn text
fnd text
fns text
form text
fpf text
frm text
frx binary
fs1 text
fs2 text
fs3 text
fsc text
fsm binary
fso binary
fsw binary
fts binary
gen text
gid binary
gif binary
gnu text
grp binary
gz binary
h text
hdg text
hf text
hlp binary
hqx text
hs text
ht text
htm text
html text
ice text
ico binary
idb binary
idf binary
idl text
ids text
idx binary
imh text
iml text
inc text
inf text
ing text
ini text
inp text
ior text
isj binary
jar binary
jav text
java text
jcl text
jhm text
jpg binary
jpp text
js text
jsw binary
kdf text
key binary
ksh text
ky text
kys text
l text
lib binary
license binary
lnk text
lst text
ltz binary
m32 text
m64 text
mac text
mak text
man text
map text
mar text
mb2 binary
mdd text
mem text
mf text
min text
mk text
mmf text
mml text
mms text
mpw text
ms text
msg text
msh text
mvs390 text
mxi text
mxp binary
ncb binary
nco text
neg text
nt text
nti text
nto binary
o binary
obj binary
ocx binary
odb text
odl text
olb binary
opt text
ora text
org text
p7c binary
p7s binary
pc text
pch binary
pdf binary
pds binary
pel text
pex text
pfx binary
pif binary
pin text
pl text
pm text
ppf text
ppt binary
prl text
pro text
props text
properties text
prp text
prx text
r text
r6k text
rc text
rc2 text
rdb text
rdf text
ref text
reg text
res binary
rex text
rsp text
rtf binary
rul text
s text
sc text
scl text
scr text
sdf text
sed text
ser binary
sh text
sho binary
ske text
slk binary
so binary
sqc text
sql text
sta binary
stub text
stz binary
syb text
tad binary
tar binary
tbl text
tch text
tcl text
tex text
tgz binary
tlb binary
tld text
toc text
tp text
tpl text
tps text
trc text
txt text
vbp text
vcw text
ver text
vlx binary
vr text
vrs text
vsd binary
w3 text
w30 text
war binary
wsp text
x text
xbm text
xdi binary
xls binary
xml text
xpm text
xsl text
y text
zip binary

47
contrib-bostech/build.xml Executable file
View File

@ -0,0 +1,47 @@
<project name="module-mainbuild" default="build">
<property name="cbesb.home" location="." />
<property name="external_libs" location="${cbesb.home}/lib" />
<property name="build.dir" location="${cbesb.home}/build" />
<property name="build.lib.dir" location="${cbesb.home}/build/lib" />
<target name="build">
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.component.util/scripts" antfile="build.xml" target="build"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.ccsl/scripts" antfile="build.xml" target="build"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.component.tcpip/scripts" antfile="build.xml" target="build"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.custom/scripts" antfile="build.xml" target="build"/>
<antcall target="packageComponents"/>
</target>
<target name="packageComponents" depends="packageTcpipComponent" />
<target name="packageTcpipComponent">
<jar destfile="${build.dir}/ChainBuilderESB-BC-TCPIP.jar">
<fileset dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.component.tcpip/src/resources">
<include name="**/jbi.xml" />
</fileset>
<fileset dir="${build.lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${external_libs}">
<include name="commons-logging-1.1.jar" />
<include name="servicemix-core-3.0-incubating.jar" />
<include name="servicemix-common-3.0-incubating.jar" />
<include name="wsdl4j-1.5.2.jar" />
<include name="backport-util-concurrent-2.1.jar" />
<include name="com.bostechcorp.cbesb.common.util.jar" />
</fileset>
</jar>
</target>
<target name="clean">
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.component.util/scripts" antfile="build.xml" target="clean"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.ccsl/scripts" antfile="build.xml" target="clean"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.runtime.component.tcpip/scripts" antfile="build.xml" target="clean"/>
<ant inheritAll="false" inheritRefs="false" dir="${cbesb.home}/com.bostechcorp.cbesb.custom/scripts" antfile="build.xml" target="clean"/>
<delete dir="${build.dir}" quiet="true" />
</target>
</project>

View File

@ -0,0 +1,47 @@
<project name="module-mainbuild" default="build">
<basename property="cbesb.project.name" file="../" />
<property name="cbesb.home" location="../.." />
<property name="src.dir" location="${cbesb.home}/${cbesb.project.name}/src/java" />
<property name="build.dir" location="${cbesb.home}/${cbesb.project.name}/target"/>
<property name="external_libs" location="${cbesb.home}/lib" />
<property name="build.lib.dir" location="${cbesb.home}/build/lib" />
<target name="build" depends="createJar" />
<target name="init">
<mkdir dir="${build.dir}/classes" />
<mkdir dir="${build.lib.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${build.dir}/classes" debug="true">
<classpath>
<fileset dir="${build.lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${external_libs}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="createJar" depends="compile">
<jar destfile="${build.lib.dir}/${cbesb.project.name}.jar">
<fileset dir="${build.dir}/classes">
<include name="**/*.class" />
</fileset>
</jar>
</target>
<target name="clean">
<delete dir="${build.dir}/classes" quiet="true"/>
<delete file="${build.lib.dir}/${cbesb.project.name}.jar" quiet="true"/>
</target>
</project>

View File

@ -0,0 +1,206 @@
/*
* ChainBuilder ESB
* Visual Enterprise Integration
*
* Copyright (C) 2007 Bostech Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* $Id: FourByteLengthEncodedHandler.java,v 1.1 2007/04/12 02:04:12 mpreston Exp $
*/
package com.bostechcorp.cbesb.custom.protocol;
import javax.jbi.messaging.MessageExchange;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.bostechcorp.cbesb.runtime.ccsl.lib.DumpNormalizedMessage;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipContext;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipHandler;
public class FourByteLengthEncodedHandler implements ITcpipHandler {
protected static final short INPUT_WANT_LENGTH = 0;
protected static final short INPUT_WANT_DATA = 1;
protected static final short LENGTH_BYTES = 4;
protected static final int INPUT_TIMEOUT = 3000;
protected Log logger = LogFactory.getLog(getClass());
protected ITcpipContext context;
protected StringBuffer inMessage;
protected short inputState;
protected boolean gotInMessage;
protected int bytesLeft;
protected byte[] lengthBytes = new byte[LENGTH_BYTES];
public String getDescription() { return "TCPIP four byte length encoded protocol handler"; }
public void init(ITcpipContext ctx) {
context = ctx;
context.setSocketTimeout(0);
inMessage = new StringBuffer();
gotInMessage = false;
bytesLeft = LENGTH_BYTES;
inputState = INPUT_WANT_LENGTH;
}
/*
* This handles received data in consumer mode.
*/
public int gotReceiveData(byte[] bytes) throws Exception {
context.setSocketTimeout(INPUT_TIMEOUT);
int bytesConsumed = receiveStateMachine(bytes);
if (gotInMessage) {
// create the inbound exchange and possibly return the out message
byte[] inBytes = (new String(inMessage)).getBytes("ISO8859-1");
logger.debug("got inbound message ("+inMessage.length()+" bytes)\n"+DumpNormalizedMessage.dumpBytesAsHex(inBytes));
byte[] outBytes = context.createInbound(inBytes);
if (outBytes != null) sendMessage(outBytes);
// reset the input state
inMessage = new StringBuffer();
inputState = INPUT_WANT_LENGTH;
bytesLeft = LENGTH_BYTES;
gotInMessage = false;
context.setSocketTimeout(0);
}
return bytesConsumed;
}
/*
* Flush input state on a timeout
*/
public void gotReceiveTimeout() throws Exception {
logger.info("TCPIP handler timed out on input");
inMessage = new StringBuffer();
inputState = INPUT_WANT_LENGTH;
bytesLeft = LENGTH_BYTES;
context.setSocketTimeout(0);
}
/*
* No special processing for a socket error
*/
public void gotSocketError(Exception e) throws Exception {}
/*
* Send an in-only message
*/
public void processInOnlyBytes(byte[] bytes) throws Exception {
sendMessage(bytes);
}
/*
* Send a message and return a reply
*/
public byte[] processInOutBytes(byte[] bytes) throws Exception {
byte[] returnBytes = null;
sendMessage(bytes);
byte[] received;
context.setSocketTimeout(INPUT_TIMEOUT);
while ((received = context.receiveSocket()) != null) {
for (int bytesLeft=0; (bytesLeft=received.length) > 0;) {
int consumed = receiveStateMachine(received);
if (gotInMessage) break;
if (consumed > 0) {
byte[] newBytes = new byte[bytesLeft-consumed];
for (int i=0; i<newBytes.length; i++) newBytes[i] = received[consumed++];
received = newBytes;
}
}
if (gotInMessage) {
returnBytes = (new String(inMessage)).getBytes("ISO8859-1");
inMessage = new StringBuffer();
inputState = INPUT_WANT_LENGTH;
gotInMessage = false;
bytesLeft = 4;
context.setSocketTimeout(0);
break;
}
}
return returnBytes;
}
/*
* I don't use these since i'm using the byte array methods
*/
public void processInOnlyExchange(MessageExchange e) throws Exception {}
public void processInOutExchange(MessageExchange e) throws Exception {}
/*
* Add the byte count and send a message
*/
protected void sendMessage(byte[] bytes) throws Exception {
byte[] message = new byte[bytes.length+4];
int length = bytes.length+LENGTH_BYTES;
for (int i=LENGTH_BYTES-1; i>=0; i--) {
message[i] = (byte)(length & 0xFF);
length >>= 8;
}
int i;
for (i=0; i<bytes.length; i++) message[i+4] = bytes[i];
context.sendSocket(message);
}
/*
* Detect messages
*/
protected int receiveStateMachine(byte[] bytes) throws Exception {
int bytesConsumed = bytes.length;
int position = 0;
if (bytes.length < 1) throw new Exception("zero bytes received");
switch (inputState) {
case INPUT_WANT_LENGTH:
while (bytesLeft > 0 && position < bytes.length) {
lengthBytes[--bytesLeft] = bytes[position++];
}
if (bytesLeft > 0) {
bytesConsumed = position;
break;
}
inputState = INPUT_WANT_DATA;
bytesLeft=0;
for (int i=LENGTH_BYTES-1; i>=0; i--)
bytesLeft = 256*bytesLeft + lengthBytes[i];
bytesLeft -= LENGTH_BYTES;
// don't break here since we want to process the next state
case INPUT_WANT_DATA:
int length = bytes.length-position;
if (length < bytesLeft) {
inMessage.append(new String(bytes, position, length, "ISO8859-1"));
bytesLeft -= length;
} else {
inMessage.append(new String(bytes, position, bytesLeft, "ISO8859-1"));
position += bytesLeft;
bytesConsumed = position;
gotInMessage = true;
}
break;
}
return bytesConsumed;
}
}

View File

@ -0,0 +1,159 @@
package com.bostechcorp.cbesb.custom.protocol;
import java.net.SocketTimeoutException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import com.bostechcorp.cbesb.runtime.ccsl.lib.DumpNormalizedMessage;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipContext;
public class MllpAckNakHandler extends MllpHandler {
protected char fieldSep;
protected String[] mshFields;
public String getDescription() { return "TCPIP MLLP ACK/NAK protocol handler"; }
public void init(ITcpipContext ctx) {
super.init(ctx);
ctx.setIsAsyncSend(true);
}
/*
* This handles received data in consumer mode.
* Create an exchange and send an ACK if the MSH is valid
*/
public int gotReceiveData(byte[] bytes) throws Exception {
int bytesConsumed = receiveStateMachine(bytes);
if (gotInMessage) {
// pre-parse the message and make sure that we at least have a valid MSH segment
String messageString = new String(inMessage);
byte[] messageBytes = messageString.getBytes("ISO8859-1");
logger.debug("got inbound message ("+inMessage.length()+" bytes)\n"+DumpNormalizedMessage.dumpBytesAsHex(messageBytes));
if (hl7PreParse(messageString)) {
// send a message exchange into the container.
context.createInbound(messageBytes);
// construct an ACK message
String ackString = makeAck();
byte[] ackBytes = ackString.getBytes("ISO8859-1");
logger.debug("sending acknowledgement ("+ackString.length()+" bytes)\n"+DumpNormalizedMessage.dumpBytesAsHex(ackBytes));
sendMessage(ackBytes);
} else
logger.debug("not valid HL7");
// reset the input state
inMessage = new StringBuffer();
inputState = INPUT_WANT_0B;
gotInMessage = false;
context.setSocketTimeout(0);
}
return bytesConsumed;
}
/*
* Send a message. Get the ack and resend if timeout or not "MSA|AA"
*/
public void processInOnlyBytes(byte[] bytes) throws Exception {
int retries;
for (retries=0; retries < 5; retries++) {
try {
byte[] receivedBytes;
try {
receivedBytes = super.processInOutBytes(bytes);
}
catch (SocketTimeoutException toe) {
continue;
}
String receivedString = new String(receivedBytes, "ISO8859-1");
int crPosition = receivedString.indexOf((char)13);
if (crPosition > 0) {
String fieldSep = receivedString.substring(3,4);
String goodAck = "MSA" + fieldSep + "AA";
if (receivedString.substring(crPosition+1, crPosition+1+goodAck.length()).equals(goodAck)) {
logger.debug("got good ack\n"+DumpNormalizedMessage.dumpBytesAsHex(receivedBytes));
break;
}
}
}
catch (SocketTimeoutException e) {
logger.debug("ACKNACK send got "+e, e);
}
}
if (retries == 5) {
throw new Exception("no ACK received");
}
}
/*
* in-out exchanges are not valid for this handler. We simply demote it to
* in-only and return a canned success message.
*/
public byte[] processInOutBytes(byte[] bytes) throws Exception {
byte[] successBytes = "MllpAckNakHandler sent message successfully".getBytes("ISO8859-1");
processInOnlyBytes(bytes);
return successBytes;
}
/*
* Verify that the message begins with 'MSH' and contains a carriage return.
* Split the MSH segment into an array on the field separator
*/
protected boolean hl7PreParse(String messageString) {
boolean isValid = false;
int firstCr = messageString.indexOf(13);
if (firstCr > 2 && messageString.startsWith("MSH")) {
fieldSep = messageString.charAt(3);
mshFields = splitFields(messageString.substring(0, firstCr), fieldSep);
// we need at least 12 fields
if (mshFields.length >= 12) isValid = true;
}
return isValid;
}
protected String makeAck() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
long timeNow = System.currentTimeMillis();
String timeStamp = sdf.format(new Date(timeNow));
String eventString;
if (mshFields[8].length() > 4) eventString = mshFields[8].substring(3);
else eventString = "";
String ack =
"MSH" + fieldSep +
mshFields[1] + fieldSep + // encoding characters
mshFields[4] + fieldSep + // flip the sender and receiver
mshFields[5] + fieldSep +
mshFields[2] + fieldSep +
mshFields[3] + fieldSep +
timeStamp + fieldSep + // current date & time
"" + fieldSep + // not used
"ACK" + // message type
eventString +
fieldSep +
timeNow + fieldSep + // control number, use current time
mshFields[10] + fieldSep + // processing (T/P)
mshFields[11] + (char)13 +
"MSA" + fieldSep +
"AA" + fieldSep +
mshFields[9] + fieldSep; // original control number
return ack;
}
protected String[] splitFields(String mes, char sep) {
Vector<String> fields = new Vector<String>();
int startPosition = 0;
int sepPosition;
while((sepPosition = mes.indexOf(sep, startPosition)) >= 0) {
fields.add(mes.substring(startPosition, sepPosition));
startPosition = sepPosition+1;
}
if (startPosition < mes.length())
fields.add(mes.substring(startPosition));
return fields.toArray(new String[0]);
}
}

View File

@ -0,0 +1,224 @@
/*
* ChainBuilder ESB
* Visual Enterprise Integration
*
* Copyright (C) 2007 Bostech Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* $Id: MllpHandler.java,v 1.2 2007/04/25 20:45:59 afung Exp $
*/
package com.bostechcorp.cbesb.custom.protocol;
import javax.jbi.messaging.MessageExchange;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.bostechcorp.cbesb.runtime.ccsl.lib.DumpNormalizedMessage;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipContext;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ITcpipHandler;
public class MllpHandler implements ITcpipHandler {
protected static final short INPUT_WANT_0B = 0;
protected static final short INPUT_WANT_1C = 1;
protected static final short INPUT_WANT_0D = 2;
protected static final int READ_TIMEOUT = 7000;
protected Log logger = LogFactory.getLog(getClass());
protected ITcpipContext context;
protected StringBuffer inMessage;
protected short inputState;
protected boolean gotInMessage;
public String getDescription() { return "TCPIP MLLP protocol handler"; }
public void init(ITcpipContext ctx) {
context = ctx;
context.setSocketTimeout(0);
inMessage = new StringBuffer();
gotInMessage = false;
inputState = INPUT_WANT_0B;
}
/*
* This handles received data in consumer mode.
*/
public int gotReceiveData(byte[] bytes) throws Exception {
System.out.println("\n\n\nMllpHandler received:\n"+DumpNormalizedMessage.dumpBytesAsHex(bytes)+"\n\n");
context.setSocketTimeout(READ_TIMEOUT);
int bytesConsumed = receiveStateMachine(bytes);
if (gotInMessage) {
// create the inbound exchange and possibly return the out message
byte[] inBytes = (new String(inMessage)).getBytes("ISO8859-1");
logger.debug("got inbound message ("+inMessage.length()+" bytes)\n"+DumpNormalizedMessage.dumpBytesAsHex(inBytes));
System.out.println("\n\n\nMllpHandler creating inbound:\n"+DumpNormalizedMessage.dumpBytesAsHex(inBytes)+"\n\n");
byte[] outBytes = context.createInbound(inBytes);
if (outBytes != null) {
System.out.println("\n\n\nMllpHandler reply bytes:\n"+DumpNormalizedMessage.dumpBytesAsHex(outBytes)+"\n\n");
sendMessage(outBytes);
}
// reset the input state
inMessage = new StringBuffer();
inputState = INPUT_WANT_0B;
gotInMessage = false;
context.setSocketTimeout(0);
}
return bytesConsumed;
}
/*
* Flush input state on a timeout
*/
public void gotReceiveTimeout() throws Exception {
logger.info("TCPIP handler timed out on input");
inMessage = new StringBuffer();
inputState = INPUT_WANT_0B;
context.setSocketTimeout(0);
}
/*
* No special processing for a socket error
*/
public void gotSocketError(Exception e) throws Exception {}
/*
* Send an in-only message
*/
public void processInOnlyBytes(byte[] bytes) throws Exception {
sendMessage(bytes);
}
/*
* Send a message and return a reply
*/
public byte[] processInOutBytes(byte[] bytes) throws Exception {
byte[] returnBytes = null;
sendMessage(bytes);
byte[] received;
context.setSocketTimeout(READ_TIMEOUT);
while ((received = context.receiveSocket()) != null) {
for (int bytesLeft=0; (bytesLeft=received.length) > 0;) {
int consumed = receiveStateMachine(received);
if (gotInMessage) break;
if (consumed > 0) {
byte[] newBytes = new byte[bytesLeft-consumed];
for (int i=0; i<newBytes.length; i++) newBytes[i] = received[consumed++];
received = newBytes;
}
}
if (gotInMessage) {
returnBytes = (new String(inMessage)).getBytes("ISO8859-1");
inMessage = new StringBuffer();
inputState = INPUT_WANT_0B;
gotInMessage = false;
context.setSocketTimeout(0);
break;
}
}
return returnBytes;
}
/*
* I don't use these since i'm using the byte array methods
*/
public void processInOnlyExchange(MessageExchange e) throws Exception {}
public void processInOutExchange(MessageExchange e) throws Exception {}
/*
* Add the MLLP wrapper and send a message
*/
protected void sendMessage(byte[] bytes) throws Exception {
byte[] message = new byte[bytes.length+3];
message[0] = 0x0B;
int i;
for (i=0; i<bytes.length; i++) message[i+1] = bytes[i];
message[++i] = 0x1C;
message[++i] = 0x0D;
context.sendSocket(message);
}
/*
* Detect messages in a 0B-->1C0D MLLP wrapper
*/
protected int receiveStateMachine(byte[] bytes) throws Exception {
int bytesConsumed = bytes.length;
int position = 0;
if (bytes.length < 1) throw new Exception("zero bytes received");
switch (inputState) {
case INPUT_WANT_0B:
// ignore everything up to the first 0x0B
int pos_0b=findByte(bytes, position, (byte)0x0B);
if (pos_0b < 0) break;
position = pos_0b+1;
inputState = INPUT_WANT_1C;
context.setSocketTimeout(READ_TIMEOUT);
// don't break here since we want to process the next state
case INPUT_WANT_1C:
// capture everything up to then next 0x1C
int pos_1c=findByte(bytes, position, (byte)0x1C);
if (pos_1c < 0) {
int length = bytes.length-position;
if (length > 0) inMessage.append(new String(bytes, position, length, "ISO8859-1"));
break;
}
inMessage.append(new String(bytes, position, pos_1c-position, "ISO8859-1"));
inputState = INPUT_WANT_0D;
position = pos_1c+1;
// don't break here since we want to process the next state
case INPUT_WANT_0D:
// if the next byte is 0D then we have a message, otherwise keep capturing
if (position >= bytes.length) break;
if (bytes[position] == (byte)0x0D) {
gotInMessage = true;
bytesConsumed = position+1;
} else {
inMessage.appendCodePoint(0x1C);
inputState=INPUT_WANT_1C;
bytesConsumed = position;
}
break;
}
return bytesConsumed;
}
/*
* find the first occurrence of a value in a byte array
*/
protected int findByte(byte[] bytes, int start, byte want) {
int result = -1;
if (bytes != null) {
for (int i=start; i<bytes.length; i++)
if (bytes[i] == want) {
result = i;
break;
}
}
return result;
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="src/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/geronimo-spec-j2ee-connector-1.5-rc4.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/activation.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/groovy-all-1.0-JSR-06.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/jsr-223-1.0-pr.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs.plugin/derby.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs.plugin/derbyclient.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs.plugin/ibatis-common-2.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs.plugin/ibatis-dao-2.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs.plugin/ibatis-sqlmap-2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.bostechcorp.cbesb.runtime.component.util"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.bostechcorp.cbesb.common.util"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/servicemix-common-3.0-incubating.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/servicemix-core-3.0-incubating.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/servicemix-jbi-3.0-incubating.jar"/>
<classpathentry kind="lib" path="/com.bostechcorp.cbesb.external.libs/commons-codec-1.3.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.bostechcorp.cbesb.common"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.bostechcorp.cbesb.runtime.ccsl</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,47 @@
<project name="module-mainbuild" default="build">
<basename property="cbesb.project.name" file="../" />
<property name="cbesb.home" location="../.." />
<property name="src.dir" location="${cbesb.home}/${cbesb.project.name}/src/java" />
<property name="build.dir" location="${cbesb.home}/${cbesb.project.name}/target"/>
<property name="external_libs" location="${cbesb.home}/lib" />
<property name="build.lib.dir" location="${cbesb.home}/build/lib" />
<target name="build" depends="createJar" />
<target name="init">
<mkdir dir="${build.dir}/classes" />
<mkdir dir="${build.lib.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${build.dir}/classes" debug="true">
<classpath>
<fileset dir="${build.lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${external_libs}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="createJar" depends="compile">
<jar destfile="${build.lib.dir}/${cbesb.project.name}.jar">
<fileset dir="${build.dir}/classes">
<include name="**/*.class" />
</fileset>
</jar>
</target>
<target name="clean">
<delete dir="${build.dir}/classes" quiet="true"/>
<delete file="${build.lib.dir}/${cbesb.project.name}.jar" quiet="true"/>
</target>
</project>

View File

@ -0,0 +1,180 @@
/*
* ChainBuilder ESB
* Visual Enterprise Integration
*
* Copyright (C) 2006 Bostech Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* $Id: CcslComponent.java,v 1.1.1.1 2007/04/09 17:49:27 mpreston Exp $
*/
package com.bostechcorp.cbesb.runtime.ccsl.base;
import java.io.IOException;
import javax.jbi.JBIException;
import javax.jbi.component.Component;
import javax.jbi.component.ComponentContext;
import javax.jbi.component.ComponentLifeCycle;
import javax.jbi.component.ServiceUnitManager;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import com.bostechcorp.cbesb.common.version.Version;
import com.bostechcorp.cbesb.runtime.ccsl.lib.CcslConfig;
import com.bostechcorp.cbesb.runtime.ccsl.lib.ExceptionUtil;
public class CcslComponent implements Component, ComponentLifeCycle {
String realComponentClassName;
CcslConfig config;
Component realComponent;
ComponentLifeCycle realComponentLifeCycle;
ServiceUnitManager realSuManager;
ServiceUnitManager ccslSuManager;
ComponentContext realComponentContext;
ComponentContext ccslComponentContext;
DeliveryChannel realDeliveryChannel;
DeliveryChannel ccslDeliveryChannel;
Log log;
public ComponentLifeCycle getLifeCycle() {
return this;
}
public Document getServiceDescription(ServiceEndpoint arg0) {
Document desc = realComponent.getServiceDescription(arg0);
// try {
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// StreamResult result = new StreamResult(baos);
// TransformerFactory tf = TransformerFactory.newInstance();
// Transformer t = tf.newTransformer();
// t.setOutputProperty("indent", "yes");
// DOMSource ds = new DOMSource(desc.getFirstChild());
// t.transform(ds, result);
// log.debug("CCSL-SERVICEDESC="+baos.toString("utf-8")+"\n");
// }
// catch (Exception e) {
// log.error("\n\n\nException printing content: "+e+"\n"+ExceptionUtil.stackTraceString(e)+"\n\n\n");
// }
//
return desc;
}
public ServiceUnitManager getServiceUnitManager() {
if (ccslSuManager == null) {
realSuManager = realComponent.getServiceUnitManager();
ccslSuManager = new CcslSuManager(this, realSuManager);
}
return ccslSuManager;
}
public boolean isExchangeWithConsumerOkay(ServiceEndpoint arg0,
MessageExchange arg1) {
return realComponent.isExchangeWithConsumerOkay(arg0, arg1);
}
public boolean isExchangeWithProviderOkay(ServiceEndpoint arg0,
MessageExchange arg1) {
return realComponent.isExchangeWithProviderOkay(arg0, arg1);
}
public ServiceEndpoint resolveEndpointReference(DocumentFragment arg0) {
return realComponent.resolveEndpointReference(arg0);
}
public ObjectName getExtensionMBeanName() {
return realComponentLifeCycle.getExtensionMBeanName();
}
public void init(ComponentContext arg0) throws JBIException {
// save the real component context
realComponentContext = arg0;
// get a logger for our use
log = LogFactory.getLog(this.getClass());
// load the configuration file
config = new CcslConfig(log, realComponentContext.getInstallRoot());
realComponentClassName = config.getComponentClassName();
realDeliveryChannel = realComponentContext.getDeliveryChannel();
ccslDeliveryChannel = new CcslDeliveryChannel(this, realDeliveryChannel, log);
// create our adapter context
ccslComponentContext = new CcslComponentContext(this, realComponentContext, realDeliveryChannel, log);
log.debug("CCSL is initializing");
//Print the CCSL version
Version versInfo = Version.getInstance(this.getClass());
if (versInfo != null)
{
log.info("ChainBuilder ESB CCSL version: " + versInfo.toString() +
" built on " + versInfo.getBuildTimestamp());
}
else
{
log.warn("Unable to load CCSL version.");
}
// load the real component
log.debug("CCSL is loading component class "+realComponentClassName);
try {
Class comp = Class.forName(realComponentClassName, true, this.getClass().getClassLoader());
realComponent = (Component)comp.newInstance();
//Print version info for real component
versInfo = Version.getInstance(comp);
if (versInfo != null)
{
log.info(realComponentClassName + " Component version:" + versInfo.toString() +
" built on " + versInfo.getBuildTimestamp());
}
realComponentLifeCycle = realComponent.getLifeCycle();
realComponentLifeCycle.init(ccslComponentContext);
}
catch (ClassNotFoundException e) {
log.error("\n\n\nCCSL error loading class: "+e+"\n"+ExceptionUtil.stackTraceString(e)+"\n\n\n");
e.printStackTrace();
}
catch (Exception e) {
log.error("\n\n\nCCSL component class "+realComponentClassName+" loaded but failed to instantiate");
log.error(" exception="+e+"\n"+ExceptionUtil.stackTraceString(e)+"\n\n\n");
}
}
public void shutDown() throws JBIException {
realComponentLifeCycle.shutDown();
}
public void start() throws JBIException {
realComponentLifeCycle.start();
}
public void stop() throws JBIException {
realComponentLifeCycle.stop();
}
public CcslConfig getConfig() {
return config;
}
}

View File

@ -0,0 +1,147 @@
/*
* ChainBuilder ESB
* Visual Enterprise Integration
*
* Copyright (C) 2006 Bostech Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* $Id: CcslComponentContext.java,v 1.1.1.1 2007/04/09 17:49:27 mpreston Exp $
*/
package com.bostechcorp.cbesb.runtime.ccsl.base;
import java.util.MissingResourceException;
import javax.jbi.JBIException;
import javax.jbi.component.ComponentContext;
import javax.jbi.management.MBeanNames;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.MessagingException;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.MBeanServer;
import javax.naming.InitialContext;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
public class CcslComponentContext implements ComponentContext {
ComponentContext realComponentContext;
DeliveryChannel realDeliveryChannel;
DeliveryChannel ccslDeliveryChannel;
Log log;
CcslComponentContext(CcslComponent comp, ComponentContext cc, DeliveryChannel dc, Log logger) {
realComponentContext = cc;
realDeliveryChannel = dc;
log = LogFactory.getLog(this.getClass());
ccslDeliveryChannel = new CcslDeliveryChannel(comp, realDeliveryChannel, log);
}
public ServiceEndpoint activateEndpoint(QName arg0, String arg1)
throws JBIException {
return realComponentContext.activateEndpoint(arg0, arg1);
}
public void deactivateEndpoint(ServiceEndpoint arg0) throws JBIException {
realComponentContext.deactivateEndpoint(arg0);
}
public void deregisterExternalEndpoint(ServiceEndpoint arg0)
throws JBIException {
realComponentContext.deregisterExternalEndpoint(arg0);
}
public String getComponentName() {
return realComponentContext.getComponentName();
}
public DeliveryChannel getDeliveryChannel() throws MessagingException {
return ccslDeliveryChannel;
}
public ServiceEndpoint getEndpoint(QName arg0, String arg1) {
return realComponentContext.getEndpoint(arg0, arg1);
}
public Document getEndpointDescriptor(ServiceEndpoint arg0)
throws JBIException {
try {
return realComponentContext.getEndpointDescriptor(arg0);
} catch (NullPointerException e) {
log.debug