@Test public void testDeserialize() { Serializer serializer = new JavaObjectSerializer(); String stringObj = "key001"; byte[] bvalue = serializer.serialize(stringObj, null); String result = (String) serializer.deserialize(bvalue, null); Assert.assertEquals("string serialize result",stringObj, result); }
public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch (Exception e) { throw new RuntimeException("Fail to deserialize object, byte value:" + bvalue +", cause: " + e, e); }finally { try { bais.close(); } catch (IOException e) { } } }
JavaObjectSerializer implements Serializer { public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch (Exception e) { throw new RuntimeException("Fail to deserialize object, byte value:" + bvalue +", cause: " + e, e); }finally { try { bais.close(); } catch (IOException e) { } } } }
JavaObjectSerializer implements Serializer { public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch (Exception e) { throw new RuntimeException("Fail to deserialize object, byte value:" + bvalue +", cause: " + e, e); }finally { try { bais.close(); } catch (IOException e) { } } }  }
JavaObjectSerializer implements Serializer { public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch (Exception e) { throw new RuntimeException("Fail to deserialize object, byte value:" + bvalue +", cause: " + e, e); }finally { try { bais.close(); } catch (IOException e) { } } }  Object deserialize(byte[] bvalue, Object deserializeTarget); byte[] serialize(Object o, Object arg); }
JavaObjectSerializer implements Serializer { public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch (Exception e) { throw new RuntimeException("Fail to deserialize object, byte value:" + bvalue +", cause: " + e, e); }finally { try { bais.close(); } catch (IOException e) { } } }  Object deserialize(byte[] bvalue, Object deserializeTarget); byte[] serialize(Object o, Object arg);  }