当使用带有JsonRpc方言的ValueProxy参数时,RF'使用null RequestContext'解冻bean

时间:2012-06-04 10:01:22

标签: gwt requestfactory autobean

当我尝试发送使用ValueProxy参数的请求时,我得到了这个'Unforzen bean'异常。我不知道这个例外是不是因为使用JsonDialect的RF错误或者我做错了什么......¿有些帮助吗?

java.lang.AssertionError: Unfrozen bean with null RequestContext
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkStreamsNotCrossed(AbstractRequestContext.java:981)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:509)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.edit(AbstractRequestContext.java:502)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.retainArg(AbstractRequestContext.java:1230)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.access$2(AbstractRequestContext.java:1223)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$JsonRpcPayloadDialect.addInvocation(AbstractRequestContext.java:202)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.addInvocation(AbstractRequestContext.java:661)
at es.xxxx.taller.client.Taller_SomeRequestContextImpl.SomeCall(Taller_SomeRequestContextImpl.java:29)
at es.xxxx.taller.client.Taller.onModuleLoad(Taller.java:417)



public class SomeEntryPoint implements EntryPoint {

@JsonRpcProxy
public interface SomeProxy extends ValueProxy {
    String getSomeProperty();
    void setSomeProperty(String value);
}

@JsonRpcProxy
public interface VoidProxy extends ValueProxy {
}

public interface SomeAutoBeanFactory extends AutoBeanFactory {
    SomeAutoBeanFactory INSTANCE = GWT.create(SomeAutoBeanFactory.class);

    AutoBean<SomeProxy> someProxy();
}

public interface SomeRequestFactory extends RequestFactory {
    SomeRequestFactory INSTANCE = GWT.create(SomeRequestFactory.class);

    SomeRequestContext context();
}

@JsonRpcService
public interface SomeRequestContext extends RequestContext {

    SomeCall SomeCall(SomeProxy proxy);

    @JsonRpcWireName(value = "SomeCall")
    public interface SomeCall extends Request<VoidProxy> {
    }
}

public void onModuleLoad() {

    SomeProxy someProxy = SomeAutoBeanFactory.INSTANCE.someProxy().as();

    someProxy.setSomeProperty("someValue");

    SomeRequestFactory.INSTANCE.context().SomeCall(someProxy).fire();
}
}

1 个答案:

答案 0 :(得分:1)

代理应该由RequestContext创建,而不是AutoBeanFactory!使用JsonRpc方言不会改变您使用RequestFactory的方式。

public void onModuleLoad() {
   SomeRequestContext ctx = SomeRequestFactory.INSTANCE.context();
   SomeProxy someProxy = ctx.create(SomeProxy.class);
   someProxy.setSomeProperty("someValue");
   ctx.SomeCall(someProxy).fire();
}