private Object readObjectInstance(Class cl, ObjectDefinition def) throws IOException { String type = def.getType(); String[] fieldNames = def.getFieldNames(); if (cl != null) { Deserializer reader; reader = findSerializerFactory().getObjectDeserializer(type, cl); return reader.readObject(this, fieldNames); } else { return findSerializerFactory().readObject(this, type, fieldNames); } }
/** * Reads the object as a list. */ public Object readList(AbstractHessianInput in, int length, String type) throws HessianProtocolException, IOException { Deserializer deserializer = getDeserializer(type); if (deserializer != null) return deserializer.readList(in, length); else return new CollectionDeserializer(ArrayList.class).readList(in, length); }
/** * Resolves a remote object. */ public Object resolveRemote(String type, String url) throws IOException { HessianRemoteResolver resolver = getRemoteResolver(); if (resolver != null) return resolver.lookup(type, url); else return new HessianRemote(type, url); }
@Override public Hessian2Input unwrapHeaders(Hessian2Input in) throws IOException { InputStream is = new DeflateInputStream(in); Hessian2Input filter = new Hessian2Input(is); filter.setCloseStreamOnClose(true); return filter; }
@Override public Hessian2Output wrap(Hessian2Output out) throws IOException { OutputStream os = new DeflateOutputStream(out); Hessian2Output filterOut = new Hessian2Output(os); filterOut.setCloseStreamOnClose(true); return filterOut; }
@Override State next(int ch) { println(); if (ch == 'r') { return new ReplyState(this); } else if (ch == 'c') { return new CallState(this); } else return nextObject(ch); } }
/** * Set true if the collection serializer should send the java type. */ public void setSendCollectionType(boolean isSendType) { if (_collectionSerializer == null) _collectionSerializer = new CollectionSerializer(); _collectionSerializer.setSendJavaType(isSendType); if (_mapSerializer == null) _mapSerializer = new MapSerializer(); _mapSerializer.setSendJavaType(isSendType); }
/** * Creates a new Hessian input stream, initialized with an * underlying input stream. * * @param is the underlying output stream. */ public Hessian2StreamingInput(InputStream is) { _in = new Hessian2Input(new StreamingInputStream(is)); }
/** * Resolves a remote object. */ public Object resolveRemote(String type, String url) throws IOException { HessianRemoteResolver resolver = getRemoteResolver(); if (resolver != null) return resolver.lookup(type, url); else return new HessianRemote(type, url); }
@Override public Object readMap(AbstractHessianInput in) throws IOException { try { Object obj = instantiate(); return readMap(in, obj); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOExceptionWrapper(e); } }
protected SerializerFactory findSerializerFactory(AbstractHessianInput in) { SerializerFactory serializerFactory = null; if(in instanceof Hessian2Input) { serializerFactory = ((Hessian2Input) in).findSerializerFactory(); } else if(in instanceof HessianInput) { serializerFactory = ((HessianInput) in).getSerializerFactory(); } return serializerFactory == null? new SerializerFactory(): serializerFactory; } }
/** * Creates a new Hessian output stream, initialized with an * underlying output stream. * * @param os the underlying output stream. */ public Hessian2StreamingOutput(OutputStream os) { _out = new Hessian2Output(os); }
/** * Returns the default serializer for a class that isn't matched * directly. Application can override this method to produce * bean-style serialization instead of field serialization. * * @param cl the class of the object that needs to be serialized. * @return a serializer object for the serialization. */ @Override protected Serializer getDefaultSerializer(Class cl) { return new BeanSerializer(cl, getClassLoader()); }
/** * Reads a short * <p> * <pre> * I b32 b24 b16 b8 * </pre> */ public short readShort() throws IOException { return (short) readInt(); }
/** * Close the output. */ public void close() throws IOException { _in.close(); }
/** * Reads the object as a map. */ public Object readMap(AbstractHessianInput in, String type) throws HessianProtocolException, IOException { return readMap(in, type, null, null); }
/** * Read the next object */ public Object readObject() throws IOException { return _in.readStreamingObject(); }
/** * Reads the start of a list. */ @Override public int readMapStart() throws IOException { return read(); }
/** * Normally, shouldn't be called externally, but needed for QA, e.g. * ejb/3b01. */ public final int read() throws IOException { if (_length <= _offset && !readBuffer()) return -1; return _buffer[_offset++] & 0xff; }