类org.springframework.core.serializer.support.SerializationDelegate源码实例Demo

下面列出了怎么用org.springframework.core.serializer.support.SerializationDelegate的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-analysis-note   文件: ConcurrentMapCache.java
private Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try {
		serialization.serialize(storeValue, out);
		return out.toByteArray();
	}
	finally {
		out.close();
	}
}
 
源代码2 项目: spring-analysis-note   文件: ConcurrentMapCache.java
private Object deserializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
	ByteArrayInputStream in = new ByteArrayInputStream((byte[]) storeValue);
	try {
		return serialization.deserialize(in);
	}
	finally {
		in.close();
	}
}
 
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
	this.serialization = new SerializationDelegate(classLoader);
	// Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
	if (isStoreByValue()) {
		recreateCaches();
	}
}
 
/**
 * Create a new ConcurrentMapCache instance for the specified cache name.
 * @param name the name of the cache
 * @return the ConcurrentMapCache (or a decorator thereof)
 */
protected Cache createConcurrentMapCache(String name) {
	SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null);
	return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256),
			isAllowNullValues(), actualSerialization);

}
 
private Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try {
		serialization.serialize(storeValue, out);
		return out.toByteArray();
	}
	finally {
		out.close();
	}
}
 
private Object deserializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
	ByteArrayInputStream in = new ByteArrayInputStream((byte[]) storeValue);
	try {
		return serialization.deserialize(in);
	}
	finally {
		in.close();
	}
}
 
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
	this.serialization = new SerializationDelegate(classLoader);
	// Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
	if (isStoreByValue()) {
		recreateCaches();
	}
}
 
/**
 * Create a new ConcurrentMapCache instance for the specified cache name.
 * @param name the name of the cache
 * @return the ConcurrentMapCache (or a decorator thereof)
 */
protected Cache createConcurrentMapCache(String name) {
	SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null);
	return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256),
			isAllowNullValues(), actualSerialization);

}
 
源代码9 项目: lams   文件: ConcurrentMapCacheManager.java
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
	this.serialization = new SerializationDelegate(classLoader);
	// Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
	if (isStoreByValue()) {
		recreateCaches();
	}
}
 
源代码10 项目: lams   文件: ConcurrentMapCacheManager.java
/**
 * Create a new ConcurrentMapCache instance for the specified cache name.
 * @param name the name of the cache
 * @return the ConcurrentMapCache (or a decorator thereof)
 */
protected Cache createConcurrentMapCache(String name) {
	SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null);
	return new ConcurrentMapCache(name, new ConcurrentHashMap<Object, Object>(256),
			isAllowNullValues(), actualSerialization);

}
 
private ConcurrentMapCache createCacheWithStoreByValue() {
	return new ConcurrentMapCache(CACHE_NAME, this.nativeCache, true,
			new SerializationDelegate(ConcurrentMapCacheTests.class.getClassLoader()));
}
 
private ConcurrentMapCache createCacheWithStoreByValue() {
	return new ConcurrentMapCache(CACHE_NAME, this.nativeCache, true,
			new SerializationDelegate(ConcurrentMapCacheTests.class.getClassLoader()));
}
 
源代码13 项目: entando-core   文件: CustomConcurrentMapCache.java
public CustomConcurrentMapCache(String name, ConcurrentMap<Object, Object> store, boolean allowNullValues, SerializationDelegate serialization) {
    super(name, store, allowNullValues, serialization);
}
 
源代码14 项目: spring-analysis-note   文件: ConcurrentMapCache.java
/**
 * Create a new ConcurrentMapCache with the specified name and the
 * given internal {@link ConcurrentMap} to use. If the
 * {@link SerializationDelegate} is specified,
 * {@link #isStoreByValue() store-by-value} is enabled
 * @param name the name of the cache
 * @param store the ConcurrentMap to use as an internal store
 * @param allowNullValues whether to allow {@code null} values
 * (adapting them to an internal null holder value)
 * @param serialization the {@link SerializationDelegate} to use
 * to serialize cache entry or {@code null} to store the reference
 * @since 4.3
 */
protected ConcurrentMapCache(String name, ConcurrentMap<Object, Object> store,
		boolean allowNullValues, @Nullable SerializationDelegate serialization) {

	super(allowNullValues);
	Assert.notNull(name, "Name must not be null");
	Assert.notNull(store, "Store must not be null");
	this.name = name;
	this.store = store;
	this.serialization = serialization;
}
 
源代码15 项目: java-technology-stack   文件: ConcurrentMapCache.java
/**
 * Create a new ConcurrentMapCache with the specified name and the
 * given internal {@link ConcurrentMap} to use. If the
 * {@link SerializationDelegate} is specified,
 * {@link #isStoreByValue() store-by-value} is enabled
 * @param name the name of the cache
 * @param store the ConcurrentMap to use as an internal store
 * @param allowNullValues whether to allow {@code null} values
 * (adapting them to an internal null holder value)
 * @param serialization the {@link SerializationDelegate} to use
 * to serialize cache entry or {@code null} to store the reference
 * @since 4.3
 */
protected ConcurrentMapCache(String name, ConcurrentMap<Object, Object> store,
		boolean allowNullValues, @Nullable SerializationDelegate serialization) {

	super(allowNullValues);
	Assert.notNull(name, "Name must not be null");
	Assert.notNull(store, "Store must not be null");
	this.name = name;
	this.store = store;
	this.serialization = serialization;
}
 
源代码16 项目: lams   文件: ConcurrentMapCache.java
/**
 * Create a new ConcurrentMapCache with the specified name and the
 * given internal {@link ConcurrentMap} to use. If the
 * {@link SerializationDelegate} is specified,
 * {@link #isStoreByValue() store-by-value} is enabled
 * @param name the name of the cache
 * @param store the ConcurrentMap to use as an internal store
 * @param allowNullValues whether to allow {@code null} values
 * (adapting them to an internal null holder value)
 * @param serialization the {@link SerializationDelegate} to use
 * to serialize cache entry or {@code null} to store the reference
 * @since 4.3
 */
protected ConcurrentMapCache(String name, ConcurrentMap<Object, Object> store,
		boolean allowNullValues, SerializationDelegate serialization) {

	super(allowNullValues);
	Assert.notNull(name, "Name must not be null");
	Assert.notNull(store, "Store must not be null");
	this.name = name;
	this.store = store;
	this.serialization = serialization;
}
 
 类所在包
 类方法
 同包方法