[Jboss-cvs] JBossAS SVN: r55157 - branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/spi
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 4 00:50:47 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-04 00:50:43 -0400 (Fri, 04 Aug 2006)
New Revision: 55157
Modified:
branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/spi/DeploymentContext.java
Log:
Relax the type of the context data map value to not be Serializable and implement writeData to only write out the Serialiable values
Modified: branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/spi/DeploymentContext.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/spi/DeploymentContext.java 2006-08-04 03:08:57 UTC (rev 55156)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployers/spi/DeploymentContext.java 2006-08-04 04:50:43 UTC (rev 55157)
@@ -21,11 +21,17 @@
*/
package org.jboss.deployers.spi;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jboss.util.JBossObject;
@@ -36,6 +42,8 @@
* deployment descriptor) that is processed by one ore more deployers to
* procude MC beans.
*
+ * TODO: look at how the state should be reflected in the kernel
+ *
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @author Scott.Stark at jboss.org
* @version $Revision$
@@ -44,19 +52,28 @@
implements Serializable
{
private static final long serialVersionUID = 1;
-
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("file", VirtualFile.class),
+ new ObjectStreamField("watchFile", VirtualFile.class),
+ new ObjectStreamField("parent", DeploymentContext.class),
+ new ObjectStreamField("deploymentTypes", CopyOnWriteArraySet.class),
+ new ObjectStreamField("classpath", ArrayList.class),
+ new ObjectStreamField("subDeployments", ArrayList.class),
+ new ObjectStreamField("contextData", ArrayList.class),
+ };
// Protected Data ------------------------------------------------
- protected VirtualFile file;
- protected DeploymentContext parent;
- protected Set<String> deploymentTypes = new CopyOnWriteArraySet<String>();
+ private VirtualFile file;
+ private VirtualFile watchFile;
+ private DeploymentContext parent;
+ private Set<String> deploymentTypes = new CopyOnWriteArraySet<String>();
/** The list of VFS paths that form the classpath */
- protected List<String> classpath = new ArrayList<String>();
- protected List<DeploymentContext> subDeployments = new ArrayList<DeploymentContext>();
- protected ConcurrentHashMap<Serializable, Serializable>
- contextData = new ConcurrentHashMap<Serializable, Serializable>();
+ private List<String> classpath = new ArrayList<String>();
+ private List<DeploymentContext> subDeployments = new ArrayList<DeploymentContext>();
+ private ConcurrentHashMap<Serializable, Object>
+ contextData = new ConcurrentHashMap<Serializable, Object>();
/** The current state of the deployment */
- protected DeploymentState state = DeploymentState.CONSTRUCTED;
-
+ private transient DeploymentState state = DeploymentState.CONSTRUCTED;
+
// Constructors --------------------------------------------------
public DeploymentContext()
{
@@ -69,21 +86,48 @@
// Public --------------------------------------------------------
+ /**
+ * Get the virtual file that represents the root of the deployment context
+ */
public VirtualFile getFile()
{
return file;
}
+ /**
+ * Set the virtual file that represents the root of the deployment context
+ */
public void setFile(VirtualFile file)
{
this.file = file;
}
/**
+ * Get the virtual file that represents the deployment context file to
+ * monitor for modifications as a redeployment trigger.
+ * @return watchFile - the descriptor to monitor. If null the deployment
+ * context file should be used.
+ */
+ public VirtualFile getWatchFile()
+ {
+ return this.watchFile;
+ }
+
+ /**
+ * Set the virtual file that represents the deployment context file to
+ * monitor for modifications as a redeployment trigger.
+ * @param watchFile - the descriptor to monitor
+ */
+ public void setWatchFile(VirtualFile watchFile)
+ {
+ this.watchFile = watchFile;
+ }
+
+ /**
* A map of arbitrary data associated with the deployment context
* @see #putContextData(Class, Serializable, Serializable)
* @return a reference to the context data map.
*/
- public Map<Serializable, Serializable> getContextData()
+ public Map<Serializable, Object> getContextData()
{
return contextData;
}
@@ -96,10 +140,10 @@
* @param key - the simple key
* @return the current value for the scope/key.
*/
- public Serializable getContextData(Class scope, Serializable key)
+ public Object getContextData(Class scope, Serializable key)
{
String fullKey = scope.getName() + "." + key;
- Serializable currentData = contextData.get(fullKey);
+ Object currentData = contextData.get(fullKey);
return currentData;
}
/**
@@ -111,10 +155,10 @@
* @param data - the context data
* @return any previous value for the scope/key.
*/
- public Serializable putContextData(Class scope, Serializable key, Serializable data)
+ public Object putContextData(Class scope, Serializable key, Object data)
{
String fullKey = scope.getName() + "." + key;
- Serializable currentData = contextData.put(fullKey, data);
+ Object currentData = contextData.put(fullKey, data);
return currentData;
}
/**
@@ -123,10 +167,10 @@
* @param key - the simple key
* @return the value for the removed scope/key.
*/
- public Serializable removeContextData(Class scope, Serializable key)
+ public Object removeContextData(Class scope, Serializable key)
{
String fullKey = scope.getName() + "." + key;
- Serializable data = contextData.remove(fullKey);
+ Object data = contextData.remove(fullKey);
return data;
}
@@ -267,4 +311,37 @@
return equals;
}
+ /**
+ * Only write out the serializable elements of the contextData
+ * @param out
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.putFields().put("file", VirtualFile.class);
+ out.putFields().put("watchFile", VirtualFile.class);
+ out.putFields().put("parent", DeploymentContext.class);
+ out.putFields().put("deploymentTypes", deploymentTypes);
+ out.putFields().put("classpath", classpath);
+ out.putFields().put("subDeployments", subDeployments);
+
+ ConcurrentHashMap serialData = new ConcurrentHashMap();
+ Iterator<Entry<Serializable, Object>> iter = contextData.entrySet().iterator();
+ while( iter.hasNext() )
+ {
+ Entry<Serializable, Object> entry = iter.next();
+ if( entry.getValue() instanceof Serializable )
+ {
+ serialData.put(entry.getKey(), entry.getValue());
+ }
+ }
+ out.putFields().put("contextData", serialData);
+ out.writeFields();
+ }
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ }
}
More information about the jboss-cvs-commits
mailing list