1 6 7 package org.jfox.jetty.cluster; 8 9 import java.lang.reflect.Method ; 10 11 import org.jfox.ioc.connector.ClusterInvocation; 12 import org.jfox.ioc.connector.ClusterServer; 13 import org.jfox.ioc.connector.ClusterableContainer; 14 import org.jfox.ioc.connector.ConnectorServer; 15 import org.jfox.ioc.connector.Container; 16 import org.jfox.ioc.connector.Handler; 17 import org.jfox.ioc.connector.Invocation; 18 import org.jfox.ioc.connector.ServerNode; 19 import org.jfox.ioc.logger.Logger; 20 import org.mortbay.j2ee.session.AbstractReplicatedStore; 21 22 30 31 public class ClusterStore extends AbstractReplicatedStore implements ClusterableContainer, Handler { 32 protected Logger _log = Logger.getLogger(ClusterStore.class); 33 34 public ClusterStore() { 35 super(); 36 } 37 38 public void start() throws Exception { 39 super.start(); 40 } 41 42 public void stop() { 43 super.stop(); 44 } 45 46 public void destroy() { 47 super.destroy(); 48 } 49 50 protected void publish(String id, Method method, Object [] argInstances) { 51 HttpSessionInvocation invocation = new HttpSessionInvocation(null, null, argInstances); 52 invocation.setSessionId(id); 53 invocation.setMethodId((Integer ) _methodToInteger.get(method)); 54 ClusterInvocation clusterInvocation = new ClusterInvocation(invocation, ServerNode.THE_NODE); 56 ClusterServer clusterServer = ConnectorServer.getClusterServer(); 57 if (clusterServer != null) { try { 59 clusterServer.cast(clusterInvocation); 60 } 61 catch (Exception e) { 62 _log.warn("session publish failed.", e); 63 } 64 } 65 66 } 67 68 73 public void syncInvocation(Invocation invocation) { 74 HttpSessionInvocation sessionInvocation = (HttpSessionInvocation) invocation; 75 String id = sessionInvocation.getSessionId(); 76 Integer method = sessionInvocation.getMethodId(); 77 Object [] args = sessionInvocation.getArgs(); 78 } 81 82 public Class getHandlerClass() { 83 return this.getClass(); 84 } 85 86 public Class getInvocationClass() { 87 return HttpSessionInvocation.class; 88 } 89 90 public Container getContainer() { 91 return this; 92 } 93 94 101 public Object execute(Invocation invocation) throws Throwable { 102 syncInvocation(invocation); 103 return null; 104 } 105 106 111 public Method getMethodByHash(String hashId) { 112 return null; 113 } 114 115 public static void main(String [] args) { 116 117 } 118 } 119 | Popular Tags |