1 18 package org.apache.activemq.jndi; 19 20 import javax.naming.NamingException ; 21 import javax.naming.Reference ; 22 import java.io.Externalizable ; 23 import java.io.IOException ; 24 import java.io.ObjectInput ; 25 import java.io.ObjectOutput ; 26 import java.util.Properties ; 27 28 31 32 public abstract class JNDIBaseStorable implements JNDIStorableInterface, Externalizable { 33 34 private Properties properties = null; 35 36 37 42 protected abstract void buildFromProperties(Properties props); 43 44 49 50 protected abstract void populateProperties(Properties props); 51 52 57 58 public synchronized void setProperties(Properties props) { 59 this.properties = props; 60 buildFromProperties(props); 61 } 62 63 68 69 public synchronized Properties getProperties() { 70 if (this.properties == null) { 71 this.properties = new Properties (); 72 } 73 populateProperties(this.properties); 74 return this.properties; 75 } 76 77 78 84 public Reference getReference() throws NamingException { 85 return JNDIReferenceFactory.createReference(this.getClass().getName(), this); 86 } 87 88 94 public void readExternal(ObjectInput in) throws IOException ,ClassNotFoundException { 95 Properties props = (Properties )in.readObject(); 96 if (props != null) { 97 setProperties(props); 98 } 99 100 } 101 102 107 public void writeExternal(ObjectOutput out) throws IOException { 108 out.writeObject(getProperties()); 109 110 } 111 112 } 113 114 | Popular Tags |