1 21 package com.db4o.config; 22 23 import java.io.*; 24 25 import com.db4o.*; 26 27 32 public class TSerializable implements ObjectConstructor { 33 34 public Object onStore(ObjectContainer con, Object object){ 35 try{ 36 ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); 37 new ObjectOutputStream(byteStream).writeObject(object); 38 return byteStream.toByteArray(); 39 }catch (Exception e){} 40 return null; 41 } 42 43 public void onActivate(ObjectContainer con, Object object, Object members){ 44 } 46 47 public Object onInstantiate(ObjectContainer con, Object storedObject){ 48 try{ 49 Object in = new ObjectInputStream( 50 new ByteArrayInputStream((byte[])storedObject)).readObject(); 51 return in; 52 }catch(Exception e){} 53 return null; 54 } 55 56 public Class storedClass(){ 57 return byte[].class; 58 } 59 } 60 | Popular Tags |