First, we will create a JBI proxy implementing an interface compatible with the target service. Then, in place of the target service we will use the proxy instance, so that any calls intended for the target service will be first routed to the proxy. The proxy in turn will delegate the call to the target service. The structural relationship between various classes participating in the interaction is shown in the following figure:
Here, EchoProxyService
is the class which we later expose in the JBI bus as the service. This class implements the IEcho
interface. In order to demonstrate the proxy, EchoProxyService
doesn't implement the service as such, instead depends on the JbiProxy derived out of another class TargetService
. The TargetService
contains the actual service code. As you can see, both the EchoProxyService
and the TargetService
implement the same interface.