javagwtrequestfactory

Where to use @SuppressWarnings("requestfactory")


I'm trying to build a simple (read-only) web app with GWT and RequestFactory, and I can't work out how to get rid of following warning:

warning: The domain type DDisplay is not default-instantiable. Calling RequestContext.create(DDisplayProxy.class) will cause a server error.

  Add @SuppressWarnings("requestfactory") to dismiss.

The problem being, I have pasted @SuppressWarnings("requestfactory") above every possibly relevant class, interface and method, but I still get this message.

As my requestfactory is read-only, I'm not going to call RequestContext.create, so this is not a concern. It would just be nice to get rid of the warning (without creating a DDisplay locator class).

On the server side I have a domain object DDisplay, and a DAO, DDisplayService.

public class DDisplay {

    public String getTitle () {
        return "title";
    }
}

and

public class DDisplayService {

    public DDisplay getDisplayByUUID (String uuid) {
        return new DDisplay ();
    }
}

I have the following for RequestFactory:

@ProxyForName("com.foobar.server.display.DDisplay")
public interface DDisplayProxy extends EntityProxy {

    String getTitle ();
}

and

public interface DisplayRequestFactory extends RequestFactory {

    @ServiceName(
            value="com.foobar.server.display.DDisplayService"
        ,locator="com.foobar.server.display.SpringServiceLocator"
    )
    public interface DisplayRequestContext extends RequestContext {
        Request <DDisplayProxy> getDisplayByUUID (String id);
    }

    DisplayRequestContext display ();
}

Can anyone tell me where to put the @SuppressWarnings("requestfactory") to get rid of this error please? Or is there another way of doing this - do I just need to add a never-used Locator class?

thanks,

Jim


Solution

  • From reading the source where the error message come from, it appears that you can add this to your EntityProxy, DDisplayProxy. Something like this:

    @SuppressWarnings("requestfactory")
    @ProxyForName("com.foobar.server.display.DDisplay")
    public interface DDisplayProxy extends EntityProxy {
    
        String getTitle();
    }
    

    This from reading the source of com.google.web.bindery.requestfactory.apt.DomainChecker#visitType, which if currentTypeIsProxy is true and there is no locator, and the type isn't instatiable, the warning is emitted. From inside of state.warn(...) (which is given the proxy type element), it checks for the presence of the @SuppressWarnings annotation on that type.