Author: pferraro
Date: 2008-10-31 00:18:51 -0400 (Fri, 31 Oct 2008)
New Revision: 2036
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Add custom serialization for EngineStatusImpl
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-31
04:18:33 UTC (rev 2035)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-31
04:18:51 UTC (rev 2036)
@@ -24,8 +24,11 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.io.Writer;
@@ -1194,11 +1197,16 @@
}
}
- class EngineStatusImpl implements ResetRequestSource.EngineStatus
+ static class EngineStatusImpl implements ResetRequestSource.EngineStatus,
Externalizable
{
- private Set<String> aliases = new LinkedHashSet<String>();
- private Map<String, ResetRequestSource.Status> contexts = new
HashMap<String, ResetRequestSource.Status>();
+ private final Set<String> aliases = new LinkedHashSet<String>();
+ private final Map<String, ResetRequestSource.Status> contexts = new
HashMap<String, ResetRequestSource.Status>();
+ public EngineStatusImpl()
+ {
+ // Expose for deserialization
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.mcmp.ResetRequestSource.EngineStatus#getAliases()
@@ -1216,5 +1224,48 @@
{
return this.contexts;
}
+
+ /**
+ * @{inheritDoc}
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput input) throws IOException
+ {
+ int aliases = input.readInt();
+ for (int i = 0; i < aliases; ++i)
+ {
+ this.aliases.add(input.readUTF());
+ }
+
+ ResetRequestSource.Status[] stati = ResetRequestSource.Status.values();
+ int contexts = input.readInt();
+
+ for (int i = 0; i < contexts; ++i)
+ {
+ this.contexts.put(input.readUTF(), stati[input.readInt()]);
+ }
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput output) throws IOException
+ {
+ output.writeInt(this.aliases.size());
+
+ for (String alias: this.aliases)
+ {
+ output.writeUTF(alias);
+ }
+
+ output.writeInt(this.contexts.size());
+
+ for (Map.Entry<String, ResetRequestSource.Status> context:
this.contexts.entrySet())
+ {
+ output.writeUTF(context.getKey());
+ output.writeInt(context.getValue().ordinal());
+ }
+ }
}
}
Show replies by date