我有带有一些请求接口(interface)的RequestFactory
public interface FooRequest extends RequestContext {
Request<List<Foo>> findSmt();
}
我不知道应该在哪里放置 findSmt()
实现以及如何与该实现进行连接。
最佳答案
您可以使用@Service注释来表示实现findSmt的类。您不应该继承 FooRequest。
@Service(FooRequestImpl.class)
public interface FooRequest extends RequestContext {
Request<List<FooProxy>> findSmt();
}
...
public class FooRequestImpl
{
List<FooDAO> findSmt() //note that we dropped the Request and changed the Proxy to the DAO
{
return getFoos();
}
}
不幸的是,在同样的情况下,我被迫将静态方法放入我的域实体中。我认为不可能在单独的类中创建InstanceRequest
。
关于java - 关于RequestFactory中自定义方法的简单问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5422860/