1 19 package org.objectweb.carol.cmi; 20 21 import java.rmi.Remote ; 22 import java.rmi.RemoteException ; 23 import java.util.Set ; 24 import java.io.Serializable ; 25 26 32 public final class DistributedEquiv { 33 private static Object lock = new Object (); 34 private static DistributedEquivSystem des = null; 35 36 40 public static DistributedEquiv start() throws ConfigException { 41 synchronized (lock) { 42 if (des != null) 43 throw new ConfigException("DistributedEquiv already started"); 44 try { 45 des = new DistributedEquivSystem(); 46 } catch (ConfigException e) { 47 throw e; 48 } catch (Exception e) { 49 throw new ConfigException( 50 e.getClass().getName() + ": " + e.getMessage()); 51 } 52 } 53 return new DistributedEquiv(); 54 } 55 56 public void stop() throws ConfigException { 57 synchronized (lock) { 58 des.terminate(); 59 des = null; 60 } 61 } 62 63 66 static boolean exportObject(Serializable key, byte[] obj) 67 throws ConfigException, RemoteException { 68 DistributedEquivSystem d = des; 69 if (d == null) 70 throw new ConfigException("DistributedEquiv not started"); 71 return d.exportObject(key, obj); 72 } 73 74 77 static boolean unexportObject(Serializable key) throws ConfigException { 78 DistributedEquivSystem d = des; 79 if (d == null) 80 throw new ConfigException("DistributedEquiv not started"); 81 return d.unexportObject(key); 82 } 83 84 87 static ClusterStubData getGlobal(Serializable key) 88 throws ConfigException, RemoteException { 89 DistributedEquivSystem d = des; 90 if (d == null) 91 throw new ConfigException("DistributedEquiv not started"); 92 return d.getGlobal(key); 93 } 94 95 98 static Remote getLocal(Serializable key) throws ConfigException { 99 DistributedEquivSystem d = des; 100 if (d == null) 101 throw new ConfigException("DistributedEquiv not started"); 102 return d.getLocal(key); 103 } 104 105 static Set keySet() throws ConfigException { 106 DistributedEquivSystem d = des; 107 if (d == null) 108 throw new ConfigException("DistributedEquiv not started"); 109 return d.keySet(); 110 } 111 } 112 | Popular Tags |