@Override public synchronized Object getKey(SerializationStrategy strategy) throws IOException, ClassNotFoundException { if (null == keyDeserialized) { keyDeserialized = strategy.deserialize(keySerialized); } return keyDeserialized; }
/** * Generates a String key for the supplied object. */ private String generateStringKeyFor(final Object obj) { try { return this.serializationStrategy.generateStringKeyFor(obj); } catch (Exception e) { throw new CacheException(e); } } }
public SerializationKeySnapshot(SerializationStrategy strategy, Object key) throws IOException { this.keySerialized = strategy.serialize(key); }
@Override public synchronized Object getKey(SerializationStrategy strategy) throws IOException, ClassNotFoundException { if (null == keyDeserialized) { keyDeserialized = strategy.deserialize(keySerialized); } return keyDeserialized; } }
/** * Generates a String key for the supplied object. */ String generateStringKeyFor(final Object obj) { String key; try { key = this.serializationStrategy.generateStringKeyFor(obj); } catch (Exception e) { throw new CacheException(e); } return key; }
@Override public Object getValue(SerializationStrategy strategy) throws IOException, ClassNotFoundException { return strategy.deserialize(value); } }
private Object getElementDataForDMI(Element element) throws CacheException { AbstractElementData elementData; switch (valueMode) { case IDENTITY: return new IdentityModeElementData(element, Integer.MIN_VALUE); case SERIALIZATION: elementData = new SerializationModeElementData(element); try { return elementSerialization.serialize(elementData); } catch (IOException e) { throw new CacheException("Unexpected error while serializing the value " + element.getObjectValue(), e); } default: throw new UnsupportedOperationException("Value mode " + valueMode + " isn't supported"); } }
/** * Generates a String key for the supplied object. * <p> * Depending on configuration the generated Strings are also cached in a local soft cache. */ private String generateStringKeyFor(final Object obj) { boolean useCache = shouldUseCache(obj); if (useCache) { String value = keyLookupCache.get(obj); if (value != null) { return value; } } String key; try { key = this.serializationStrategy.generateStringKeyFor(obj); } catch (Exception e) { throw new CacheException(e); } if (useCache && keyLookupCache.size() < localKeyCacheMaxsize) { keyLookupCache.put(obj, key); } return key; }
/** * Return a new copy of this entry, newly deserialized from the serialized state. * * @param strategy deserialization strategy * @return a newly deserialized entry * @throws IOException if de-serialization fails * @throws ClassNotFoundException if a necessary class definition is missing */ public T getDeserializedValueCopy(final SerializationStrategy<T> strategy) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue()); }
private Object getKeyForDMI(Element element) throws CacheException { switch (valueMode) { case IDENTITY: return element.getObjectKey(); case SERIALIZATION: try { return dsoSerialization.serialize(element.getObjectKey()); } catch (IOException e) { throw new CacheException("Unexpected error while serializing the key " + element.getObjectKey(), e); } default: throw new UnsupportedOperationException("Value mode " + valueMode + " isn't supported"); } }
public Sync getSyncForKey(final Object key) { String stringKey; try { stringKey = serializationStrategy.generateStringKeyFor(key); } catch (Exception e) { throw new CacheException(e); } return new TcSync(backend.createFinegrainedLock(stringKey)); } }
public T getDeserializedValueCopy(final SerializationStrategy<T> strategy, ClassLoader classLoader) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue(), classLoader); }
public void put(final Object key, final Object value) throws CacheException { if (!isEnabled()) { return; } byte[] data; try { data = serializationStrategy.serialize(value); } catch (Exception e) { throw new CacheException(e); } String sKey = generateStringKeyFor(key); SerializedEntry entry = new SerializedEntry(value, data, store.getTimeSource()); store.putNoReturn(sKey, entry); // Now that the entry is shared we can drop the byte[] entry.nullByteArray(); }
/** * Return a new copy of this entry, newly deserialized from the serialized state. * * @param strategy deserialization strategy * @return a newly deserialized entry * @throws IOException if de-serialization fails * @throws ClassNotFoundException if a necessary class definition is missing */ public T getDeserializedValueCopy(final SerializationStrategy<T> strategy) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue()); }
public TimestampedValue createTimestampedValue(final Element element) { SerializationModeElementData value = new SerializationModeElementData(element); byte[] data; try { data = store.getSerializationStrategy().serialize(value); } catch (Exception e) { throw new CacheException(e); } TimestampedValue entry = new SerializedEntry<SerializationModeElementData>(value, data, element.getElementEvictionData().getCreationTime(), element.getElementEvictionData().getCreationTime()); return entry; }
public T getDeserializedValueCopy(final SerializationStrategy<T> strategy) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue()); }
public TimestampedValue createTimestampedValue(final Element element) { SerializationModeElementData value = new SerializationModeElementData(element); byte[] data; try { data = serializationStrategy.serialize(value); } catch (Exception e) { throw new CacheException(e); } // we can store null in the entry if we're doing copy on read value = copyOnRead ? null : value; if (element.usesCacheDefaultLifespan()) { return new SerializedEntry<SerializationModeElementData>(value, data, TimeUtil.toSecs(element.getElementEvictionData().getCreationTime()), TimeUtil.toSecs(element.getElementEvictionData().getCreationTime())); } else { int tti = element.getTimeToIdle(); int ttl = element.getTimeToLive(); return new CustomLifespanSerializedEntry<SerializationModeElementData>(value, data, tti, ttl, TimeUtil.toSecs(element.getElementEvictionData().getCreationTime()), TimeUtil.toSecs(element.getElementEvictionData().getCreationTime())); } }
/** * Return a new copy of this entry, newly deserialized from the serialized state, using a specific classloader. * * @param strategy deserialization strategy * @param classLoader loader to use during deserialization * @return a newly deserialized entry * @throws IOException if de-serialization fails * @throws ClassNotFoundException if a necessary class definition is missing */ public T getDeserializedValueCopy(final SerializationStrategy<T> strategy, final ClassLoader classLoader) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue(), classLoader); }
/** * Return a new copy of this entry, newly deserialized from the serialized state, using a specific classloader. * * @param strategy deserialization strategy * @param classLoader loader to use during deserialization * @return a newly deserialized entry * @throws IOException if de-serialization fails * @throws ClassNotFoundException if a necessary class definition is missing */ public T getDeserializedValueCopy(final SerializationStrategy<T> strategy, final ClassLoader classLoader) throws IOException, ClassNotFoundException { return strategy.deserialize(getValue(), classLoader); }