Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 390435 - Provide API to access client information and client-specific features
Summary: Provide API to access client information and client-specific features
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P1 enhancement (vote)
Target Milestone: 2.0 RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 329007
Blocks: 255513
  Show dependency tree
 
Reported: 2012-09-26 09:28 EDT by Ralf Sternberg CLA
Modified: 2013-01-08 08:13 EST (History)
2 users (show)

See Also:


Attachments
Example of a custom client (12.08 KB, application/octet-stream)
2012-09-26 09:54 EDT, Ralf Sternberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Sternberg CLA 2012-09-26 09:28:51 EDT
Now that there are alternative clients for RAP in the making, we need some API to obtain a reference to the client that is connected to the current session. This API should allow alternative clients to provide access to device-specific information and capabilities. We came up with the following draft:

  Client client = RWT.getClient();

Client is an interface that provides a service lookup method. For example, a client could provide a GeoLocationService:

  GeoLocationService locationService = client.getService( GeoLocationService.class );

The existing WebClient will be the default implementation of this interface.
Comment 1 Ralf Sternberg CLA 2012-09-26 09:54:05 EDT
Created attachment 221512 [details]
Example of a custom client

Implemented a first version in commit 4aa08df23ac92862861a32bd263ccac82b978c6d.

API to register custom clients is still internal. I've attached a simple example of a client implementation.
Comment 2 Tim Buschtoens CLA 2012-10-05 08:47:56 EDT
Regarding services, i think they should be handled in the protocol as static/fixed ids and vice-versa. See Bug 388835 - [protocol] update non-widget protocol object-types handling
Comment 3 Ivan Furnadjiev CLA 2012-10-10 10:49:12 EDT
Implemented JavaScriptExecutor and BrowserHistory as services.
Comment 4 Tim Buschtoens CLA 2012-10-11 08:58:53 EDT
The Client interface should provide "getLocale" and "getTimeZoneOffset" methods. The information could be sent by the client in the first "head". Maybe Client should become an abstract class so it can implement these two methods itself?
Comment 5 Ralf Sternberg CLA 2012-10-11 17:08:13 EDT
(In reply to comment #4)
> Maybe Client should become an abstract class so it can implement these two
> methods itself?

For me an interface feels better as it provides more flexibility for implementations - it does not tie implementations to a given super class. There's nothing wrong with an abstract base class but I think it should stay internal as long the API to register clients is internal.
Comment 6 Tim Buschtoens CLA 2013-01-08 08:13:55 EST
Client and ClientService classes are implemented and documented, bug closed.