You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2006/10/17 20:38:39 UTC
svn commit: r464992 [4/4] - in /incubator/ode/trunk:
bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/
bpel-obj/src/main/java/org/apache/ode/bpel/o/
bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/
Modified: incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/Serializer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/Serializer.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/Serializer.java (original)
+++ incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/Serializer.java Tue Oct 17 11:38:35 2006
@@ -28,168 +28,168 @@
*/
public class Serializer {
- public static final byte[] MAGIC_NUMBER_BARFILE_PRE20040908 =
- new byte[] { 0x50, 0x4b, 0x03, 0x04 };
+ public static final byte[] MAGIC_NUMBER_BARFILE_PRE20040908 =
+ new byte[] { 0x50, 0x4b, 0x03, 0x04 };
- public static final byte[] MAGIC_NUMBER_OFH_20040908 =
- new byte[] { 0x55, '5', 'S', 0x00, 'O', 'F', 'H', 0x20, 0x04, 0x09, 0x08 };
+ public static final byte[] MAGIC_NUMBER_OFH_20040908 =
+ new byte[] { 0x55, '5', 'S', 0x00, 'O', 'F', 'H', 0x20, 0x04, 0x09, 0x08 };
- public static final byte[] MAGIC_NUMBER = MAGIC_NUMBER_OFH_20040908;
+ public static final byte[] MAGIC_NUMBER = MAGIC_NUMBER_OFH_20040908;
- public static final short FORMAT_SERIALIZED_JAVA14 = 0x01;
+ public static final short FORMAT_SERIALIZED_JAVA14 = 0x01;
- public static final short FORMAT_OLD_BAR = 0x02;
+ public static final short FORMAT_OLD_BAR = 0x02;
- // START PERSISTED FIELDS
- public final byte[] magic = new byte[MAGIC_NUMBER.length];
+ // START PERSISTED FIELDS
+ public final byte[] magic = new byte[MAGIC_NUMBER.length];
- /** Compiled Process representation format. */
- public short format;
+ /** Compiled Process representation format. */
+ public short format;
- /** Time of compilation (system local time). */
- public long compileTime;
+ /** Time of compilation (system local time). */
+ public long compileTime;
- /** Number of compiled processes in this file. */
- public int numProcesses;
- private InputStream _inputStream;
+ /** Number of compiled processes in this file. */
+ public int numProcesses;
+ private InputStream _inputStream;
// END PERSISTED FIELDS
- public Serializer(long compileTime, int numProcesses) {
- System.arraycopy(MAGIC_NUMBER, 0, magic, 0, MAGIC_NUMBER.length);
- this.format = FORMAT_SERIALIZED_JAVA14;
- this.compileTime = compileTime;
- this.numProcesses = numProcesses;
- }
-
- public Serializer() {}
-
- public Serializer(InputStream inputStream) throws IOException {
- _inputStream = inputStream;
- read(inputStream);
- }
-
- public void read(InputStream is) throws IOException {
- DataInputStream oin = new DataInputStream(is);
- byte[] magic = new byte[MAGIC_NUMBER.length];
- oin.read(magic, 0, magic.length);
-
- // Check old (BAR-file) encoding scheme
- if (Arrays.equals(MAGIC_NUMBER_BARFILE_PRE20040908, magic)) {
- this.format = FORMAT_OLD_BAR;
- this.compileTime = 0;
- this.numProcesses = 1;
- return;
- }
-
- // The current (most recent) scheme
- if (Arrays.equals(MAGIC_NUMBER, magic)) {
- this.format = oin.readShort();
- this.compileTime = oin.readLong();
- this.numProcesses = oin.readInt();
- return;
+ public Serializer(long compileTime, int numProcesses) {
+ System.arraycopy(MAGIC_NUMBER, 0, magic, 0, MAGIC_NUMBER.length);
+ this.format = FORMAT_SERIALIZED_JAVA14;
+ this.compileTime = compileTime;
+ this.numProcesses = numProcesses;
}
- throw new IOException("Unrecognized file format (bad magic number).");
- }
+ public Serializer() {}
- public void write(OutputStream os) throws IOException {
-
- DataOutputStream out = new DataOutputStream(os);
+ public Serializer(InputStream inputStream) throws IOException {
+ _inputStream = inputStream;
+ read(inputStream);
+ }
- out.write(MAGIC_NUMBER);
- out.writeShort(format);
- out.writeLong(compileTime);
- out.writeInt(numProcesses);
- out.flush();
- }
-
- public void writeOProcess(OProcess process, OutputStream os) throws IOException{
- ObjectOutputStream oos = new CustomObjectOutputStream(os);
- oos.writeObject(process);
- oos.flush();
- }
-
- public OProcess readOProcess() throws IOException, ClassNotFoundException {
- ObjectInputStream ois = new CustomObjectInputStream(_inputStream);
- return (OProcess) ois.readObject();
- }
-
- static class CustomObjectOutputStream extends ObjectOutputStream {
+ public void read(InputStream is) throws IOException {
+ DataInputStream oin = new DataInputStream(is);
+ byte[] magic = new byte[MAGIC_NUMBER.length];
+ oin.read(magic, 0, magic.length);
+
+ // Check old (BAR-file) encoding scheme
+ if (Arrays.equals(MAGIC_NUMBER_BARFILE_PRE20040908, magic)) {
+ this.format = FORMAT_OLD_BAR;
+ this.compileTime = 0;
+ this.numProcesses = 1;
+ return;
+ }
+
+ // The current (most recent) scheme
+ if (Arrays.equals(MAGIC_NUMBER, magic)) {
+ this.format = oin.readShort();
+ this.compileTime = oin.readLong();
+ this.numProcesses = oin.readInt();
+ return;
+ }
- /**
- * @param out
- * @throws IOException
- */
- public CustomObjectOutputStream(OutputStream out) throws IOException {
- super(out);
- enableReplaceObject(true);
- }
-
- protected Object replaceObject(Object obj) throws IOException{
- if(obj instanceof QName){
- QName q = (QName)obj;
- return new OQName(q.getNamespaceURI(), q.getLocalPart(), q.getPrefix());
- }
- return super.replaceObject(obj);
+ throw new IOException("Unrecognized file format (bad magic number).");
}
+
+ public void write(OutputStream os) throws IOException {
- }
+ DataOutputStream out = new DataOutputStream(os);
+
+ out.write(MAGIC_NUMBER);
+ out.writeShort(format);
+ out.writeLong(compileTime);
+ out.writeInt(numProcesses);
+ out.flush();
+ }
- static class CustomObjectInputStream extends ObjectInputStream {
+ public void writeOProcess(OProcess process, OutputStream os) throws IOException{
+ ObjectOutputStream oos = new CustomObjectOutputStream(os);
+ oos.writeObject(process);
+ oos.flush();
+ }
- /**
- * @param in
- * @throws IOException
- */
- public CustomObjectInputStream(InputStream in) throws IOException {
- super(in);
- enableResolveObject(true);
- }
-
- protected Object resolveObject(Object obj) throws IOException {
- if(obj instanceof OQName){
- OQName q = (OQName)obj;
- return new QName(q.uri, q.local, q.prefix);
- }
- return super.resolveObject(obj);
- }
-
- /**
- * Override coverts old class names into new class names to preserve compatibility with
- * pre-Apache namespaces.
- */
- @Override
- protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
- ObjectStreamClass read = super.readClassDescriptor();
- if (read.getName().startsWith("com.fs.pxe.")) {
- return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.pxe.", "org.apache.ode.")));
- }
- if (read.getName().startsWith("com.fs.utils.")) {
- return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.utils.", "org.apache.ode.utils.")));
- }
- return read;
+ public OProcess readOProcess() throws IOException, ClassNotFoundException {
+ ObjectInputStream ois = new CustomObjectInputStream(_inputStream);
+ return (OProcess) ois.readObject();
}
-
- }
- static class OQName implements Serializable{
-
- private static final long serialVersionUID = 1L;
+ static class CustomObjectOutputStream extends ObjectOutputStream {
+
+ /**
+ * @param out
+ * @throws IOException
+ */
+ public CustomObjectOutputStream(OutputStream out) throws IOException {
+ super(out);
+ enableReplaceObject(true);
+ }
+
+ protected Object replaceObject(Object obj) throws IOException{
+ if(obj instanceof QName){
+ QName q = (QName)obj;
+ return new OQName(q.getNamespaceURI(), q.getLocalPart(), q.getPrefix());
+ }
+ return super.replaceObject(obj);
+ }
- final String local;
- final String uri;
- final String prefix;
+ }
+
+ static class CustomObjectInputStream extends ObjectInputStream {
+
+ /**
+ * @param in
+ * @throws IOException
+ */
+ public CustomObjectInputStream(InputStream in) throws IOException {
+ super(in);
+ enableResolveObject(true);
+ }
+
+ protected Object resolveObject(Object obj) throws IOException {
+ if(obj instanceof OQName){
+ OQName q = (OQName)obj;
+ return new QName(q.uri, q.local, q.prefix);
+ }
+ return super.resolveObject(obj);
+ }
+
+ /**
+ * Override coverts old class names into new class names to preserve compatibility with
+ * pre-Apache namespaces.
+ */
+ @Override
+ protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
+ ObjectStreamClass read = super.readClassDescriptor();
+ if (read.getName().startsWith("com.fs.pxe.")) {
+ return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.pxe.", "org.apache.ode.")));
+ }
+ if (read.getName().startsWith("com.fs.utils.")) {
+ return ObjectStreamClass.lookup(Class.forName(read.getName().replace("com.fs.utils.", "org.apache.ode.utils.")));
+ }
+ return read;
+ }
- /**
- * @param localPart
- */
- OQName(String uri, String local, String prefix){
- this.uri = uri;
- this.local = local;
- this.prefix = prefix;
- }
+ }
+
+ static class OQName implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ final String local;
+ final String uri;
+ final String prefix;
+
+ /**
+ * @param localPart
+ */
+ OQName(String uri, String local, String prefix){
+ this.uri = uri;
+ this.local = local;
+ this.prefix = prefix;
+ }
}
}
Modified: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java?view=diff&rev=464992&r1=464991&r2=464992
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java Tue Oct 17 11:38:35 2006
@@ -164,8 +164,8 @@
public void testEmptyProcess() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- proc.procesScope.activity = new OEmpty(proc);
+ proc.procesScope = new OScope(proc, null);
+ proc.procesScope.activity = new OEmpty(proc, proc.procesScope);
run(proc);
@@ -176,8 +176,8 @@
public void testThrow() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OThrow othrow = new OThrow(proc);
+ proc.procesScope = new OScope(proc, null);
+ OThrow othrow = new OThrow(proc, proc.procesScope);
othrow.faultName = new QName("foo", "bar");
proc.procesScope.activity = othrow;
@@ -190,14 +190,14 @@
public void testFaultHandling() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OThrow othrow = new OThrow(proc);
+ proc.procesScope = new OScope(proc, null);
+ OThrow othrow = new OThrow(proc, proc.procesScope);
othrow.faultName = new QName("foo", "bar");
proc.procesScope.activity = othrow;
proc.procesScope.faultHandler = new OFaultHandler(proc);
- OCatch ocatch = new OCatch(proc);
+ OCatch ocatch = new OCatch(proc, proc.procesScope);
proc.procesScope.faultHandler.catchBlocks.add(ocatch);
- ocatch.activity = new OEmpty(proc);
+ ocatch.activity = new OEmpty(proc, ocatch);
run(proc);
assertTrue(_completedOk);
@@ -207,10 +207,10 @@
public void testOneElementSequence() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OSequence sequence = new OSequence(proc);
+ proc.procesScope = new OScope(proc, null);
+ OSequence sequence = new OSequence(proc, proc.procesScope);
proc.procesScope.activity = sequence;
- sequence.sequence.add(new OEmpty(proc));
+ sequence.sequence.add(new OEmpty(proc, sequence));
run(proc);
@@ -221,11 +221,11 @@
public void testTwoElementSequence() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OSequence sequence = new OSequence(proc);
+ proc.procesScope = new OScope(proc, null);
+ OSequence sequence = new OSequence(proc, proc.procesScope);
proc.procesScope.activity = sequence;
- sequence.sequence.add(new OEmpty(proc));
- sequence.sequence.add(new OEmpty(proc));
+ sequence.sequence.add(new OEmpty(proc, sequence));
+ sequence.sequence.add(new OEmpty(proc, sequence));
run(proc);
@@ -236,8 +236,8 @@
public void testEmptyFlow() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- proc.procesScope.activity = new OFlow(proc);
+ proc.procesScope = new OScope(proc, null);
+ proc.procesScope.activity = new OFlow(proc, proc.procesScope);
run(proc);
@@ -248,10 +248,10 @@
public void testSingleElementFlow() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OFlow flow = new OFlow(proc);
+ proc.procesScope = new OScope(proc, null);
+ OFlow flow = new OFlow(proc, proc.procesScope);
proc.procesScope.activity = flow;
- flow.parallelActivities.add(new OEmpty(proc));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
run(proc);
@@ -262,11 +262,11 @@
public void testTwoElementFlow() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OFlow flow = new OFlow(proc);
+ proc.procesScope = new OScope(proc, null);
+ OFlow flow = new OFlow(proc, proc.procesScope);
proc.procesScope.activity = flow;
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
run(proc);
@@ -277,18 +277,18 @@
public void testFlowTermination() {
OProcess proc = new OProcess("2.0");
- proc.procesScope = new OScope(proc);
- OFlow flow = new OFlow(proc);
+ proc.procesScope = new OScope(proc, null);
+ OFlow flow = new OFlow(proc, proc.procesScope);
proc.procesScope.activity = flow;
- OThrow othrow = new OThrow(proc);
+ OThrow othrow = new OThrow(proc, flow);
othrow.faultName = new QName("foo", "bar");
flow.parallelActivities.add(othrow);
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
- flow.parallelActivities.add(new OEmpty(proc));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
+ flow.parallelActivities.add(new OEmpty(proc, flow));
run(proc);