From 24314dc1699c7e73048fa24e33729f1aa1ec0e86 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 6 Jul 2012 11:00:24 +0200 Subject: Modules serialize with Castor. Just about to remove the parsing. CastorXMLUtility is now a static member of gateway. Domain specific instances can be used by domain applications, but the maps do not interfere with the kernel. --- src/main/java/com/c2kernel/entity/TraceableEntity.java | 15 +++++++-------- src/main/java/com/c2kernel/entity/agent/ActiveEntity.java | 7 +++---- src/main/java/com/c2kernel/entity/proxy/AgentProxy.java | 7 +++---- src/main/java/com/c2kernel/entity/proxy/EntityProxy.java | 3 +-- src/main/java/com/c2kernel/entity/proxy/ItemProxy.java | 4 ++-- .../java/com/c2kernel/entity/transfer/TransferItem.java | 7 +++---- .../java/com/c2kernel/entity/transfer/TransferSet.java | 3 +-- 7 files changed, 20 insertions(+), 26 deletions(-) (limited to 'src/main/java/com/c2kernel/entity') diff --git a/src/main/java/com/c2kernel/entity/TraceableEntity.java b/src/main/java/com/c2kernel/entity/TraceableEntity.java index c7aff82..93f9407 100644 --- a/src/main/java/com/c2kernel/entity/TraceableEntity.java +++ b/src/main/java/com/c2kernel/entity/TraceableEntity.java @@ -30,7 +30,6 @@ import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.Logger; /************************************************************************** @@ -64,9 +63,9 @@ import com.c2kernel.utils.Logger; public class TraceableEntity extends ItemPOA { - private int mSystemKey; - private org.omg.PortableServer.POA mPoa; - private TransactionManager mStorage; + private final int mSystemKey; + private final org.omg.PortableServer.POA mPoa; + private final TransactionManager mStorage; /************************************************************************** @@ -135,7 +134,7 @@ public class TraceableEntity extends ItemPOA // create properties if (!propString.equals("")) { try { - props = (PropertyArrayList)CastorXMLUtility.unmarshall(propString); + props = (PropertyArrayList)Gateway.getMarshaller().unmarshall(propString); for (Object name : props.list) { Property thisProp = (Property)name; mStorage.put(mSystemKey, thisProp, props); @@ -153,7 +152,7 @@ public class TraceableEntity extends ItemPOA if (initWfString == null || initWfString.equals("")) lc = new Workflow(new CompositeActivity()); else - lc = new Workflow((CompositeActivity)CastorXMLUtility.unmarshall(initWfString)); + lc = new Workflow((CompositeActivity)Gateway.getMarshaller().unmarshall(initWfString)); lc.initialise(mSystemKey, agentPath); mStorage.put(mSystemKey, lc, null); } catch (Throwable ex) { @@ -254,7 +253,7 @@ public class TraceableEntity extends ItemPOA CompositeActivity domainWf = (CompositeActivity)wf.search("workflow/domain"); jobBag.list = filter?domainWf.calculateJobs(agent, true):domainWf.calculateAllJobs(agent, true); Logger.msg(1, "TraceableEntity::queryLifeCycle("+mSystemKey+") - Returning "+jobBag.list.size()+" jobs."); - return CastorXMLUtility.marshall( jobBag ); + return Gateway.getMarshaller().marshall( jobBag ); } catch( Throwable ex ) { @@ -309,7 +308,7 @@ public class TraceableEntity extends ItemPOA C2KLocalObject obj = mStorage.get( mSystemKey, path, null ); // marshall it, or in the case of an outcome get the data. - result = CastorXMLUtility.marshall(obj); + result = Gateway.getMarshaller().marshall(obj); } } catch (ObjectNotFoundException ex) { diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java index 3d45e35..d20fc1e 100644 --- a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java +++ b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java @@ -28,7 +28,6 @@ import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.Logger; /************************************************************************** @@ -123,7 +122,7 @@ public class ActiveEntity extends AgentPOA { try { - props = (PropertyArrayList)CastorXMLUtility.unmarshall(propsString); + props = (PropertyArrayList)Gateway.getMarshaller().unmarshall(propsString); } catch( Exception ex ) { @@ -207,7 +206,7 @@ public class ActiveEntity extends AgentPOA { C2KLocalObject obj = mDatabase.get( mSystemKey, xpath, null ); - result = CastorXMLUtility.marshall(obj); + result = Gateway.getMarshaller().marshall(obj); } } @@ -236,7 +235,7 @@ public class ActiveEntity extends AgentPOA @Override public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) { try { - JobArrayList newJobList = (JobArrayList)CastorXMLUtility.unmarshall(newJobs); + JobArrayList newJobList = (JobArrayList)Gateway.getMarshaller().unmarshall(newJobs); // get our joblist if (currentJobs == null) diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 29cd13b..5c6a37e 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -37,7 +37,6 @@ import com.c2kernel.process.Gateway; import com.c2kernel.scripting.ErrorInfo; import com.c2kernel.scripting.Script; import com.c2kernel.scripting.ScriptingEngineException; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.LocalObjectLoader; import com.c2kernel.utils.Logger; @@ -186,7 +185,7 @@ public class AgentProxy extends EntityProxy } } - public Object callScript(ItemProxy item, Job job) throws ScriptingEngineException { + private Object callScript(ItemProxy item, Job job) throws ScriptingEngineException { Script script = new Script(item, this, job); return script.execute(); } @@ -263,11 +262,11 @@ public class AgentProxy extends EntityProxy /** Wrappers for scripts */ public String marshall(Object obj) throws Exception { - return CastorXMLUtility.marshall(obj); + return Gateway.getMarshaller().marshall(obj); } public Object unmarshall(String obj) throws Exception { - return CastorXMLUtility.unmarshall(obj); + return Gateway.getMarshaller().unmarshall(obj); } /** Let scripts resolve items */ diff --git a/src/main/java/com/c2kernel/entity/proxy/EntityProxy.java b/src/main/java/com/c2kernel/entity/proxy/EntityProxy.java index fae2e28..cb76a19 100644 --- a/src/main/java/com/c2kernel/entity/proxy/EntityProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/EntityProxy.java @@ -19,7 +19,6 @@ import com.c2kernel.entity.ManageableEntity; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.Logger; @@ -113,7 +112,7 @@ abstract public class EntityProxy implements ManageableEntity return retString.toString(); } C2KLocalObject target = Gateway.getStorage().get(mSystemKey, path, null); - return CastorXMLUtility.marshall(target); + return Gateway.getMarshaller().marshall(target); } catch (ObjectNotFoundException e) { throw e; } catch (Exception e) { diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java index 658e0c8..dcaef55 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java @@ -24,7 +24,7 @@ import com.c2kernel.entity.ManageableEntity; import com.c2kernel.entity.agent.Job; import com.c2kernel.entity.agent.JobArrayList; import com.c2kernel.lifecycle.instance.stateMachine.Transitions; -import com.c2kernel.utils.CastorXMLUtility; +import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; /****************************************************************************** @@ -163,7 +163,7 @@ public class ItemProxy extends EntityProxy JobArrayList thisJobList; try { String jobs = queryLifeCycle(agentId, filter); - thisJobList = (JobArrayList)CastorXMLUtility.unmarshall(jobs); + thisJobList = (JobArrayList)Gateway.getMarshaller().unmarshall(jobs); } catch (Exception e) { Logger.error(e); diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java index 0e3b764..520063a 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java @@ -16,7 +16,6 @@ import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; @@ -58,7 +57,7 @@ public class TransferItem { C2KLocalObject obj = Gateway.getStorage().get(sysKey, path, null); Logger.msg("Dumping object " + path + " in " + sysKey); File dumpPath = new File(dir.getCanonicalPath() + ".xml"); - FileStringUtility.string2File(dumpPath, CastorXMLUtility.marshall(obj)); + FileStringUtility.string2File(dumpPath, Gateway.getMarshaller().marshall(obj)); return; } catch (ObjectNotFoundException ex) { } // not an object @@ -84,7 +83,7 @@ public class TransferItem { if (choppedPath.startsWith(ClusterStorage.OUTCOME)) newObj = new Outcome(choppedPath, xmlFile); else - newObj = (C2KLocalObject)CastorXMLUtility.unmarshall(xmlFile); + newObj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(xmlFile); objects.add(newObj); } @@ -108,7 +107,7 @@ public class TransferItem { throw new Exception("No workflow found in import for "+sysKey); // init item - newItem.initialise(importAgentId, CastorXMLUtility.marshall(props), CastorXMLUtility.marshall(wf.search("workflow/domain"))); + newItem.initialise(importAgentId, Gateway.getMarshaller().marshall(props), Gateway.getMarshaller().marshall(wf.search("workflow/domain"))); // store objects importByType(ClusterStorage.COLLECTION, objects); diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java index 71a593a..7a3ba2e 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import com.c2kernel.lookup.EntityPath; import com.c2kernel.lookup.NextKeyManager; import com.c2kernel.process.Gateway; -import com.c2kernel.utils.CastorXMLUtility; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; @@ -52,7 +51,7 @@ public class TransferSet { } try { - String self = CastorXMLUtility.marshall(this); + String self = Gateway.getMarshaller().marshall(this); FileStringUtility.string2File(new File(dir, "transferSet.xml"), self); } catch (Exception ex) { Logger.error("Error writing header file"); -- cgit v1.2.3