Java Code Examples for com.caucho.hessian.io.AbstractHessianInput#addRef()

The following examples show how to use com.caucho.hessian.io.AbstractHessianInput#addRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDateTimeDeserializer.java    From jvm-sandbox-repeater with Apache License 2.0 6 votes vote down vote up
@Override
public Object readObject(AbstractHessianInput in,
                         Object[] fields)
        throws IOException {

    String[] fieldNames = (String[]) fields;

    int ref = in.addRef(null);

    long initValue = Long.MIN_VALUE;

    for (int i = 0; i < fieldNames.length; i++) {
        String key = fieldNames[i];
        if ("value".equals(key)) {
            initValue = in.readUTCDate();
        } else {
            in.readObject();
        }
    }
    Object value = create(initValue);
    in.setRef(ref, value);
    return value;
}
 
Example 2
Source File: GenericClassDeserializer.java    From sofa-hessian with Apache License 2.0 6 votes vote down vote up
/**
 * 当读取Object时会调用此方法, Object类型包括Enum与AliEnum
 */
public Object readObject(AbstractHessianInput in, Object[] fieldNames) throws IOException {
    int ref = in.addRef(null);

    String name = null;

    for (int i = 0; i < fieldNames.length; i++) {
        if ("name".equals(fieldNames[i])) {
            name = in.readString();
        } else {
            in.readObject();
        }
    }

    Object value;
    if (ClassFilter.filter(name)) {
        value = create(name);
    } else {
        value = new GenericClass(name);
    }

    in.setRef(ref, value);

    return value;
}
 
Example 3
Source File: TranscribableEnumDeserializer.java    From cougar with Apache License 2.0 6 votes vote down vote up
public Object readMap(AbstractHessianInput in) throws IOException {
    String name = null;

    while (!in.isEnd()) {
        String key = in.readString();

        if (key.equals("name")) {
            name = in.readString();
        }
        else {
            in.readObject();
        }
    }

    in.readMapEnd();

    Object obj = transcriptionParams.contains(TranscribableParams.EnumsWrittenAsStrings) ? name : create(name);

    in.addRef(obj);

    return obj;
}
 
Example 4
Source File: TranscribableEnumDeserializer.java    From cougar with Apache License 2.0 6 votes vote down vote up
@Override
public Object readObject(AbstractHessianInput in, Object[] fields) throws IOException {
    String[] fieldNames = (String[]) fields;
    String name = null;

    for (int i = 0; i < fieldNames.length; i++) {
        if ("name".equals(fieldNames[i])) {
            name = in.readString();
        }
        else {
            in.readObject();
        }
    }

    Object obj = create(name);

    in.addRef(obj);

    return obj;
}
 
Example 5
Source File: FaultDetailDeserialiser.java    From cougar with Apache License 2.0 6 votes vote down vote up
@Override
public Object readObject(final AbstractHessianInput in, Object[] fields) throws IOException {

	try {

		TranscriptionInput ti = new TranscriptionInput() {

			@Override
			public <T> T readObject(Parameter param, boolean client) throws Exception {
				return (T) in.readObject();
			}
		};

		int ref = in.addRef(null);

           FaultDetail o = transcribe(ti);
           in.setRef(ref, o);

		return o;
	}
	catch (Exception e) {
		throw new IOException(e);
	}

}
 
Example 6
Source File: TranscribableExceptionDeserialiser.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Object readObject(final AbstractHessianInput in, Object[] fields) throws IOException {

	try {

		TranscriptionInput ti = new TranscriptionInput() {

			@Override
			public <T> T readObject(Parameter param, boolean client) throws Exception {
				return (T) in.readObject();
			}
		};

		int ref = in.addRef(null);

		Constructor constructor = cls.getConstructor(TranscriptionInput.class, Set.class);
           Object ret = constructor.newInstance(ti, transcriptionParams);

           in.setRef(ref, ret);

		return ret;
	}
	catch (Exception e) {
		throw new IOException(e);
	}

}