1 Reply Latest reply on Oct 16, 2009 5:21 PM by dmlloyd

    Remoting 3: Type-safe client API

    dmlloyd

      Leaving aside the fact that it's been an amazingly long time since I've had a chance to post in here...

      I've recently added additional type-safe methods to the Client interface in trunk. The purpose of these methods is to allow a service to be defined such that the result type of the invocation depends not only on the client's defined reply type, but also the type of the request you're sending.

      There are two ways to use this feature. The first way is to use the new form of invoke()/send() which accepts as a second parameter, the expected return type. The second way is to have your request type extend the new TypedRequest interface, which defines the reply subtype for each request type. If this is the case, invoke()/send() will use a third form in which the argument extends TypedRequest and the reply type is defined accordingly.

      This feature is optional; the regular invoke()/send() methods still exist on the Client interface for simpler use cases.

      Please let me know what you think of this idea. The implementation was actually quite trivial, since per-request type checking is already built into the SPI.