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

项目:putnami-web-toolkit    文件:CommandSerializationPolicy.java   
private boolean isInstantiable(Class<?> clazz) {
    if (clazz.isPrimitive()) {
        return true;
    }
    if (clazz.isEnum()) {
        return true;
    }
    if (Throwable.class.isAssignableFrom(clazz)) {
        return true;
    }
    if (clazz.isArray()) {
        return this.isInstantiable(clazz.getComponentType());
    }
    if (IsSerializable.class.isAssignableFrom(clazz)) {
        return true;
    }
    if (Serializable.class.isAssignableFrom(clazz)) {
        return true;
    }
    return SerializabilityUtil.hasCustomFieldSerializer(clazz) != null;
}
项目:unitimes    文件:GwtRpcServlet.java   
public static <T extends GwtRpcResponse> T execute(GwtRpcRequest<T> request, ApplicationContext applicationContext, SessionContext sessionContext) throws GwtRpcException {
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation((Class<GwtRpcRequest<T>>)request.getClass(), applicationContext);

        // execute request
        T response = implementation.execute(request, sessionContext);

        // return response
        return response;
    } catch (Throwable t) {
        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            GwtRpcException e = (GwtRpcException)t;
            if (e.hasCause())
                sLog.warn("Seen server exception: " + e.getMessage(), e.getCause());
            else
                sLog.info("Seen server exception: " + e.getMessage());
            throw e;
        }
        if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            throw new GwtRpcException(t.getMessage(), t);
        }
        sLog.error("Seen exception: " + t.getMessage(), t);
        throw new GwtRpcException(t.getMessage());
    }
}
项目:unitime    文件:GwtRpcServlet.java   
public static <T extends GwtRpcResponse> T execute(GwtRpcRequest<T> request, ApplicationContext applicationContext, SessionContext sessionContext) throws GwtRpcException {
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation((Class<GwtRpcRequest<T>>)request.getClass(), applicationContext);

        // execute request
        T response = implementation.execute(request, sessionContext);

        // return response
        return response;
    } catch (Throwable t) {
        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            GwtRpcException e = (GwtRpcException)t;
            if (e.hasCause())
                sLog.warn("Seen server exception: " + e.getMessage(), e.getCause());
            else
                sLog.info("Seen server exception: " + e.getMessage());
            throw e;
        }
        if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            throw new GwtRpcException(t.getMessage(), t);
        }
        sLog.error("Seen exception: " + t.getMessage(), t);
        throw new GwtRpcException(t.getMessage());
    }
}
项目:putnami-web-toolkit    文件:CommandSerializationPolicy.java   
@Override
public void validateDeserialize(Class<?> clazz) throws SerializationException {
    if (!this.isInstantiable(clazz)) {
        throw new SerializationException("Type '" + clazz.getName() + "' was not assignableJRE_BLACKSET to '"
            + IsSerializable.class.getName() + "' and did not have a custom field serializer. "
            + "For security purposes, this type will not be deserialized.");
    }
}
项目:putnami-web-toolkit    文件:CommandSerializationPolicy.java   
@Override
public void validateSerialize(Class<?> clazz) throws SerializationException {
    if (!this.isInstantiable(clazz)) {
        throw new SerializationException("Type '" + clazz.getName() + "' was not assignable to '"
            + IsSerializable.class.getName() + "' and did not have a custom field serializer."
            + "For security purposes, this type will not be serialized.");
    }
}
项目:ineform    文件:SessionMonitorServlet.java   
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException,
    IOException {
    resp.getWriter().println("Number of active sessions: " + numberOfSessions.get());
    List<HttpSession> copy;
    synchronized (sessions) {
        copy = new ArrayList<HttpSession>(sessions);
    }
    for (HttpSession sess : copy) {

        Long approximateSizeInByte = 0L;
        Enumeration<String> attributeNames = sess.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            String name = attributeNames.nextElement();
            if (sess.getAttribute(name) instanceof IsSerializable
                || sess.getAttribute(name) instanceof Serializable) {
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                ObjectOutput out = new ObjectOutputStream(bos);

                out.writeObject(sess.getAttribute(name));
                byte[] bytes = bos.toByteArray();
                approximateSizeInByte += bytes.length;
            }

        }
        resp.getWriter().println("Size of " + sess.getId() + ": " + approximateSizeInByte);

    }

}
项目:gwt-storage    文件:StorageKeyProviderModel.java   
public StorageKeyProviderModel(TreeLogger logger, JClassType providerType) {
  this.providerType = providerType;
  this.storageKeyGenericType = providerType.getOracle().findType(StorageKey.class.getCanonicalName()).isGenericType();
  this.serializableIntf = providerType.getOracle().findType(Serializable.class.getCanonicalName()).isInterface();
  this.isSerializableIntf = providerType.getOracle().findType(IsSerializable.class.getCanonicalName()).isInterface();
  this.methods = new ArrayList<>();
  this.logger = logger;
}
项目:unitimes    文件:GwtRpcException.java   
public GwtRpcException(String message, Throwable cause) {
    super(message, cause);
    if (cause instanceof IsSerializable)
        iCause = cause;
}
项目:unitimes    文件:GwtRpcServlet.java   
@Override
public <T extends GwtRpcResponse> T execute(GwtRpcRequest<T> request) throws GwtRpcException {
    // start time
    long t0 = JProf.currentTimeMillis();
    GwtRpcLogging logging = null;
    // create helper
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation(request);

        // get logging
        logging = implementation.getClass().getAnnotation(GwtRpcLogging.class);

        // execute request
        T response = implementation.execute(request, getSessionContext());

        // log request
        log(request, response, null, JProf.currentTimeMillis() - t0, getSessionContext(), logging);

        // return response
        return response;
    } catch (Throwable t) {
        // log exception
        log(request, null, t, JProf.currentTimeMillis() - t0, getSessionContext(), logging);

        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            GwtRpcException e = (GwtRpcException)t;
            if (e.hasCause())
                sLog.warn("Seen server exception: " + e.getMessage(), e);
            else
                sLog.info("Seen server exception: " + e.getMessage());
            throw e;
        }
        if (t instanceof AccessDeniedException)
            throw new PageAccessException(t.getMessage(), t);
        if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            throw new GwtRpcException(t.getMessage(), t);
        }
        sLog.error("Seen exception: " + t.getMessage(), t);
        throw new GwtRpcException(t.getMessage());
    }
}
项目:unitimes    文件:GwtRpcServlet.java   
@Override
public void run() {
    iRunning = true;
    Localization.setLocale(iLocale);
    ApplicationProperties.setSessionId(iContext.getUser() == null ? null : iContext.getUser().getCurrentAcademicSessionId());
    // start time
    long t0 = JProf.currentTimeMillis();
    GwtRpcLogging logging = null;
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation(iRequest);

        // get logging
        logging = implementation.getClass().getAnnotation(GwtRpcLogging.class);

        // execute request
        iResponse = implementation.execute(iRequest, iContext);

        // log request
        log(iRequest, iResponse, null, JProf.currentTimeMillis() - t0, iContext, logging);
    } catch (Throwable t) {
        // log exception
        log(iRequest, null, t, JProf.currentTimeMillis() - t0, iContext, logging);

        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            iException = (GwtRpcException)t;
            if (iException.hasCause())
                sLog.warn("Seen server exception: " + t.getMessage(), t.getCause());
            else
                sLog.info("Seen server exception: " + t.getMessage());
        } else if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            iException = new GwtRpcException(t.getMessage(), t);
        } else {
            sLog.error("Seen exception: " + t.getMessage(), t);
            iException = new GwtRpcException(t.getMessage());
        }
    } finally {
        Localization.removeLocale();
        Formats.removeFormats();
        ApplicationProperties.setSessionId(null);
        _RootDAO.closeCurrentThreadSessions();
    }
    synchronized (this) {
        iWaitingThread = null;
        iRunning = false;
        iContext = null;
    }
}
项目:unitime    文件:GwtRpcException.java   
public GwtRpcException(String message, Throwable cause) {
    super(message, cause);
    if (cause instanceof IsSerializable)
        iCause = cause;
}
项目:unitime    文件:GwtRpcServlet.java   
@Override
public <T extends GwtRpcResponse> T execute(GwtRpcRequest<T> request) throws GwtRpcException {
    // start time
    long t0 = JProf.currentTimeMillis();
    GwtRpcLogging logging = null;
    // create helper
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation(request);

        // get logging
        logging = implementation.getClass().getAnnotation(GwtRpcLogging.class);

        // execute request
        T response = implementation.execute(request, getSessionContext());

        // log request
        log(request, response, null, JProf.currentTimeMillis() - t0, getSessionContext(), logging);

        // return response
        return response;
    } catch (Throwable t) {
        // log exception
        log(request, null, t, JProf.currentTimeMillis() - t0, getSessionContext(), logging);

        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            GwtRpcException e = (GwtRpcException)t;
            if (e.hasCause())
                sLog.warn("Seen server exception: " + e.getMessage(), e);
            else
                sLog.info("Seen server exception: " + e.getMessage());
            throw e;
        }
        if (t instanceof AccessDeniedException)
            throw new PageAccessException(t.getMessage(), t);
        if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            throw new GwtRpcException(t.getMessage(), t);
        }
        sLog.error("Seen exception: " + t.getMessage(), t);
        throw new GwtRpcException(t.getMessage());
    }
}
项目:unitime    文件:GwtRpcServlet.java   
@Override
public void run() {
    iRunning = true;
    Localization.setLocale(iLocale);
    ApplicationProperties.setSessionId(iContext.getUser() == null ? null : iContext.getUser().getCurrentAcademicSessionId());
    // start time
    long t0 = JProf.currentTimeMillis();
    GwtRpcLogging logging = null;
    try {
        // retrieve implementation from given request
        GwtRpcImplementation<GwtRpcRequest<T>, T> implementation = getImplementation(iRequest);

        // get logging
        logging = implementation.getClass().getAnnotation(GwtRpcLogging.class);

        // execute request
        iResponse = implementation.execute(iRequest, iContext);

        // log request
        log(iRequest, iResponse, null, JProf.currentTimeMillis() - t0, iContext, logging);
    } catch (Throwable t) {
        // log exception
        log(iRequest, null, t, JProf.currentTimeMillis() - t0, iContext, logging);

        // re-throw exception as GwtRpcException or IsSerializable runtime exception
        if (t instanceof GwtRpcException) {
            iException = (GwtRpcException)t;
            if (iException.hasCause())
                sLog.warn("Seen server exception: " + t.getMessage(), t.getCause());
            else
                sLog.info("Seen server exception: " + t.getMessage());
        } else if (t instanceof IsSerializable) {
            if (t.getCause() != null)
                sLog.error("Seen server exception: " + t.getMessage(), t);
            else
                sLog.warn("Seen server exception: " + t.getMessage(), t);
            iException = new GwtRpcException(t.getMessage(), t);
        } else {
            sLog.error("Seen exception: " + t.getMessage(), t);
            iException = new GwtRpcException(t.getMessage());
        }
    } finally {
        Localization.removeLocale();
        Formats.removeFormats();
        ApplicationProperties.setSessionId(null);
        _RootDAO.closeCurrentThreadSessions();
    }
    synchronized (this) {
        iWaitingThread = null;
        iRunning = false;
        iContext = null;
    }
}
项目:bGwtGson    文件:GwtGsonServiceAsync.java   
void fromJson(String json, IsSerializable objType,
AsyncCallback<IsSerializable> callback);
项目:bGwtGson    文件:GwtGsonServiceImpl.java   
@Override
public String toJson(IsSerializable obj) {
    return gson.toJson(obj);
}
项目:bGwtGson    文件:GwtGsonServiceImpl.java   
@Override
public IsSerializable fromJson(String json, IsSerializable type) {
    return (IsSerializable) gson.fromJson(json, type.getClass());
}
项目:bGwtGson    文件:GwtGsonService.java   
/**
 * This method serializes the specified object into its 
 * equivalent Json representation.
 * @param src the object for which Json representation 
 * is to be created setting for Gson
 * @return Json representation of {@code src}.
 */
public String toJson(IsSerializable src);
项目:bGwtGson    文件:GwtGsonService.java   
/**
 * This method deserializes the specified Json into 
 * an object of the specified class.
 * @param json the string from which the object is to be deserialized
 * @param objType an "empty" object to send object type via RPC
 * @return an IsSerializable object of type of objType from the string
 */
public IsSerializable fromJson(String json, IsSerializable objType);
项目:gwt-storage    文件:StorageKeyFactory.java   
/**
 * Returns IsSerializable type value's storage key.
 *
 * @param keyName name of storage key
 * @param <T> type of value
 * @return IsSerializable type value's storage key
 */
public static <T extends IsSerializable> StorageKey<T> isSerializableKey(String keyName){
    return new StorageKey<>(keyName, IsSerializable.class);
}
项目:bGwtGson    文件:GwtGsonServiceAsync.java   
void toJson(IsSerializable src, AsyncCallback<String> callback);