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/utils/ActDefCache.java | 3 ++- src/main/java/com/c2kernel/utils/CastorArrayList.java | 8 ++++---- src/main/java/com/c2kernel/utils/CastorXMLUtility.java | 17 +++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/c2kernel/utils') diff --git a/src/main/java/com/c2kernel/utils/ActDefCache.java b/src/main/java/com/c2kernel/utils/ActDefCache.java index 0c9fea1..1345e25 100644 --- a/src/main/java/com/c2kernel/utils/ActDefCache.java +++ b/src/main/java/com/c2kernel/utils/ActDefCache.java @@ -12,6 +12,7 @@ import com.c2kernel.lifecycle.ActivityDef; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Viewpoint; +import com.c2kernel.process.Gateway; public class ActDefCache { @@ -34,7 +35,7 @@ public class ActDefCache { throw new ObjectNotFoundException("Problem loading "+actName+" v"+actVersion+": "+ex.getMessage(), ""); } try { - thisActDef = (ActivityDef)CastorXMLUtility.unmarshall(marshalledAct); + thisActDef = (ActivityDef)Gateway.getMarshaller().unmarshall(marshalledAct); } catch (Exception ex) { Logger.error(ex); throw new InvalidDataException("Could not unmarshall '"+actName+"' v"+actVersion+": "+ex.getMessage(), ""); diff --git a/src/main/java/com/c2kernel/utils/CastorArrayList.java b/src/main/java/com/c2kernel/utils/CastorArrayList.java index ea9a090..a7b5d8a 100644 --- a/src/main/java/com/c2kernel/utils/CastorArrayList.java +++ b/src/main/java/com/c2kernel/utils/CastorArrayList.java @@ -15,15 +15,15 @@ import java.util.ArrayList; * All rights reserved. **************************************************************************/ // -abstract public class CastorArrayList implements Serializable { - public ArrayList list; +abstract public class CastorArrayList implements Serializable { + public ArrayList list; public CastorArrayList() { super(); - list = new ArrayList(); + list = new ArrayList(); } - public CastorArrayList(ArrayList list) { + public CastorArrayList(ArrayList list) { this(); this.list = list; } diff --git a/src/main/java/com/c2kernel/utils/CastorXMLUtility.java b/src/main/java/com/c2kernel/utils/CastorXMLUtility.java index 4dca391..6bdc657 100644 --- a/src/main/java/com/c2kernel/utils/CastorXMLUtility.java +++ b/src/main/java/com/c2kernel/utils/CastorXMLUtility.java @@ -27,16 +27,16 @@ import com.c2kernel.persistency.outcome.Outcome; **************************************************************************/ public class CastorXMLUtility { - private static Mapping mMapping = new Mapping(); - private static HashSet mMappingKeys = new HashSet(); - + private final Mapping mMapping = new Mapping(); + private final HashSet mMappingKeys = new HashSet(); + /** * Looks for a file called 'index.xml' at the given URL, and loads every file * listed in there by relative path * * @param mapURL - map root - */ - static public void loadMapsFrom(URL mapURL) throws InvalidDataException { + */ + public CastorXMLUtility(URL mapURL) throws InvalidDataException { // load index.xml Logger.msg(3, "Loading maps from "+mapURL); String index; @@ -60,12 +60,13 @@ public class CastorXMLUtility Logger.msg("Loaded all maps from "+mapURL.toString()); } + /************************************************************************** * Updates a mapping referenced by the mapID. * The same mapping cannot be loaded many times as it generates an exception. * That is the reason for this method as it maintains the HashSet of MappingKeys. **************************************************************************/ - static public void addMapping( URL mapID ) + public void addMapping( URL mapID ) throws IOException, MappingException, MarshalException, @@ -89,7 +90,7 @@ public class CastorXMLUtility * Marshalls a mapped object to string. The mapping must be loaded before. * See updateMapping(). **************************************************************************/ - static public String marshall( Object obj ) + public String marshall( Object obj ) throws IOException, MappingException, MarshalException, @@ -112,7 +113,7 @@ public class CastorXMLUtility * Unmarshalls a mapped object from string. The mapping must be loaded before. * See updateMapping(). **************************************************************************/ - static public Object unmarshall( String data ) + public Object unmarshall( String data ) throws IOException, MappingException, MarshalException, -- cgit v1.2.3