List of usage examples for org.apache.ibatis.cache CacheException CacheException
public CacheException(String message, Throwable cause)
From source file:org.mybatis.caches.memcached.CompressorTranscoder.java
License:Apache License
/** * {@inheritDoc}// w w w . j a v a 2 s . c o m */ @Override public Object decode(final CachedData cachedData) { byte[] buffer = cachedData.getData(); ByteArrayInputStream bais = new ByteArrayInputStream(buffer); GZIPInputStream gzis = null; ObjectInputStream ois = null; Object ret = null; try { gzis = new GZIPInputStream(bais); ois = new ObjectInputStream(gzis); ret = ois.readObject(); } catch (Exception e) { throw new CacheException("Impossible to decompress cached object, see nested exceptions", e); } finally { closeQuietly(ois); closeQuietly(gzis); closeQuietly(bais); } return ret; }
From source file:org.mybatis.caches.memcached.CompressorTranscoder.java
License:Apache License
/** * {@inheritDoc}//from w w w.j a v a2 s. c o m */ @Override public CachedData encode(final Object object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzops = null; ObjectOutputStream oos = null; try { gzops = new GZIPOutputStream(baos); oos = new ObjectOutputStream(gzops); oos.writeObject(object); } catch (IOException e) { throw new CacheException("Impossible to compress object [" + object + "], see nested exceptions", e); } finally { closeQuietly(oos); closeQuietly(gzops); closeQuietly(baos); } byte[] buffer = baos.toByteArray(); return new CachedData(SERIALIZED_COMPRESSED, buffer, CachedData.MAX_SIZE); }
From source file:org.mybatis.caches.redis.CompressorTranscoder.java
License:Apache License
/** * {@inheritDoc}/* w ww . j a va 2 s .c o m*/ */ public Object decode(final CachedData cachedData) { byte[] buffer = cachedData.getData(); ByteArrayInputStream bais = new ByteArrayInputStream(buffer); GZIPInputStream gzis = null; ObjectInputStream ois = null; Object ret = null; try { gzis = new GZIPInputStream(bais); ois = new ObjectInputStream(gzis); ret = ois.readObject(); } catch (Exception e) { throw new CacheException("Impossible to decompress cached object, see nested exceptions", e); } finally { closeQuietly(ois); closeQuietly(gzis); closeQuietly(bais); } return ret; }
From source file:org.mybatis.caches.redis.CompressorTranscoder.java
License:Apache License
/** * {@inheritDoc}//from w ww. ja v a 2s . c om */ public CachedData encode(final Object object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzops = null; ObjectOutputStream oos = null; try { gzops = new GZIPOutputStream(baos); oos = new ObjectOutputStream(gzops); oos.writeObject(object); } catch (IOException e) { throw new CacheException("Impossible to compress object [" + object + "], see nested exceptions", e); } finally { closeQuietly(oos); closeQuietly(gzops); closeQuietly(baos); } byte[] buffer = baos.toByteArray(); return new CachedData(SERIALIZED_COMPRESSED, buffer, CachedData.MAX_SIZE); }