Remote Reflection API


Remote Reflection is a Java API which make it easier to call remote methods on remote JVM in very simple way without the need for any special configurations or common contract between client and server.

Usage

1- Create new maven project.
2- Add JK-DB dependency to your pom.xml inside the dependencies sections

    <dependency>
        <groupId>com.jalalkiswani</groupId>
        <artifactId>jk-remote-reflection</artifactId>
        <version>0.0.1</version>
    </dependency>

Server

In the server application(the application which you want to expose its method remotely) , add the following after at the end of you main method:

public class YourMainClass{
    ...
    public static void main(String args){
    ...     
    ReflectionServer server = new ReflectionServer(PORT_NUMBER);
    server.start();
    }
}

Client

In the client application(the application which should consume the remote method):

   ReflectionClient client = new ReflectionClient(remoteHostIp, remoteServerPort);
    MethodCallInfo info = new MethodCallInfo(className, methodName, param);
    client.callMethod(info); 

For example:

    String className = "com.jk.reflection.test.TestRemoteObject";
    String methodName = "sayHello";
    MethodCallInfo info = new MethodCallInfo(className, methodName, "Jalal Kiswani");
    client.callMethod(info);
    System.out.println(info.getResult());

API Design (UML)