Example #1
0
  public static void initializeDefaultSessionProvider() {
    if (!MarshallingSessionProviderFactory.isMarshallingSessionProviderRegistered()) {
      MarshallingSessionProviderFactory.setMarshallingSessionProvider(
          new MarshallingSessionProvider() {
            @Override
            public MarshallingSession getEncoding() {
              return new MarshallerFramework.JSONMarshallingSession();
            }

            @Override
            public MarshallingSession getDecoding() {
              return new MarshallerFramework.JSONMarshallingSession();
            }

            @Override
            public boolean hasMarshaller(String fqcn) {
              return MarshallerFramework.getMarshallerFactory().getMarshaller(null, fqcn) != null;
            }

            @Override
            public Marshaller getMarshaller(String fqcn) {
              return MarshallerFramework.getMarshallerFactory().getMarshaller(null, fqcn);
            }
          });
    }
  }
Example #2
0
  @SuppressWarnings({"unchecked"})
  public static Map<String, Object> decodePayload(final Object value) {
    if (value == null) {
      return null;
    }
    if (!(value instanceof JSONObject)) {
      throw new RuntimeException("bad payload: " + value);
    }

    if (autoDemarshall) {
      return ErraiProtocol.decodePayload(GWTJSON.wrap((JSONObject) value));
    } else {
      nativeLog("using no-auto envelope demarshaller");
      return ErraiProtocolEnvelopeNoAutoMarshaller.INSTANCE.demarshall(
          GWTJSON.wrap((JSONObject) value), MarshallingSessionProviderFactory.getEncoding());
    }
  }