Bug 697114 - look to convert interfaces to concrete classes in GWT RPC interfaces
look to convert interfaces to concrete classes in GWT RPC interfaces
Status: NEW
Product: RHQ Project
Classification: Other
Component: Core UI (Show other bugs)
4.0.0.Beta1
Unspecified Unspecified
medium Severity high (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On:
Blocks: rhq4
  Show dependency treegraph
 
Reported: 2011-04-15 17:23 EDT by John Mazzitelli
Modified: 2011-05-23 20:58 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Mazzitelli 2011-04-15 17:23:58 EDT
read: http://stackoverflow.com/questions/3059787/gwt-using-listserializable-in-a-rpc-call

That indicates we should not use interface classes like List or Set as params or return types in our RPC interfaces. I have not found this in the GWT docs, but this sounds like its true.

We do use List, Set and other interface types in some of our GWT service interfaces. We should go through and convert them to concrete classes. This might reduce the size of the app that needs to be downloaded and might speed up compilation times.
Comment 1 John Mazzitelli 2011-04-19 11:22:02 EDT
this will involve alot of work. Not only will we have to change the parameter types and return types for all GWT services, but it means all GWT Impls will need to change to use the concrete types which would (and almost certainly will) means changing SLSB API to use concrete types OR we do unchecked casting which could cause problems in the future if we change SLSB implementations.

For example:

in TagGWTService we have this:

    Set<Tag> addTags(Set<Tag> tags) throws RuntimeException;

We'd have to change both parameter and return type to this:

    HashSet<Tag> addTags(HashSet<Tag> tags) throws RuntimeException;

This means we need to change TagGWTServiceImpl from:

    public Set<Tag> addTags(Set<Tag> tags) throws RuntimeException {
        try {
            return SerialUtility.prepare(tagManager.addTags(getSessionSubject(), tags), "TagService.addTags");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }

to something like:

    public HashSet<Tag> addTags(HashSet<Tag> tags) throws RuntimeException {
        try {
            HashSet<Tag> results = new HashSet<Tag>(tagManager.addTags(getSessionSubject(), tags)); // new collection that is explicitly of concrete type HashSet
            return SerialUtility.prepare(results, "TagService.addTags");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }

which requires a duplicate HashSet object to be created, just so we can have a concreate class, which is probably stupid. So we would alternatively have to do something like:


    public HashSet<Tag> addTags(HashSet<Tag> tags) throws RuntimeException {
        try {
            HashSet<Tag> results = (HashSet<Tag>) tagManager.addTags(getSessionSubject(), tags); // unchecked cast - what if addTags isn't really returning a HashSet?
            return SerialUtility.prepare(results, "TagService.addTags");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }

This just does a cast to the concrete type - but requires us to know the SLSB implementation details - that is, what is the actual concrete type that it is returning.

The other alternative is to change the SLSB API to explicitly return the concrete type, so TagManager would be something like "HashSet addTags(....)". The negative of this is it now forces changes to everyone calling that API, which may affect remote interfaces/clients/CLI scripts.

Note You need to log in before you can comment on or make changes to this bug.