1 6 7 package org.jfox.jndi; 8 9 import java.lang.reflect.Method ; 10 import java.util.ArrayList ; 11 import java.util.List ; 12 13 import javax.naming.Name ; 14 import javax.naming.Context ; 15 16 import org.jfox.ioc.connector.ClusterableContainer; 17 import org.jfox.ioc.connector.Invocation; 18 19 22 23 public class ClusterableJNDIContainerImpl extends JNDIContainerImpl implements ClusterableContainer { 24 25 28 private List <String > clusterMethods = new ArrayList <String >(); 29 { 30 clusterMethods.add("bind"); 31 clusterMethods.add("rebind"); 32 clusterMethods.add("unbind"); 33 clusterMethods.add("createSubcontext"); 34 clusterMethods.add("destroySubcontext"); 35 clusterMethods.add("closeSubcontext"); 36 } 37 38 42 public void syncInvocation(Invocation invocation) { 43 try { 44 Method method = invocation.getMethod(); 45 Object [] args = invocation.getArgs(); 46 if(clusterMethods.contains(method.getName())){ 47 logger.debug("syncInvocation " + invocation); 48 if(method.getName().equals("bind")) { 50 Context ctx = (Context ) args[0]; 51 Name name = (Name ) args[1]; 52 Object bindObject = args[2]; 53 String className = (String ) args[3]; 54 this.rebind(ctx, name, bindObject, className); 55 } 56 else { 57 method.invoke(this, args); 58 } 59 } 60 } 61 catch(Exception e){ 62 logger.warn("syncInvocation " + invocation + " error.",e); 63 } 64 } 65 66 public static void main(String [] args) { 67 68 } 69 } 70 | Popular Tags |