/** * Create a remote proxy to a POJO on a remote server. * * @param locator - the remoting locator to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(InvokerLocator locator, Class targetClass) throws Exception { TransporterClient client = new TransporterClient(locator, targetClass.getName()); return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{targetClass}, client); }
/** * Create a remote proxy to a POJO on a remote server. * * @param locatorURI - the remoting locator uri to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @param loadBalancer - policy for selecting which target server to use from list of available servers. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(String locatorURI, Class targetClass, LoadBalancer loadBalancer) throws Exception { if (InternalTransporterServices.getInstance().getNetworkRegistry() == null) { setupDetector(); } InvokerLocator locator = new InvokerLocator(locatorURI); TransporterClient client = new TransporterClient(locator, targetClass.getName(), loadBalancer); return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{targetClass}, client); }
/** * Create a remote proxy to a POJO on a remote server. * * @param locatorURI - the remoting locator uri to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @param clustered - true will cause the transporter to look for other remoting serves that have the POJO running * and include it in the client's target list. If a call on first target fails, will seamlessly fail over to one * of the other discovered targets. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(String locatorURI, Class targetClass, boolean clustered) throws Exception { if (!clustered) { return createTransporterClient(locatorURI, targetClass); } else { if (InternalTransporterServices.getInstance().getNetworkRegistry() == null) { setupDetector(); } InvokerLocator locator = new InvokerLocator(locatorURI); TransporterClient client = new TransporterClient(locator, targetClass.getName()); return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{targetClass}, client); } }