0

当我尝试发送使用 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();
}
}
4

1 回答 1

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();
}
于 2012-06-04T10:12:42.773 回答