modification in serialize api. needs review...
Project: http://git-wip-us.apache.org/repos/asf/ode/repo Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/b4dc6266 Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/b4dc6266 Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/b4dc6266 Branch: refs/heads/master Commit: b4dc6266b5f97acc64e173287cb1a235c079f567 Parents: e54b5be Author: fangzhen <[email protected]> Authored: Tue Jul 29 15:55:47 2014 +0800 Committer: fangzhen <[email protected]> Committed: Tue Jul 29 15:55:47 2014 +0800 ---------------------------------------------------------------------- .../org/apache/ode/bpel/compiler/BpelC.java | 8 +- .../ode/bpel/compiler_2_0/GoodCompileTest.java | 569 ++++++++++--------- .../bpel/obj/serde/JavaSerOmDeserializer.java | 19 +- .../ode/bpel/obj/serde/JsonOmDeserializer.java | 15 +- .../ode/bpel/obj/serde/OmDeserializer.java | 8 +- .../ode/bpel/obj/serde/OmSerdeFactory.java | 7 +- .../ode/bpel/obj/serde/SerializerTest.java | 15 +- .../org/apache/ode/bpel/engine/BpelProcess.java | 3 +- .../org/apache/ode/store/DeploymentUnitDir.java | 6 +- .../java/org/apache/ode/jbi/OdeContext.java | 3 +- 10 files changed, 343 insertions(+), 310 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java ---------------------------------------------------------------------- diff --git a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java index c5362a0..c3ce971 100644 --- a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java +++ b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelC.java @@ -285,9 +285,7 @@ public class BpelC { } try { - OProcessWrapper wrapper = new OProcessWrapper(System.currentTimeMillis()); - wrapper.setProcess(oprocess); - OmSerializer serializer = new OmSerdeFactory().createOmSerializer(_outputStream, wrapper); + OmSerializer serializer = new OmSerdeFactory().createOmSerializer(_outputStream, oprocess); serializer.serialize(); } finally { // close & mark myself invalid @@ -440,9 +438,7 @@ public class BpelC { } try { - OProcessWrapper wrapper = new OProcessWrapper(System.currentTimeMillis()); - wrapper.setProcess(oprocess); - OmSerializer serializer = new OmSerdeFactory().createOmSerializer(_outputStream, wrapper); + OmSerializer serializer = new OmSerdeFactory().createOmSerializer(_outputStream, oprocess); serializer.serialize(); } finally { // close & mark myself invalid http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java ---------------------------------------------------------------------- diff --git a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java index ab23b01..10195f3 100644 --- a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java +++ b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java @@ -19,6 +19,8 @@ package org.apache.ode.bpel.compiler_2_0; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.FileInputStream; import java.net.URI; @@ -26,287 +28,298 @@ import java.net.URL; import org.apache.ode.bpel.compiler.api.CompileListener; import org.apache.ode.bpel.obj.OProcess; -import org.apache.ode.bpel.obj.OProcessWrapper; +import org.apache.ode.bpel.obj.migrate.EqualityVisitor; +import org.apache.ode.bpel.obj.migrate.ExtensibeImplEqualityComp; +import org.apache.ode.bpel.obj.migrate.TraverseObject; import org.apache.ode.bpel.obj.serde.OmDeserializer; import org.apache.ode.bpel.obj.serde.OmSerdeFactory; import org.junit.Assert; import org.junit.Test; -public class GoodCompileTest extends AbstractCompileTestCase implements CompileListener { - - public void runTest(String bpel) throws Exception { - try { - Class testClass = getClass(); - URL url = testClass.getResource(bpel); - URI uri = url.toURI(); - String path = uri.getPath(); - File bpelFile = new File(path); - OProcess origi = _compiler.compile2OProcess(bpelFile, 0); - String bpelPath = bpelFile.getAbsolutePath(); - String cbpPath = bpelPath.substring(0, bpelPath.lastIndexOf(".")) + ".cbp"; - _compiler.serializeOProcess(origi, cbpPath); - - OmDeserializer deserializer = new OmSerdeFactory().createOmDeserializer(new FileInputStream(cbpPath)); - OProcessWrapper wrapper = deserializer.deserialize(); - wrapper.getProcess(); - } catch (Exception ex) { - ex.printStackTrace(); - Assert.fail("Compilation or deserialization did not succeed."); - } - } - - @Test - public void testAssign1_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign1-2.0.bpel"); - } - - @Test - public void testAssign2_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign2-2.0.bpel"); - } - - @Test - public void testAssign3_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign3-2.0.bpel"); - } - - @Test - public void testAssign5_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign5-2.0.bpel"); - } - - @Test - public void testAssign6_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign6-2.0.bpel"); - } - - @Test - public void testAssign7_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign7-2.0.bpel"); - } - - @Test - public void testAssign8_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign8-2.0.bpel"); - } - - @Test - public void testAssign9_BPEL20() throws Exception { - runTest("/2.0/good/assign/Assign9-2.0.bpel"); - } - - @Test - public void testAsyncProcess() throws Exception { - runTest("/2.0/good/AsyncProcess/AsyncProcess2.bpel"); - } - - @Test - public void testCompensation1() throws Exception { - runTest("/2.0/good/compensation/comp1-2.0.bpel"); - } - - @Test - public void testCompensation2() throws Exception { - runTest("/2.0/good/compensation/comp2-2.0.bpel"); - } - - @Test - public void testFlow2() throws Exception { - runTest("/2.0/good/flow/flow2-2.0.bpel"); - } - - @Test - public void testFlow3() throws Exception { - runTest("/2.0/good/flow/flow3-2.0.bpel"); - } - - @Test - public void testFlow4() throws Exception { - runTest("/2.0/good/flow/flow4-2.0.bpel"); - } - - @Test - public void testFlow5() throws Exception { - runTest("/2.0/good/flow/flow5-2.0.bpel"); - } - - @Test - public void testFlow6() throws Exception { - runTest("/2.0/good/flow/flow6-2.0.bpel"); - } - - @Test - public void testFlow7() throws Exception { - runTest("/2.0/good/flow/flow7-2.0.bpel"); - } - - @Test - public void testForEach1() throws Exception { - runTest("/2.0/good/foreach/ForEach1-2.0.bpel"); - } - - @Test - public void testForEach2() throws Exception { - runTest("/2.0/good/foreach/ForEach2-2.0.bpel"); - } - - @Test - public void testForEach3() throws Exception { - runTest("/2.0/good/foreach/ForEach3-2.0.bpel"); - } - - @Test - public void testIf1() throws Exception { - runTest("/2.0/good/if/If1-2.0.bpel"); - } - - @Test - public void testIf2() throws Exception { - runTest("/2.0/good/if/If2-2.0.bpel"); - } - - @Test - public void testIf3() throws Exception { - runTest("/2.0/good/if/If3-2.0.bpel"); - } - - @Test - public void testPick3() throws Exception { - runTest("/2.0/good/pick/Pick3-2.0.bpel"); - } - - @Test - public void testPick4() throws Exception { - runTest("/2.0/good/pick/Pick4-2.0.bpel"); - } - - @Test - public void testPick5() throws Exception { - runTest("/2.0/good/pick/Pick5-2.0.bpel"); - } - - @Test - public void testPick6() throws Exception { - runTest("/2.0/good/pick/Pick6-2.0.bpel"); - } - - @Test - public void testRethrow1() throws Exception { - runTest("/2.0/good/rethrow/Rethrow1-2.0.bpel"); - } - - @Test - public void testRethrow2() throws Exception { - runTest("/2.0/good/rethrow/Rethrow2-2.0.bpel"); - } - - @Test - public void testThrow1() throws Exception { - runTest("/2.0/good/throw/Throw1-2.0.bpel"); - } - - @Test - public void testThrow2() throws Exception { - runTest("/2.0/good/throw/Throw2-2.0.bpel"); - } - - @Test - public void testThrow3() throws Exception { - runTest("/2.0/good/throw/Throw3-2.0.bpel"); - } - - @Test - public void testThrow4() throws Exception { - runTest("/2.0/good/throw/Throw4-2.0.bpel"); - } - - @Test - public void testThrow5() throws Exception { - runTest("/2.0/good/throw/Throw5-2.0.bpel"); - } - - @Test - public void testThrow6() throws Exception { - runTest("/2.0/good/throw/Throw6-2.0.bpel"); - } - - @Test - public void testThrow7() throws Exception { - runTest("/2.0/good/throw/Throw7-2.0.bpel"); - } - - @Test - public void testWait1() throws Exception { - runTest("/2.0/good/wait/Wait1-2.0.bpel"); - } - - @Test - public void testWait2() throws Exception { - runTest("/2.0/good/wait/Wait2-2.0.bpel"); - } - - @Test - public void testWhile() throws Exception { - runTest("/2.0/good/while/While1-2.0.bpel"); - } - - @Test - public void testXPath10GetVariableData1() throws Exception { - runTest("/2.0/good/xpath10-func/GetVariableData1-2.0.bpel"); - } - - @Test - public void testXPath10GetVariableData2() throws Exception { - runTest("/2.0/good/xpath10-func/GetVariableData2-2.0.bpel"); - } - - @Test - public void testXPath10GetVariableData3() throws Exception { - runTest("/2.0/good/xpath10-func/GetVariableData3-2.0.bpel"); - } - - @Test - public void testXPath10GetVariableData4() throws Exception { - runTest("/2.0/good/xpath10-func/GetVariableData4-2.0.bpel"); - } - - @Test - public void testXPath10GetVariableProperty1() throws Exception { - runTest("/2.0/good/xpath10-func/GetVariableProperty1-2.0.bpel"); - } - - @Test - public void testXPath20GetVariableData2() throws Exception { - runTest("/2.0/good/xpath20-func/GetVariableData2-xp2.0.bpel"); - } - - @Test - public void testXPath20GetVariableData3() throws Exception { - runTest("/2.0/good/xpath20-func/GetVariableData3-xp2.0.bpel"); - } - - @Test - public void testXPath20GetVariableData4() throws Exception { - runTest("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel"); - } - - @Test - public void testXPath20GetVariableProperty1() throws Exception { - runTest("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel"); - } - - @Test - public void testXSDImport() throws Exception { - runTest("/2.0/good/xsd-import/helloworld-Server.bpel"); - } - - @Test - public void testCircularReference() throws Exception { - runTest("/2.0/good/circularReference/CircularReference.bpel"); - } - - @Test - public void testMultipleEmbeddedSchemas() throws Exception { - runTest("/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel"); - } +public class GoodCompileTest extends AbstractCompileTestCase implements + CompileListener { + + public void runTest(String bpel) throws Exception { + try { + Class testClass = getClass(); + URL url = testClass.getResource(bpel); + URI uri = url.toURI(); + String path = uri.getPath(); + File bpelFile = new File(path); + OProcess origi = _compiler.compile2OProcess(bpelFile, 0); + String bpelPath = bpelFile.getAbsolutePath(); + String cbpPath = bpelPath.substring(0, bpelPath.lastIndexOf(".")) + + ".cbp"; + _compiler.serializeOProcess(origi, cbpPath); + + OmDeserializer deserializer = new OmSerdeFactory() + .createOmDeserializer(new FileInputStream(cbpPath)); + OProcess desered = deserializer.deserialize(); + + TraverseObject traverse = new TraverseObject(); + EqualityVisitor visitor = new EqualityVisitor(desered); + visitor.addCustomComparator(new ExtensibeImplEqualityComp(visitor)); + traverse.accept(visitor); + boolean res = (Boolean) traverse.traverseObject(origi); + assertEquals(Boolean.TRUE, res); + } catch (Exception ex) { + ex.printStackTrace(); + Assert.fail("Compilation or deserialization did not succeed."); + } + } + + @Test + public void testAssign1_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign1-2.0.bpel"); + } + + @Test + public void testAssign2_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign2-2.0.bpel"); + } + + @Test + public void testAssign3_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign3-2.0.bpel"); + } + + @Test + public void testAssign5_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign5-2.0.bpel"); + } + + @Test + public void testAssign6_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign6-2.0.bpel"); + } + + @Test + public void testAssign7_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign7-2.0.bpel"); + } + + @Test + public void testAssign8_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign8-2.0.bpel"); + } + + @Test + public void testAssign9_BPEL20() throws Exception { + runTest("/2.0/good/assign/Assign9-2.0.bpel"); + } + + @Test + public void testAsyncProcess() throws Exception { + runTest("/2.0/good/AsyncProcess/AsyncProcess2.bpel"); + } + + @Test + public void testCompensation1() throws Exception { + runTest("/2.0/good/compensation/comp1-2.0.bpel"); + } + + @Test + public void testCompensation2() throws Exception { + runTest("/2.0/good/compensation/comp2-2.0.bpel"); + } + + @Test + public void testFlow2() throws Exception { + runTest("/2.0/good/flow/flow2-2.0.bpel"); + } + + @Test + public void testFlow3() throws Exception { + runTest("/2.0/good/flow/flow3-2.0.bpel"); + } + + @Test + public void testFlow4() throws Exception { + runTest("/2.0/good/flow/flow4-2.0.bpel"); + } + + @Test + public void testFlow5() throws Exception { + runTest("/2.0/good/flow/flow5-2.0.bpel"); + } + + @Test + public void testFlow6() throws Exception { + runTest("/2.0/good/flow/flow6-2.0.bpel"); + } + + @Test + public void testFlow7() throws Exception { + runTest("/2.0/good/flow/flow7-2.0.bpel"); + } + + @Test + public void testForEach1() throws Exception { + runTest("/2.0/good/foreach/ForEach1-2.0.bpel"); + } + + @Test + public void testForEach2() throws Exception { + runTest("/2.0/good/foreach/ForEach2-2.0.bpel"); + } + + @Test + public void testForEach3() throws Exception { + runTest("/2.0/good/foreach/ForEach3-2.0.bpel"); + } + + @Test + public void testIf1() throws Exception { + runTest("/2.0/good/if/If1-2.0.bpel"); + } + + @Test + public void testIf2() throws Exception { + runTest("/2.0/good/if/If2-2.0.bpel"); + } + + @Test + public void testIf3() throws Exception { + runTest("/2.0/good/if/If3-2.0.bpel"); + } + + @Test + public void testPick3() throws Exception { + runTest("/2.0/good/pick/Pick3-2.0.bpel"); + } + + @Test + public void testPick4() throws Exception { + runTest("/2.0/good/pick/Pick4-2.0.bpel"); + } + + @Test + public void testPick5() throws Exception { + runTest("/2.0/good/pick/Pick5-2.0.bpel"); + } + + @Test + public void testPick6() throws Exception { + runTest("/2.0/good/pick/Pick6-2.0.bpel"); + } + + @Test + public void testRethrow1() throws Exception { + runTest("/2.0/good/rethrow/Rethrow1-2.0.bpel"); + } + + @Test + public void testRethrow2() throws Exception { + runTest("/2.0/good/rethrow/Rethrow2-2.0.bpel"); + } + + @Test + public void testThrow1() throws Exception { + runTest("/2.0/good/throw/Throw1-2.0.bpel"); + } + + @Test + public void testThrow2() throws Exception { + runTest("/2.0/good/throw/Throw2-2.0.bpel"); + } + + @Test + public void testThrow3() throws Exception { + runTest("/2.0/good/throw/Throw3-2.0.bpel"); + } + + @Test + public void testThrow4() throws Exception { + runTest("/2.0/good/throw/Throw4-2.0.bpel"); + } + + @Test + public void testThrow5() throws Exception { + runTest("/2.0/good/throw/Throw5-2.0.bpel"); + } + + @Test + public void testThrow6() throws Exception { + runTest("/2.0/good/throw/Throw6-2.0.bpel"); + } + + @Test + public void testThrow7() throws Exception { + runTest("/2.0/good/throw/Throw7-2.0.bpel"); + } + + @Test + public void testWait1() throws Exception { + runTest("/2.0/good/wait/Wait1-2.0.bpel"); + } + + @Test + public void testWait2() throws Exception { + runTest("/2.0/good/wait/Wait2-2.0.bpel"); + } + + @Test + public void testWhile() throws Exception { + runTest("/2.0/good/while/While1-2.0.bpel"); + } + + @Test + public void testXPath10GetVariableData1() throws Exception { + runTest("/2.0/good/xpath10-func/GetVariableData1-2.0.bpel"); + } + + @Test + public void testXPath10GetVariableData2() throws Exception { + runTest("/2.0/good/xpath10-func/GetVariableData2-2.0.bpel"); + } + + @Test + public void testXPath10GetVariableData3() throws Exception { + runTest("/2.0/good/xpath10-func/GetVariableData3-2.0.bpel"); + } + + @Test + public void testXPath10GetVariableData4() throws Exception { + runTest("/2.0/good/xpath10-func/GetVariableData4-2.0.bpel"); + } + + @Test + public void testXPath10GetVariableProperty1() throws Exception { + runTest("/2.0/good/xpath10-func/GetVariableProperty1-2.0.bpel"); + } + + @Test + public void testXPath20GetVariableData2() throws Exception { + runTest("/2.0/good/xpath20-func/GetVariableData2-xp2.0.bpel"); + } + + @Test + public void testXPath20GetVariableData3() throws Exception { + runTest("/2.0/good/xpath20-func/GetVariableData3-xp2.0.bpel"); + } + + @Test + public void testXPath20GetVariableData4() throws Exception { + runTest("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel"); + } + + @Test + public void testXPath20GetVariableProperty1() throws Exception { + runTest("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel"); + } + + @Test + public void testXSDImport() throws Exception { + runTest("/2.0/good/xsd-import/helloworld-Server.bpel"); + } + + @Test + public void testCircularReference() throws Exception { + runTest("/2.0/good/circularReference/CircularReference.bpel"); + } + + @Test + public void testMultipleEmbeddedSchemas() throws Exception { + runTest("/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel"); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JavaSerOmDeserializer.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JavaSerOmDeserializer.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JavaSerOmDeserializer.java index e161b4e..1d47bdf 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JavaSerOmDeserializer.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JavaSerOmDeserializer.java @@ -4,16 +4,28 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; +import javax.xml.namespace.QName; + +import org.apache.ode.bpel.obj.OProcess; import org.apache.ode.bpel.obj.OProcessWrapper; public class JavaSerOmDeserializer implements OmDeserializer { private InputStream is; + OProcessWrapper wrapper; public JavaSerOmDeserializer(InputStream is) { this.is = is; } - + + @Override + public QName getType(){ + return wrapper.getType(); + } + @Override + public String getGuid(){ + return wrapper.getGuid(); + } @Override - public OProcessWrapper deserialize() throws IOException, + public OProcess deserialize() throws IOException, SerializaionRtException { ObjectInputStream ois = new ObjectInputStream(is); OProcessWrapper wrapper = null; @@ -24,7 +36,8 @@ public class JavaSerOmDeserializer implements OmDeserializer { se.initCause(e); throw se; } - return wrapper; + this.wrapper = wrapper; + return wrapper.getProcess(); } } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JsonOmDeserializer.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JsonOmDeserializer.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JsonOmDeserializer.java index 3141c0a..ced94fb 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JsonOmDeserializer.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/JsonOmDeserializer.java @@ -11,6 +11,7 @@ import javax.xml.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ode.bpel.obj.OProcess; import org.apache.ode.bpel.obj.OProcessWrapper; import org.apache.ode.bpel.obj.serde.jacksonhack.TypeBeanSerializerFactory; import org.apache.ode.utils.NSContext; @@ -62,7 +63,7 @@ public class JsonOmDeserializer implements OmDeserializer { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) - public OProcessWrapper deserialize() throws IOException, + public OProcess deserialize() throws IOException, SerializaionRtException { mapper = new ObjectMapper(factory); mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); @@ -78,7 +79,7 @@ public class JsonOmDeserializer implements OmDeserializer { mapper.registerModule(simpleModule); wrapper = mapper.readValue(is, OProcessWrapper.class); - return wrapper; + return wrapper.getProcess(); } public void addCustomDeserializer(Class<?> c, JsonDeserializer<?> sd) { @@ -185,4 +186,14 @@ public class JsonOmDeserializer implements OmDeserializer { } } + + @Override + public String getGuid() { + return wrapper.getGuid(); + } + + @Override + public QName getType() { + return wrapper.getType(); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmDeserializer.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmDeserializer.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmDeserializer.java index 77a67b1..6fece8e 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmDeserializer.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmDeserializer.java @@ -2,8 +2,14 @@ package org.apache.ode.bpel.obj.serde; import java.io.IOException; +import javax.xml.namespace.QName; + +import org.apache.ode.bpel.obj.OProcess; import org.apache.ode.bpel.obj.OProcessWrapper; public interface OmDeserializer { - public OProcessWrapper deserialize() throws IOException, SerializaionRtException; + public OProcess deserialize() throws IOException, SerializaionRtException; + + String getGuid(); + QName getType(); } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmSerdeFactory.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmSerdeFactory.java b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmSerdeFactory.java index 5169442..444382f 100644 --- a/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmSerdeFactory.java +++ b/bpel-nobj/src/main/java/org/apache/ode/bpel/obj/serde/OmSerdeFactory.java @@ -3,6 +3,7 @@ package org.apache.ode.bpel.obj.serde; import java.io.InputStream; import java.io.OutputStream; +import org.apache.ode.bpel.obj.OProcess; import org.apache.ode.bpel.obj.OProcessWrapper; public class OmSerdeFactory { @@ -11,8 +12,10 @@ public class OmSerdeFactory { private SerializeFormat format = FORMAT_SERIALIZED_DEFAULT; - public OmSerializer createOmSerializer(OutputStream out, OProcessWrapper wrapper){ - OmSerializer serializer = null; + public OmSerializer createOmSerializer(OutputStream out, OProcess process){ + OProcessWrapper wrapper = new OProcessWrapper(System.currentTimeMillis()); + wrapper.setProcess(process); + OmSerializer serializer; switch (format) { case FORMAT_SERIALIZED_JSON: serializer = new JsonOmSerializer(out, wrapper); http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-nobj/src/test/java/org/apache/ode/bpel/obj/serde/SerializerTest.java ---------------------------------------------------------------------- diff --git a/bpel-nobj/src/test/java/org/apache/ode/bpel/obj/serde/SerializerTest.java b/bpel-nobj/src/test/java/org/apache/ode/bpel/obj/serde/SerializerTest.java index b9f20a7..e6aefe9 100644 --- a/bpel-nobj/src/test/java/org/apache/ode/bpel/obj/serde/SerializerTest.java +++ b/bpel-nobj/src/test/java/org/apache/ode/bpel/obj/serde/SerializerTest.java @@ -1,6 +1,5 @@ package org.apache.ode.bpel.obj.serde; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.io.BufferedInputStream; @@ -8,10 +7,8 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Date; import org.apache.ode.bpel.obj.OProcess; -import org.apache.ode.bpel.obj.OProcessWrapper; import org.junit.Test; public class SerializerTest { @@ -19,19 +16,15 @@ public class SerializerTest { @Test public void testBasicSerialize() throws IOException { OmSerdeFactory serdeFactory = new OmSerdeFactory(); - OProcessWrapper wrapper = new OProcessWrapper(new Date().getTime()); - wrapper.setProcess(new OProcess("0")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - OmSerializer omSerializer = serdeFactory.createOmSerializer(baos, wrapper); + OProcess original = new OProcess("0"); + OmSerializer omSerializer = serdeFactory.createOmSerializer(baos, original); omSerializer.serialize(); InputStream is = new BufferedInputStream(new ByteArrayInputStream(baos .toByteArray())); OmDeserializer omDeserializer = serdeFactory.createOmDeserializer(is); - OProcessWrapper wrapper2 = omDeserializer.deserialize(); - - assertArrayEquals(wrapper.getMagic(), wrapper2.getMagic()); - assertEquals(wrapper.getFormat(), wrapper2.getFormat()); - assertEquals(wrapper.getProcess().getFieldContainer(), wrapper2.getProcess().getFieldContainer()); + OProcess desered = omDeserializer.deserialize(); + assertEquals(original.getFieldContainer(), desered.getFieldContainer()); } } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java index b44611e..84ccd35 100644 --- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java +++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java @@ -565,8 +565,7 @@ public class BpelProcess { private OProcess deserializeCompiledProcess(InputStream is) throws Exception { OProcess compiledProcess; OmDeserializer deserializer = new OmSerdeFactory().createOmDeserializer(is); - OProcessWrapper wrapper = deserializer.deserialize(); - compiledProcess = wrapper.getProcess(); + compiledProcess = deserializer.deserialize(); return compiledProcess; } http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java ---------------------------------------------------------------------- diff --git a/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java b/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java index 0e6153d..9fdbc2b 100644 --- a/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java +++ b/bpel-store/src/main/java/org/apache/ode/store/DeploymentUnitDir.java @@ -50,7 +50,7 @@ import org.apache.ode.bpel.dd.DeployDocument; import org.apache.ode.bpel.dd.TDeployment; import org.apache.ode.bpel.dd.TDeployment.Process; import org.apache.ode.bpel.iapi.ContextException; -import org.apache.ode.bpel.obj.OProcessWrapper; +import org.apache.ode.bpel.obj.OProcess; import org.apache.ode.bpel.obj.serde.OmDeserializer; import org.apache.ode.bpel.obj.serde.OmSerdeFactory; import org.apache.ode.utils.InternPool; @@ -219,8 +219,8 @@ class DeploymentUnitDir { try { is = new FileInputStream(f); OmDeserializer deserializer = new OmSerdeFactory().createOmDeserializer(is); - OProcessWrapper wrapper = deserializer.deserialize(); - CBPInfo info = new CBPInfo(wrapper.getType(), wrapper.getGuid(), f); + OProcess process = deserializer.deserialize(); + CBPInfo info = new CBPInfo(deserializer.getType(),deserializer.getGuid(), f); // Serializer ofh = new Serializer(is); // CBPInfo info = new CBPInfo(ofh.getType(), ofh.getGuid(), f); return info; http://git-wip-us.apache.org/repos/asf/ode/blob/b4dc6266/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java ---------------------------------------------------------------------- diff --git a/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java b/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java index 5a90500..77fce97 100644 --- a/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java +++ b/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java @@ -201,8 +201,7 @@ final public class OdeContext { OProcess compiledProcess = null; try { OmDeserializer deserializer = new OmSerdeFactory().createOmDeserializer(is); - OProcessWrapper wrapper = deserializer.deserialize(); - compiledProcess = wrapper.getProcess(); + compiledProcess = deserializer.deserialize(); } finally { is.close(); }
