/** * Needs to be called by user when no longer need to make calls on remote POJO. Otherwise will * maintain remote connection until this is called. * * @param transporterClient */ public static void destroyTransporterClient(Object transporterClient) { if (transporterClient instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(transporterClient); if (handler instanceof TransporterClient) { TransporterClient client = (TransporterClient) handler; client.disconnect(); } else { throw new IllegalArgumentException("Object is not a transporter client."); } } else { throw new IllegalArgumentException("Object is not a transporter client."); } }