Java 类com.google.gwt.user.client.rpc.SerializationStreamFactory 实例源码

项目:gwt-syncproxy    文件:RequestCallbackAdapter.java   
public RequestCallbackAdapter(SerializationStreamFactory streamFactory,
    String methodName, RpcStatsContext statsContext,
    AsyncCallback<T> callback,
    RpcTokenExceptionHandler tokenExceptionHandler,
    ResponseReader responseReader) {
  assert (streamFactory != null);
  assert (callback != null);
  assert (responseReader != null);

  this.streamFactory = streamFactory;
  this.callback = callback;
  this.methodName = methodName;
  this.statsContext = statsContext;
  this.responseReader = responseReader;
  this.tokenExceptionHandler = tokenExceptionHandler;
}
项目:fullmetalgalaxy    文件:AppMain.java   
private Object deserialize(String p_serial)
{
  Object object = null;
  try
  {
    // Decode game data
    SerializationStreamFactory factory = GWT.create( GameServices.class );
    SerializationStreamReader reader = factory.createStreamReader( p_serial );
    object = reader.readObject();
    if( object != null )
    {
      return object;
    }
  } catch( Exception e )
  {
    AppRoot.logger.severe( e.getMessage() );
  }
  return object;
}
项目:fullmetalgalaxy    文件:ChatEngine.java   
public void loadPresenceRoomFromPage()
{
  String strRoom = ClientUtil.getJSString( "fmp_room" );
  if( strRoom != null && !strRoom.equalsIgnoreCase( "null" ) )
  {
    try
    {
      SerializationStreamFactory factory = GWT.create( GameServices.class );
      SerializationStreamReader reader;
      reader = factory.createStreamReader( strRoom );
      Object object = reader.readObject();
      if( object instanceof PresenceRoom )
      {
        m_presenceRoom = (PresenceRoom)object;
      }
    } catch( SerializationException e )
    {
      AppRoot.logger.log( Level.WARNING, e.getMessage() );
    }
  }

}
项目:gwittir    文件:ErrorCodeCreator.java   
public <T extends Throwable> String encode(T throwable) throws SerializationException {
    SerializationStreamFactory streamFactory = GWT.create(RemoteLoggingService.class);
    SerializationStreamWriter streamWriter = streamFactory.createStreamWriter();
    streamWriter.writeObject(throwable);
    String serializedObj = streamWriter.toString();
    HuffmanEncoder encoder = new HuffmanEncoder();
    HashMap<Character,String> map =  new HashMap<Character,String>();

    SerializationStreamFactory compressedFactory = GWT.create(Compressed.class);
    streamWriter = compressedFactory.createStreamWriter();
    streamWriter.writeObject(map);
    streamWriter.writeObject(serializedObj);
    byte[] data = encoder.encode(serializedObj, map);

    String encoded = Base64.encode(data);
    return encoded;
}
项目:gwt-syncproxy    文件:SyncProxy.java   
/**
 * @deprecated since 0.5, {@link #createProxy(Class, ProxySettings)} with
 *             {@link ProxySettings#setRemoteServiceRelativePath(String)},
 *             {@link ProxySettings#setCookieManager(CookieManager)},
 *             {@link ProxySettings#policyName}, and
 *             {@link ProxySettings#setWaitForInvocation(boolean)}
 */
@Deprecated
@SuppressWarnings("unchecked")
public static <ServiceIntf> ServiceIntf newProxyInstance(
        Class<ServiceIntf> serviceIntf, String moduleBaseURL,
        String serverBaseUrl, String remoteServiceRelativePath,
        String policyName, CookieManager cookieManager,
        boolean waitForInvocation) {
    if (cookieManager == null) {
        cookieManager = DEFAULT_COOKIE_MANAGER;
    }

    if (policyName == null) {
        try {
            POLICY_MAP.putAll(RpcPolicyFinder
                    .fetchSerializationPolicyName(moduleBaseURL));
            policyName = POLICY_MAP.get(serviceIntf.getName());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    ServiceIntf i = (ServiceIntf) Proxy.newProxyInstance(SyncProxy.class
            .getClassLoader(), new Class[] { serviceIntf,
            ServiceDefTarget.class, HasRpcToken.class,
            SerializationStreamFactory.class },
            new RemoteServiceInvocationHandler(serverBaseUrl,
                    remoteServiceRelativePath, policyName, cookieManager,
                    waitForInvocation));
    return i;
}
项目:fullmetalgalaxy    文件:GameEngine.java   
@Override
public void onModuleLoad()
{
  AppMain.instance().startLoading();
  restoreHMIFlags();

  String strModel = ClientUtil.getJSString( "fmp_model" );
  if( strModel != null )
  {
    try
    {
      SerializationStreamFactory factory = GWT.create( GameServices.class );
      SerializationStreamReader reader;
      reader = factory.createStreamReader( strModel );
      Object object = reader.readObject();
      if( object instanceof ModelFmpInit )
      {
        loadGameCallback.onSuccess( (ModelFmpInit)object );
      }
    } catch( SerializationException e )
    {
      AppRoot.logger.log( Level.WARNING, e.getMessage() );
    }
  }

  if( AppMain.instance().isLoading() )
  {
    // well, model init wasn't found in jsp => ask it with standard RPC call
    String gameId = ClientUtil.getUrlParameter( "id" ); 
    if( gameId != null )
    {
      AppMain.getRpcService().getModelFmpInit( gameId, loadGameCallback );
    }
    else
    {
      // load an empty game
      AppMain.instance().stopLoading();
    }
  }
}
项目:gwt-syncproxy    文件:RequestCallbackAdapter.java   
public RequestCallbackAdapter(SerializationStreamFactory streamFactory,
    String methodName, RpcStatsContext statsContext,
    AsyncCallback<T> callback, ResponseReader responseReader) {
  this(streamFactory, methodName, statsContext, callback, null,
      responseReader);
}
项目:gwt-syncproxy    文件:SyncProxy.java   
/**
 * Creates the actual Sync and Async ProxyInterface for the service with the
 * specified options.This method assumes your service is annotated with
 * {@link RemoteServiceRelativePath} and that you have appropriately set the
 * base url: {@link #setBaseURL(String)}. See
 * {@link #suppressRelativePathWarning(boolean)} in the event your service
 * is not annotated with {@link RemoteServiceRelativePath}.
 *
 * @since 0.5
 * @param serviceIntf
 *            the service to create a proxy for
 * @param moduleBaseUrl
 *            the server's base url
 * @param remoteServiceRelativePath
 *            the relative path for this service
 * @param policyName
 *            Policy name (*.gwt.rpc) generated by GWT RPC backend
 * @param cookieManager
 *            the cookie manager
 * @param waitForInvocation
 * @return
 */
@SuppressWarnings("unchecked")
public static <ServiceIntf> ServiceIntf createProxy(
        Class<ServiceIntf> serviceIntf, ProxySettings settings) {
    logger.config("Setting up Proxy: " + serviceIntf.getName());
    defaultUnsetSettings(serviceIntf, settings);
    return (ServiceIntf) Proxy.newProxyInstance(
            SyncProxy.class.getClassLoader(), new Class[] { serviceIntf,
                ServiceDefTarget.class, HasRpcToken.class,
                SerializationStreamFactory.class,
                    HasProxySettings.class },
            new RemoteServiceInvocationHandler(settings));
}