Pregunta

I am using a class separate from my DAO to handle access requests, but I don't know how to implement InstanceRequest methods:

public class Service
{
    public static DAO findDAO(Long id);
}

@Service(Service.class)
public interface DAORequestContext extends RequestContext
{
    Request<ProxyForDAO> findDAO(Long id);
    InstanceRequest<ProxyForDAO, Long> persist();
}

I define public Long persist() in my DAO implementation, because the gwt docs say, "On the server, instance methods must be implemented as non-static methods in the entity type," but request factory can't seem to find it:

SEVERE: Could not find any methods named persist in com.activegrade.server.data.Service Feb 23, 2011 10:03:02 PM com.google.gwt.requestfactory.server.ServiceLayerDecorator die

How do I implement an instance method in Service? I don't know how to transform the InstanceRequest. Do I need to connect the DAO class to the Service some way, so that the code generator knows to look in Service for most methods but to skip over to the DAO for InstanceRequest calls?

¿Fue útil?

Solución

ASAIK it's not possible because the InstanceRequest methods are bound to the class specified in the @Service annotation. With Request methods it is possible to have a method for multiple data classes one service class, using locators. But from what I understand of request factory this is not possible with the InstanceRequest methods. See also this project, which uses Locators, with methods in one place: http://code.google.com/p/listwidget/

Edit: I've rewritten the answer based after the update/and comment below.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top