RequestFactory 总是获取所有依赖项
当我使用 requestfactory 获取对象时,即使不使用 with(),它也总是获取所有依赖项。 我创建了一个测试用例:
public class TestObjectC {
String c;
TestObjectB b;
public TestObjectC() {
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public TestObjectB getB() {
return b;
}
public void setB(TestObjectB b) {
this.b = b;
}
}
和:
public class TestObjectB {
String b;
TestObjectA a;
public TestObjectB() {
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public TestObjectA getA() {
return a;
}
public void setA(TestObjectA a) {
this.a = a;
}
}
我的代理是:
@ProxyForName(value = "com.myproject.testing.TestObjectC")
public interface TestObjectCProxy extends ValueProxy {
public String getC();
public void setC(String c);
public TestObjectBProxy getB();
public void setB(TestObjectBProxy b);
}
和:
@ProxyForName(value = "com.myproject.testing.TestObjectB")
public interface TestObjectBProxy extends ValueProxy {
public String getB();
public void setB(String b);
public TestObjectAProxy getEins();
public void setEins(TestObjectAProxy eins);
}
当我触发请求时, requestFactory.myRequest().getTest() .fire(new Receiver() {
@Override
public void onSuccess(TestObjectCProxy response) {
System.out.println(response.getB());
System.out.println(response.getB().getB());
}
});
一切正常。我不应该得到一个空指针异常吗? 我需要使用 ProxyFor(...) 因为代理与我的数据对象位于不同的项目中。我在服务器端使用依赖注入来加载服务类。 这会成为问题吗?
问候, 阿恩
when I fetch an object using the requestfactory it always fetches all dependencies even without using with().
I created a testcase:
public class TestObjectC {
String c;
TestObjectB b;
public TestObjectC() {
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}
public TestObjectB getB() {
return b;
}
public void setB(TestObjectB b) {
this.b = b;
}
}
and:
public class TestObjectB {
String b;
TestObjectA a;
public TestObjectB() {
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
public TestObjectA getA() {
return a;
}
public void setA(TestObjectA a) {
this.a = a;
}
}
My Proxies are:
@ProxyForName(value = "com.myproject.testing.TestObjectC")
public interface TestObjectCProxy extends ValueProxy {
public String getC();
public void setC(String c);
public TestObjectBProxy getB();
public void setB(TestObjectBProxy b);
}
and:
@ProxyForName(value = "com.myproject.testing.TestObjectB")
public interface TestObjectBProxy extends ValueProxy {
public String getB();
public void setB(String b);
public TestObjectAProxy getEins();
public void setEins(TestObjectAProxy eins);
}
when I fire my Request :
requestFactory.myRequest().getTest()
.fire(new Receiver() {
@Override
public void onSuccess(TestObjectCProxy response) {
System.out.println(response.getB());
System.out.println(response.getB().getB());
}
});
everything works fine. Shouldn't I get a Nullpointer-Exception?
I need to use ProxyFor(...) because the Proxies are in a different project than my dataobjects. And I use Dependency-Injection on server-side to load the service classes.
Can any of this be a problem?
Regards,
arne
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管这并没有引起那么多人的兴趣,但也许答案会对某人有所帮助。我不知道的是 ValueProxy 总是会获取它们的所有属性。如果需要延迟获取,则只能使用 EntityProxy。
Even though this didn't catch so many peoples interest maybe the answer will help someone. What I didn't know is that ValueProxys are always fetched with all their attributes. Only EntityProxys can be used if lazy fetching is necessary.