1 19 package org.objectweb.carol.cmi; 20 21 import java.lang.reflect.InvocationTargetException ; 22 import java.rmi.Remote ; 23 24 27 public final class ClusterObject { 28 32 public static Class getClusterStubClass(Class cl) 33 throws ClassNotFoundException { 34 String stub_name = cl.getName(); 35 String cstub_name = stub_name; 36 if (stub_name.endsWith("_Stub")) 37 cstub_name = cstub_name.substring(0, cstub_name.length() - 5); 38 else if (stub_name.endsWith("_OWStub")) 39 cstub_name = cstub_name.substring(0, cstub_name.length() - 7); 40 cstub_name += "_Cluster"; 41 ClassLoader loader = cl.getClassLoader(); 42 Class cstub_class = loader.loadClass(cstub_name); 43 return cstub_class; 44 } 45 46 public static Class getClusterConfigClass(Remote obj) 47 throws ClassNotFoundException { 48 Class cl = obj.getClass(); 49 String obj_name = obj.getClass().getName(); 50 String config_name = obj_name; 51 if (obj_name.endsWith("_Stub")) 52 config_name = config_name.substring(0, config_name.length() - 5); 53 else if (obj_name.endsWith("_OWStub")) 54 config_name = config_name.substring(0, config_name.length() - 7); 55 config_name += "_ClusterConfig"; 56 ClassLoader loader = cl.getClassLoader(); 57 return loader.loadClass(config_name); 58 } 59 60 66 public static ClusterConfig getClusterConfig(Remote obj) 67 throws 68 ClassNotFoundException , 69 NoSuchMethodException , 70 IllegalAccessException , 71 InvocationTargetException { 72 Class config_class = getClusterConfigClass(obj); 73 java.lang.reflect.Method mth = 74 config_class.getMethod("getClusterConfig", (Class []) null); 75 return (ClusterConfig) mth.invoke(null, (Object []) null); 76 } 77 } 78 | Popular Tags |