requestfactorygwt-2.4

Requestfactory always fetching all Dependencies


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


Solution

  • 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.