Ensure Administered objects are Serializable

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@469873 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-11-01 11:47:51 +00:00
parent fdadd72d9c
commit b93cd9ec13
1 changed files with 30 additions and 1 deletions

View File

@ -19,13 +19,18 @@ package org.apache.activemq.jndi;
import javax.naming.NamingException;
import javax.naming.Reference;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Properties;
/**
* Faciliates objects to be stored in JNDI as properties
*/
public abstract class JNDIBaseStorable implements JNDIStorableInterface {
public abstract class JNDIBaseStorable implements JNDIStorableInterface, Externalizable{
private Properties properties = null;
@ -80,5 +85,29 @@ public abstract class JNDIBaseStorable implements JNDIStorableInterface {
return JNDIReferenceFactory.createReference(this.getClass().getName(), this);
}
/**
* @param in
* @throws IOException
* @throws ClassNotFoundException
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
*/
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException{
Properties props = (Properties)in.readObject();
if (props != null) {
setProperties(props);
}
}
/**
* @param out
* @throws IOException
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
*/
public void writeExternal(ObjectOutput out) throws IOException{
out.writeObject(getProperties());
}
}