1 24 package org.objectweb.joram.client.jms.admin; 25 26 import javax.naming.*; 27 import javax.jms.JMSException ; 28 29 import org.objectweb.joram.client.jms.FactoryParameters; 30 31 import org.objectweb.util.monolog.api.BasicLevel; 32 import org.objectweb.joram.shared.JoramTracing; 33 34 37 public abstract class AbstractConnectionFactory extends AdministeredObject { 38 39 protected FactoryParameters params; 40 41 42 protected String reliableClass = null; 43 44 50 public AbstractConnectionFactory(String host, int port) { 51 params = new FactoryParameters(host, port); 52 53 if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) 54 JoramTracing.dbgClient.log(BasicLevel.DEBUG, this + ": created."); 55 } 56 57 62 public AbstractConnectionFactory(String url) { 63 params = new FactoryParameters(url); 64 65 if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG)) 66 JoramTracing.dbgClient.log(BasicLevel.DEBUG, this + ": created."); 67 } 68 69 72 public AbstractConnectionFactory() { 73 params = new FactoryParameters(); 74 } 75 76 public void setReliableClass(String reliableClass) { 77 this.reliableClass = reliableClass; 78 } 79 80 86 final static String dfltRootLogin = "root"; 87 93 final static String dfltRootPassword = "root"; 94 98 final static String dfltLogin = "anonymous"; 99 104 final static String dfltPassword = "anonymous"; 105 106 111 public static String getDefaultRootLogin() { 112 return System.getProperty("JoramDfltRootLogin", dfltRootLogin); 113 } 114 115 120 public static String getDefaultRootPassword() { 121 return System.getProperty("JoramDfltRootPassword", dfltRootPassword); 122 } 123 124 129 public static String getDefaultLogin() { 130 return System.getProperty("JoramDfltLogin", dfltLogin); 131 } 132 133 138 public static String getDefaultPassword() { 139 return System.getProperty("JoramDfltPassword", dfltPassword); 140 } 141 142 143 public FactoryParameters getParameters() { 144 return params; 145 } 146 147 148 public final void toReference(Reference ref) throws NamingException { 149 toReference(ref, "cf"); 150 } 151 152 153 public void toReference(Reference ref, String prefix) { 154 if (prefix == null) prefix = "cf"; 155 156 params.toReference(ref, prefix); 157 ref.add(new StringRefAddr(prefix + ".reliableClass", reliableClass)); 158 } 159 160 161 public final void fromReference(Reference ref) throws NamingException { 162 fromReference(ref, "cf"); 163 } 164 165 166 public void fromReference(Reference ref, String prefix) { 167 if (prefix == null) prefix = "cf"; 168 169 reliableClass = (String ) ref.get(prefix + ".reliableClass").getContent(); 170 params.fromReference(ref, prefix); 171 } 172 } 173 | Popular Tags |