1 package org.sapia.regis.gui; 2 3 import java.io.File ; 4 import java.util.Properties ; 5 6 import org.sapia.regis.Registry; 7 import org.sapia.regis.RegistryContext; 8 import org.sapia.regis.local.LocalRegistry; 9 import org.sapia.regis.local.LocalRegistryFactory; 10 import org.sapia.regis.remote.client.RemoteRegistryFactory; 11 12 public class RegistryFactory { 13 14 public static Registry newEmbeddedInstance() throws Exception { 15 Properties props = new Properties (); 16 props.setProperty(RegistryContext.FACTORY_CLASS, LocalRegistryFactory.class.getName()); 17 18 RegistryContext ctx = new RegistryContext(props); 19 return ctx.connect(); 20 } 21 22 public static Registry newDebugInstance() throws Exception { 23 LocalRegistry local = (LocalRegistry)newEmbeddedInstance(); 24 return local; 26 } 27 28 public static Registry newRemoteInstance(String host, int port, String jndiName) throws Exception { 29 Properties props = new Properties (); 30 props.setProperty(RegistryContext.FACTORY_CLASS, RemoteRegistryFactory.class.getName()); 31 props.setProperty(RemoteRegistryFactory.ADDRESS, host); 32 props.setProperty(RemoteRegistryFactory.PORT, ""+port); 33 if(jndiName != null && jndiName.trim().length() > 0){ 34 props.setProperty(RemoteRegistryFactory.JNDI_NAME, ""+jndiName); 35 } 36 RegistryContext ctx = new RegistryContext(props); 37 return ctx.connect(); 38 } 39 } 40 | Popular Tags |