private JBossLogWriterOutput(OutputStream out) throws IOException { this.out = new JBossObjectOutputStream(out); }
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(); }
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 ObjectOutputStream createOutput(OutputStream output) throws IOException { if (trace) { log.trace(this + " creating JBossObjectOutputStream"); } return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024)); }
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; } }
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 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]; } }
out = new JBossObjectOutputStream(fos, false);