Example usage for com.google.gwt.user.client.rpc SerializationStreamFactory createStreamReader

List of usage examples for com.google.gwt.user.client.rpc SerializationStreamFactory createStreamReader

Introduction

In this page you can find the example usage for com.google.gwt.user.client.rpc SerializationStreamFactory createStreamReader.

Prototype

SerializationStreamReader createStreamReader(String encoded) throws SerializationException;

Source Link

Document

Creates a SerializationStreamReader for the encoded string.

Usage

From source file:com.fullmetalgalaxy.client.AppMain.java

License:Open Source License

private Object deserialize(String p_serial) {
    Object object = null;/*w  ww . ja  v  a  2s .  c  o m*/
    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;
}

From source file:com.fullmetalgalaxy.client.chat.ChatEngine.java

License:Open Source License

public void loadPresenceRoomFromPage() {
    String strRoom = ClientUtil.getJSString("fmp_room");
    if (strRoom != null && !strRoom.equalsIgnoreCase("null")) {
        try {//w w w  .  j a  va 2 s.  c  o m
            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());
        }
    }

}

From source file:com.fullmetalgalaxy.client.game.GameEngine.java

License:Open Source License

@Override
public void onModuleLoad() {
    AppMain.instance().startLoading();//from   w  ww  . j a va2  s. co  m
    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();
        }
    }
}

From source file:com.mynotes.client.GWTHelper.java

License:Open Source License

@SuppressWarnings("unchecked")
public static <T> T getSerializedObject(String name) throws SerializationException {
    String serialized = getString(name);
    // Need one service class, not using GIN (not important)
    SerializationStreamFactory ssf = GWT.create(LoginService.class);

    return (T) ssf.createStreamReader(serialized).readObject();
}

From source file:de.novanic.eventservice.client.connection.strategy.connector.streaming.GWTStreamingClientConnector.java

License:Open Source License

/**
 * De-serializes an occurred event with GWT serialization methods.
 * @param anEvent event to de-serialize//from   w  ww. j  ava 2 s.  c  o  m
 * @return de-serialized event
 */
protected DomainEvent deserializeEvent(String anEvent) {
    try {
        SerializationStreamFactory theSerializationStreamFactory = GWT.create(EventService.class);
        SerializationStreamReader theSerializationStreamReader = theSerializationStreamFactory
                .createStreamReader(anEvent);
        return (DomainEvent) theSerializationStreamReader.readObject();
    } catch (SerializationException e) {
        throw new RemoteEventServiceRuntimeException("Error on de-serializing event \"" + anEvent + "\"!", e);
    }
}

From source file:org.kuali.student.core.organization.ui.client.view.OrgEntryPoint.java

License:Educational Community License

@SuppressWarnings("unchecked")
public <T> T getSerializedObject(String name) throws SerializationException {
    String serialized = BrowserUtils.getString(name);
    SerializationStreamFactory ssf = GWT.create(MessagesRpcService.class); // magic
    return (T) ssf.createStreamReader(serialized).readObject();
}

From source file:org.kuali.student.lum.lu.ui.main.client.LUMMainEntryPoint.java

License:Educational Community License

@SuppressWarnings("unchecked")
public <T> T getMsgSerializedObject(String key) throws SerializationException {
    String serialized = BrowserUtils.getString(key);
    SerializationStreamFactory ssf = GWT.create(MessagesRpcService.class); // magic
    SerializationStreamReader ssr = ssf.createStreamReader(serialized);
    T ret = (T) ssr.readObject();//from   w  w  w  . j  a v  a2s. com
    return ret;
}

From source file:org.opencms.gwt.client.rpc.CmsRpcPrefetcher.java

License:Open Source License

/**
 * Deserializes the prefetched RPC data with the given name.<p>
 * /*ww w .  j  a  va 2s.com*/
 * @param asyncService the RPC service instance
 * @param name the global variable name
 * 
 * @return the prefetched RPC data
 */
public static Object getSerializedObject(Object asyncService, String name) {

    try {
        SerializationStreamFactory ssf = (SerializationStreamFactory) asyncService;
        return ssf.createStreamReader(getString(name)).readObject();
    } catch (SerializationException e) {
        // should never happen
        CmsLog.log(e.getLocalizedMessage());
    }
    return null;
}