public String generateStringKeyFor(final Object key) throws IOException { if (key instanceof String) { return (String) key; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new OOS(bos, oscSerializer); writeStringKey(key, oos); oos.close(); return bos.toString(0x00); }
@Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int code = decodeInt(this); return oscSerializer.getObjectStreamClassFor(code, loader); }
@Override protected void writeClassDescriptor(final ObjectStreamClass desc) throws IOException { int code = oscSerializer.getMappingFor(desc); encodeInt(this, code); } }
public ClusteredEventReplicator(Ehcache cache, TerracottaConfiguration.ValueMode valueMode) { this.valueMode = valueMode; switch (valueMode) { case IDENTITY: this.dsoSerialization = null; this.elementSerialization = null; break; case SERIALIZATION: this.dsoSerialization = new DsoSerializationStrategy(); this.elementSerialization = new ElementSerializationStrategy(); break; default: throw new UnsupportedOperationException("Value mode " + valueMode + " isn't supported"); } initializeOnLoad(); initializeTransients(cache); }
private static DsoSerializationStrategy getSingletonDsoSerializationStrategy() { ConcurrentMap<String, Object> root = new ConcurrentDistributedMap<String, Object>(LockType.WRITE, new HashcodeLockStrategy(), 8); ManagerUtil.beginLock(ROOT_NAME_UTILITIES, Manager.LOCK_TYPE_WRITE); try { root = (ConcurrentMap<String, Object>) ManagerUtil.lookupOrCreateRoot(ROOT_NAME_UTILITIES, root); root.putIfAbsent(DsoSerializationStrategy.class.getName(), new DsoSerializationStrategy()); setNotClearable(root); } finally { ManagerUtil.commitLock(ROOT_NAME_UTILITIES, Manager.LOCK_TYPE_WRITE); } return (DsoSerializationStrategy) root.get(DsoSerializationStrategy.class.getName()); }
public String generateStringKeyFor(final Object key) throws IOException { if (key instanceof String) { return (String) key; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new OOS(bos, oscSerializer); writeStringKey(key, oos); oos.close(); return bos.toString(0x00); }
@Override protected void writeClassDescriptor(final ObjectStreamClass desc) throws IOException { int code = oscSerializer.getMappingFor(desc); encodeInt(this, code); } }
@Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int code = decodeInt(this); return oscSerializer.getObjectStreamClassFor(code, loader); }
public String generateStringKeyFor(final Object key) throws IOException { if (key instanceof String) { return (String) key; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new OOS(bos, oscSerializer); writeStringKey(key, oos); oos.close(); return bos.toString(0x00); }
@Override protected void writeClassDescriptor(final ObjectStreamClass desc) throws IOException { String name = desc.getName(); int code = oscSerializer.getMappingFor(name); encodeInt(this, code); } }
@Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int code = decodeInt(this); return oscSerializer.getObjectStreamClassFor(code, loader); }
public String generateStringKeyFor(final Object key) throws IOException { if (key instanceof String) { return (String) key; } ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new OOS(bos, oscSerializer); writeStringKey(key, oos); oos.close(); return bos.toString(0x00); }
@Override protected void writeClassDescriptor(final ObjectStreamClass desc) throws IOException { String name = desc.getName(); int code = oscSerializer.getMappingFor(name); encodeInt(this, code); } }
@Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { int code = decodeInt(this); if (localOnly) { ObjectStreamClass osc = oscSerializer.localGetObjectStreamClassFor(code); if (osc == null) { throw new ObjectStreamClassNotLocalException(); } return osc; } else { return oscSerializer.getObjectStreamClassFor(code, loader); } }
/** * Special cases the CacheKey class in order to reduce the size of the generated Strings. */ @Override protected void writeStringKey(final Object key, final ObjectOutputStream oos) throws IOException { if (key instanceof CacheKey) { CacheKey cacheKey = (CacheKey) key; oos.writeInt(getOrCreateMapping(cacheKey.getEntityOrRoleName())); oos.writeObject(cacheKey.getKey()); } else { super.writeStringKey(key, oos); } }