當前位置: 首頁>>代碼示例>>Java>>正文


Java IsSerializable類代碼示例

本文整理匯總了Java中com.google.gwt.user.client.rpc.IsSerializable的典型用法代碼示例。如果您正苦於以下問題:Java IsSerializable類的具體用法?Java IsSerializable怎麽用?Java IsSerializable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IsSerializable類屬於com.google.gwt.user.client.rpc包,在下文中一共展示了IsSerializable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isInstantiable

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
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;
}
 
開發者ID:Putnami,項目名稱:putnami-web-toolkit,代碼行數:22,代碼來源:CommandSerializationPolicy.java

示例2: execute

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
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());
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:32,代碼來源:GwtRpcServlet.java

示例3: validateDeserialize

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@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.");
	}
}
 
開發者ID:Putnami,項目名稱:putnami-web-toolkit,代碼行數:9,代碼來源:CommandSerializationPolicy.java

示例4: validateSerialize

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@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.");
	}
}
 
開發者ID:Putnami,項目名稱:putnami-web-toolkit,代碼行數:9,代碼來源:CommandSerializationPolicy.java

示例5: doGet

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@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);

    }

}
 
開發者ID:inepex,項目名稱:ineform,代碼行數:32,代碼來源:SessionMonitorServlet.java

示例6: StorageKeyProviderModel

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
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;
}
 
開發者ID:seanchenxi,項目名稱:gwt-storage,代碼行數:9,代碼來源:StorageKeyProviderModel.java

示例7: GwtRpcException

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
public GwtRpcException(String message, Throwable cause) {
	super(message, cause);
	if (cause instanceof IsSerializable)
		iCause = cause;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:6,代碼來源:GwtRpcException.java

示例8: run

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@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;
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:54,代碼來源:GwtRpcServlet.java

示例9: fromJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
void fromJson(String json, IsSerializable objType,
AsyncCallback<IsSerializable> callback);
 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:3,代碼來源:GwtGsonServiceAsync.java

示例10: toJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@Override
public String toJson(IsSerializable obj) {
	return gson.toJson(obj);
}
 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:5,代碼來源:GwtGsonServiceImpl.java

示例11: fromJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
@Override
public IsSerializable fromJson(String json, IsSerializable type) {
	return (IsSerializable) gson.fromJson(json, type.getClass());
}
 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:5,代碼來源:GwtGsonServiceImpl.java

示例12: toJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
/**
 * 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);
 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:9,代碼來源:GwtGsonService.java

示例13: fromJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
/**
 * 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);
 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:9,代碼來源:GwtGsonService.java

示例14: isSerializableKey

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:seanchenxi,項目名稱:gwt-storage,代碼行數:11,代碼來源:StorageKeyFactory.java

示例15: toJson

import com.google.gwt.user.client.rpc.IsSerializable; //導入依賴的package包/類
void toJson(IsSerializable src, AsyncCallback<String> callback); 
開發者ID:heroandtn3,項目名稱:bGwtGson,代碼行數:2,代碼來源:GwtGsonServiceAsync.java


注:本文中的com.google.gwt.user.client.rpc.IsSerializable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。