public MarshalledObject(Object obj) throws java.io.IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JBossObjectOutputStream mvos = new JBossObjectOutputStream(baos); mvos.writeObject(obj); mvos.flush(); bytes = baos.toByteArray(); mvos.close(); hash = 0; for (int i = 0; i < bytes.length; i++) { hash += bytes[i]; } }
/** Reuses every primitive value to recreate another object. */ public Object smartClone(Object obj) throws IOException { return smartClone(obj,null,Thread.currentThread().getContextClassLoader()); }
public void writeUnshared(Object obj) throws IOException { writeObjectOverride(obj); }
public byte[] serializeToByte(final Object target) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream oos = new ObjectOutputStream(baos); JBossObjectOutputStream jbos = new JBossObjectOutputStream(oos); jbos.writeObject(target); jbos.close(); return baos.toByteArray(); }
private JBossLogWriterOutput(OutputStream out) throws IOException { this.out = new JBossObjectOutputStream(out); }
@Override public void close() throws IOException { out.close(); } }
@Override public void writeObject(Object object) throws IOException { out.writeObject(object); }
public void writeObjectUsingDataContainer(Object obj) throws IOException { DataContainer dataContainer = new DataContainer(null,this.getSubstitutionInterface(),checkSerializableClass,buffer,classDescriptorStrategy,objectDescriptorStrategy); if (output instanceof DataOutputStream) { dataOutput = (DataOutputStream) output; } else { dataOutput = new DataOutputStream(output); } ObjectOutput objectOutput = dataContainer.getOutput(); objectOutput.writeObject(obj); //objectOutput.flush(); dataContainer.saveData(dataOutput); //this.flush(); }
public void close() throws IOException { flush(); dataOutput.close(); }
public static byte[] serialize(Object obj) { ObjectOutputStream ous = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { if(useJBoss){ ous=new JBossObjectOutputStream(baos); } else { baos = new ByteArrayOutputStream(); ous=new ObjectOutputStream(baos); } ous.writeObject(obj); return baos.toByteArray(); } catch (Exception e) { throw new RuntimeException("Error during " + obj + " serialization", e); } finally { try { Closeables.close(ous, true); } catch (IOException e) { log.warn("IOException should not have been thrown.", e); } try { Closeables.close(baos, true); } catch (IOException e) { log.warn("IOException should not have been thrown.", e); } } }
public void writeObjectUsingDataContainer(Object obj) throws IOException { DataContainer dataContainer = new DataContainer(null,this.getSubstitutionInterface(),checkSerializableClass,buffer); if (output instanceof DataOutputStream) { dataOutput = (DataOutputStream) output; } else { dataOutput = new DataOutputStream(output); } ObjectOutput objectOutput = dataContainer.getOutput(); objectOutput.writeObject(obj); //objectOutput.flush(); dataContainer.saveData(dataOutput); //this.flush(); }
public void close() throws IOException { flush(); dataOutput.close(); }
public MarshalledObject(Object obj) throws java.io.IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JBossObjectOutputStream mvos = new JBossObjectOutputStream(baos); mvos.writeObject(obj); mvos.flush(); bytes = baos.toByteArray(); mvos.close(); hash = 0; for (int i = 0; i < bytes.length; i++) { hash += bytes[i]; } }
public ObjectOutputStream createOutput(OutputStream output) throws IOException { if (trace) { log.trace(this + " creating JBossObjectOutputStream"); } return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024)); }
protected void writeObjectOverride(Object obj) throws IOException { DataContainer dataContainer = new DataContainer(null,this.getSubstitutionInterface(),checkSerializableClass,buffer); if (output instanceof DataOutputStream) { dataOutput = (DataOutputStream) output; } else { dataOutput = new DataOutputStream(output); } dataContainer.setStringBuffer(buffer); ObjectOutput objectOutput = dataContainer.getDirectOutput(this.dataOutput); objectOutput.writeObject(obj); //objectOutput.flush(); //dataContainer.saveData(dataOutput); //this.flush(); }
/** Reuses every primitive value to recreate another object. */ public Object smartClone(Object obj, SafeCloningRepository safeToReuse) throws IOException { return smartClone(obj,safeToReuse,Thread.currentThread().getContextClassLoader()); }
public void writeUnshared(Object obj) throws IOException { writeObjectOverride(obj); }
public static String toString(Serializable o) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = null; try { if(useJBoss){ oos=new JBossObjectOutputStream(baos); } else{ baos = new ByteArrayOutputStream(); oos=new ObjectOutputStream(baos); } oos.writeObject(o); } catch (IOException e) { log.error("Serialization exception ", e); throw new TechnicalException(e); } finally { String s = new String(Base64Coder.encode(baos.toByteArray())); if (s.isEmpty()) { log.info("toString({}, '{}', '{}')", toStringCount.getAndIncrement(), s, o); } try { Closeables.close(oos, true); } catch (IOException e) { log.warn("IOException should not have been thrown.", e); } return s; } }
protected void writeObjectOverride(Object obj) throws IOException { DataContainer dataContainer = new DataContainer(null,this.getSubstitutionInterface(),checkSerializableClass,buffer,classDescriptorStrategy,objectDescriptorStrategy); if (output instanceof DataOutputStream) { dataOutput = (DataOutputStream) output; } else { dataOutput = new DataOutputStream(output); } dataContainer.setStringBuffer(buffer); ObjectOutput objectOutput = dataContainer.getDirectOutput(this.dataOutput); objectOutput.writeObject(obj); //objectOutput.flush(); //dataContainer.saveData(dataOutput); //this.flush(); }
/** Reuses every primitive value to recreate another object. */ public Object smartClone(Object obj, SafeCloningRepository safeToReuse) throws IOException { return smartClone(obj,safeToReuse,Thread.currentThread().getContextClassLoader()); }