1 package org.sapia.regis.remote.client; 2 3 import java.util.Properties ; 4 5 import org.sapia.regis.Registry; 6 import org.sapia.regis.RegistryFactory; 7 8 28 public class RemoteRegistryFactory implements RegistryFactory{ 29 30 34 public static final String JNDI_NAME = "org.sapia.regis.remote.jndi.name"; 35 36 40 public static final String ADDRESS = "org.sapia.regis.remote.address"; 41 42 46 public static final String PORT = "org.sapia.regis.remote.port"; 47 48 public Registry connect(Properties props) throws Exception { 49 String jndiName = props.getProperty(JNDI_NAME); 50 String portStr = props.getProperty(PORT); 51 if(portStr == null){ 52 throw new IllegalStateException ("Registry server jndi name or port must be specified"); 53 } 54 String addr = props.getProperty(ADDRESS); 55 if(addr == null){ 56 throw new IllegalStateException ("Address must be specified"); 57 } 58 59 if(jndiName != null){ 60 RegistryImporter imp = new RegistryImporter(); 61 props.setProperty("java.naming.provider.url", "ubik://"+addr+":"+portStr); 62 return imp.lookup(jndiName, props); 63 } 64 else{ 65 RegistryImporter imp = new RegistryImporter(); 66 return imp.lookup(addr, Integer.parseInt(portStr)); 67 } 68 } 69 } 70 | Popular Tags |