Hi Louis,
The client API will not currently optimize requests/responses from
within the same VM, beyond that which the TCP/IP networking layer will
likely optimize.
The client API is not an RPC mechanism, where an instance Java type
for an entity can be passed by reference from the client to a resource
class.
On Jul 10, 2009, at 4:32 PM, Louis Polycarpou wrote:
> I am investigating the use of a layered service design in Jersey:
>
> * browser calls servlet framework which 'triggers' ControllerResource
> * ControllerResource invokes one or more other Resources (on same &
> differerent VM potentially)
> * ControllerResource responds to browser
>
> At the moment, the ControllerResource & other Resources are in the
> same VM. If I use Jersey's client API to invoke the other resources,
> will it optimise this call or will it go over the TCP/IP stack
> (rather like the Local interface in EJBs)? I'm hoping that there's a
> way to do this for performance reasons now and so that I can split
> these out into different tiers later without having to refactor the
> way I'm calling the 'downstream' resources.
>
The client API is plugable so one could use a different implementation
that makes internal and optimized invocations to the service itself
(the Jersey test API uses a specialized optimized client that avoids
using the network). But as i said the API is not an RPC mechanism so
one would have to take into account that the Java type of the entity
used by the client might be different to the type used by the resource
method.
Something should be possible, but unfortunately something like this
would be rather involved and could take some time to implement, time
which i do not have :-( as there are higher priority tasks. If you
would like a challenge i would be happy to guide you :-)
> I don't like the idea of just instantiating the POJO resources and
> using them as standard methods for a number of reasons but out of
> interest is there a way to inject urlInfo and other @Context if we
> are already in a Resource when we instantiate them?
>
You need to get Jersey to instantiate to perform injection, see
ResourceContext to obtain an instance of a resource class:
https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/core/ResourceContext.html
Paul.