I have two web app that runs on the same machine. Both web apps on the same machine need to call each other but without going into HTTP.
One web app is the REST Servlet and the other one is the DATABASE servlet.
The DATABASE servlet running have methods within it's codebase:
<T> Map<String, Comparable> getFirstEntity(
String instance,
String namespace,
final String kind,
final String propertyKey,
final Comparable<T> propertyVal,
Class<T> clazz);
and
boolean createEntity(
String instance,
String namespace,
String entityType,
String entityId,
Map<String, Comparable> comparableMap,
final String[] read,
final String[] write,
final Boolean publicRead,
final Boolean publicWrite,
final EntityMetadata metadata);
Obviously, the "REST Servlet" can call these methods if it exposed as HTTP endpoints, but as mentioned, the two servlet must be able to communicate without going through exposing these methods as HTTP endpoints.
What's the best way for the "REST Servlet" to be able to "invoke" these methods?
E.g. calling it like:
Map<String, Comparable> comparableMap = buildEntity();
databaseAppProxy.createEntity(instance, DEFAULT, entityType, "1-0", comparableMap, null, null, false, false, metadata);
As well as,
Map<String, Comparable> result = databaseAppProxy.getFirstEntity(instance, DEFAULT, entityType, "age", 40, Integer.class);
These calls will then be "proxied" then from the DATABASE servlet running it will be executed.