本文整理汇总了Java中com.hazelcast.nio.serialization.Serializer类的典型用法代码示例。如果您正苦于以下问题:Java Serializer类的具体用法?Java Serializer怎么用?Java Serializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Serializer类属于com.hazelcast.nio.serialization包,在下文中一共展示了Serializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
if (cacheEntryClass == null) {
return null;
}
try {
cacheEntryClass.getMethod("areLazyPropertiesUnfetched");
// If CacheEntry.areLazyPropertiesUnfetched() exists, we're on Hibernate 5
return new Hibernate5CacheEntrySerializer();
} catch (NoSuchMethodException e) {
// Otherwise, if there's no such method, we're on Hibernate 5.1+
return new Hibernate51CacheEntrySerializer();
}
}
示例2: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<LongAccumulator>() {
@Override
public int getTypeId() {
return SerializerHookConstants.LONG_ACC;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, LongAccumulator object) throws IOException {
out.writeLong(object.get());
}
@Override
public LongAccumulator read(ObjectDataInput in) throws IOException {
return new LongAccumulator(in.readLong());
}
};
}
示例3: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Tuple2>() {
@Override
public void write(ObjectDataOutput out, Tuple2 t) throws IOException {
out.writeObject(t.f0());
out.writeObject(t.f1());
}
@Override
public Tuple2 read(ObjectDataInput in) throws IOException {
return tuple2(in.readObject(), in.readObject());
}
@Override
public int getTypeId() {
return SerializerHookConstants.TUPLE2;
}
@Override
public void destroy() {
}
};
}
示例4: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Entry>() {
@Override
public int getTypeId() {
return SerializerHookConstants.MAP_ENTRY;
}
@Override
public void write(ObjectDataOutput out, Entry object) throws IOException {
out.writeObject(object.getKey());
out.writeObject(object.getValue());
}
@Override
public Entry read(ObjectDataInput in) throws IOException {
return entry(in.readObject(), in.readObject());
}
@Override
public void destroy() {
}
};
}
示例5: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<SnapshotBarrier>() {
@Override
public int getTypeId() {
return SerializerHookConstants.SNAPSHOT_BARRIER;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, SnapshotBarrier object) throws IOException {
out.writeLong(object.snapshotId());
}
@Override
public SnapshotBarrier read(ObjectDataInput in) throws IOException {
return new SnapshotBarrier(in.readLong());
}
};
}
示例6: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new StreamSerializer<Watermark>() {
@Override
public int getTypeId() {
return SerializerHookConstants.WATERMARK;
}
@Override
public void destroy() {
}
@Override
public void write(ObjectDataOutput out, Watermark object) throws IOException {
out.writeLong(object.timestamp());
}
@Override
public Watermark read(ObjectDataInput in) throws IOException {
return new Watermark(in.readLong());
}
};
}
示例7: newHzInstance
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
private HazelcastInstance newHzInstance(Class<?> typeClass, Serializer serializer) {
Config cfg = new Config();
cfg.setProperty("hazelcast.logging.type","log4j2");
cfg.getSerializationConfig().getSerializerConfigs().add(
new SerializerConfig()
.setTypeClass(typeClass)
.setImplementation(serializer)
);
NetworkConfig network = cfg.getNetworkConfig();
JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(true);
join.getTcpIpConfig().setEnabled(false);
network.getInterfaces().setEnabled(false);
MapConfig mapCfg = new MapConfig();
mapCfg.setName(MAP_NAME);
mapCfg.setInMemoryFormat(InMemoryFormat.OBJECT);
cfg.addMapConfig(mapCfg);
return Hazelcast.newHazelcastInstance(cfg);
}
示例8: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
if (cacheKeyClass != null) {
return new Hibernate4CacheKeySerializer();
}
return null;
}
示例9: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
if (cacheEntryClass == null) {
return null;
}
if (cacheEntryClass.isInterface()) {
//Hibernate 4.2 and later have a CacheEntry interface, not a class
return new Hibernate42CacheEntrySerializer();
}
//Hibernate 4.1 and earlier have a CacheEntry class
return new Hibernate41CacheEntrySerializer();
}
示例10: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
if (cacheEntryClass != null) {
return new Hibernate3CacheEntrySerializer();
}
return null;
}
示例11: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
if (cacheKeyClass != null) {
return new Hibernate3CacheKeySerializer();
}
return null;
}
示例12: makeBinary
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
public static <V> Serializer makeBinary(final Class<V> type) {
return new JsonSerializer<>(
type,
HzSerializationConstants.TYPEID_JSON_BINARY,
new SmileFactory()
);
}
示例13: makeBinary
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
public static <V> Serializer makeBinary(final Class<V> type) {
return new JsonSerializer<>(type, TYPEID_JSON_BINARY, new SmileFactory());
}
示例14: makePlain
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
public static <V> Serializer makePlain(final Class<V> type) {
return new JsonSerializer<>(type, TYPEID_JSON_PLAIN);
}
示例15: createSerializer
import com.hazelcast.nio.serialization.Serializer; //导入依赖的package包/类
@Override
public Serializer createSerializer() {
return new Hibernate52CacheEntrySerializer();
}