/** * Once a HARMIServer implementation exists, it is possible to ask for a stub that can, for example, * be bound in JNDI for client use. Each client stub may incorporate a specific load-balancing * policy. * * @param policy {@link org.jboss.ha.client.loadbalance.LoadBalancePolicy} implementation to ues on the client. * @return proxy instance object */ public Object createHAStub(LoadBalancePolicy policy) { HARMIClient client = new HARMIClient(target.getReplicantList(), target.getCurrentViewId (), policy, key, handler); this.target.addProxy (client); return Proxy.newProxyInstance( intf.getClassLoader(), new Class[]{ intf, HARMIProxy.class }, client); }
public HARMIResponse invoke(long clientViewId, MarshalledInvocation mi) throws Exception { mi.setMethodMap(invokerMap); Method method = mi.getMethod(); try { HARMIResponse rsp = new HARMIResponse(); if (clientViewId != target.getCurrentViewId()) { rsp.newReplicants = new ArrayList<Object>(target.getReplicantList()); rsp.currentViewId = target.getCurrentViewId(); } rsp.response = method.invoke(handler, mi.getArguments()); return rsp; } catch (IllegalAccessException iae) { throw iae; } catch (IllegalArgumentException iae) { throw iae; } catch (java.lang.reflect.InvocationTargetException ite) { throw (Exception)ite.getTargetException(); } }
public List<?> getReplicants() throws Exception { return target.getReplicantList(); }