1 18 19 package org.objectweb.jac.core.dist; 20 21 import org.apache.log4j.Logger; 22 import org.objectweb.jac.core.*; 23 import org.objectweb.jac.util.*; 24 25 40 41 public class NonBlockingStubWrapper extends StubWrapper { 42 static Logger logger = Logger.getLogger("stub"); 43 44 49 50 public NonBlockingStubWrapper(AspectComponent ac, RemoteRef remoteRef) { 51 super(ac,remoteRef); 52 } 53 54 59 60 public NonBlockingStubWrapper(AspectComponent ac, String serverContainer) { 61 super(ac,serverContainer); 62 } 63 64 65 68 69 public Object invoke(Interaction interaction) { 70 71 if (remoteRef == null) { 72 if (serverContainer == null) { 73 logger.warn("local call (1) for stub "+interaction.wrappee); 74 return proceed(interaction); 75 } 76 RemoteContainer rc = Topology.get().getFirstContainer(serverContainer); 77 if (rc == null) { 78 logger.warn("local call (2) for stub "+interaction.wrappee); 79 return proceed(interaction); 80 } 81 remoteRef = rc.bindTo(NameRepository.get().getName(interaction.wrappee)); 82 if (remoteRef == null) { 83 logger.warn("local call (3) for stub "+interaction.wrappee+ 84 " ("+rc+","+serverContainer+")"); 85 return proceed(interaction); 86 } 87 } 88 89 logger.debug(interaction.wrappee + " forwards to the server"); 90 91 95 96 final String finalMethodName = interaction.method.getName(); 97 final Object [] finalMethodArgs = interaction.args; 98 99 new Thread () { 101 public void run() { 102 remoteRef.invoke( finalMethodName, finalMethodArgs ); 104 } 105 } . start(); 106 107 return null; 108 } 110 111 public void setFirstFreeCell() { 112 } 113 114 120 final static protected int nbMaxOfResults = 16; 121 122 126 protected Object [] results = new Object [nbMaxOfResults]; 127 128 129 protected int firstFreeCell = 0; 130 131 137 public Object getResult( Integer index ) { 138 int ind = index.intValue(); 139 Object result = results[ind]; 140 141 results[ind] = null; 145 146 return result; 147 } 148 149 } 150 | Popular Tags |