How not expose method to client when using RCP

75 views
Skip to first unread message

Luis Costa

unread,
Dec 10, 2012, 4:53:44 AM12/10/12
to google-we...@googlegroups.com

Hi all,

I’m using GWT 2.5, and RCP to exchange information between client and service.

I’m trying to define the interface that extends RemoteService and another one CRUDService<T> that has among others (CRUD methods) a method:

public Class<T> getDtoType();

 

But this method is only intended to be user by the implementation, on the server side.

Is there a way not to expose this method to client side?

Otherwise I’m getting an error, when I compile the project, saying Class<T> does not implements Serializeble nor IsSerializeble.

 

Could anyone give me some feedback?

Thanks,

Luis.

Luis Costa

unread,
Dec 10, 2012, 6:24:44 AM12/10/12
to google-we...@googlegroups.com
Correction:
RCP I mean RPC :)

Jens

unread,
Dec 10, 2012, 7:10:31 AM12/10/12
to google-we...@googlegroups.com
As far as I know you cant send the class Class through GWT-RPC as its not serializable. So you have to remove your getDtoType() method from your GWT-RPC interface (and any other method that takes Class as argument)

As you only want to use the method on server side I am not sure why you add it to the interface and thus make it part of your public API?


-- J.

Luis Costa

unread,
Dec 11, 2012, 4:42:18 AM12/11/12
to google-we...@googlegroups.com

Hi Jens,

Thanks for your answer, the point here is who owns the contract (interface) server or client?

In my perspective is the server, and so this interface could have more than just methods to be expose to client side, in others technologies it can be defined which methods are expose to client, I think it would be interesting to have a way to define interface methods not to be exposed to client side (like a transient annotation).

Hope to hear some feedback.

Luis.

Jens

unread,
Dec 11, 2012, 6:27:41 AM12/11/12
to google-we...@googlegroups.com
As mentioned before if you use a public interface that interface defines a type that is part of your public API (= how your server can be accessed via GWT apps).

In case of GWT-RPC you could give me your GWT-RPC service interface and I could build a GWT app that uses your service (lets ignore potential technical issues here). So if you dont want me to use a specific method then this method should not be part of that interface. Otherwise I will use this method just because it exists and you are always bound to that method, as you can not remove it later without breaking my app that uses your service.

So your GWT-RPC service interface should only contain methods that the client is interested in, not more. If you need an additional interface for your servlet on server side then just create one and let it possibly extend the shared GWT-RPC service.

-- J.
Reply all
Reply to author
Forward
0 new messages