com.caucho.hessian.io.HessianProtocolException Java Examples

The following examples show how to use com.caucho.hessian.io.HessianProtocolException. 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: GenericMultipleClassLoaderSofaSerializerFactory.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
@Override
public Serializer getSerializer(Class cl) throws HessianProtocolException {

    if (GenericObject.class == cl) {
        return GenericObjectSerializer.getInstance();
    }

    if (GenericArray.class == cl) {
        return GenericArraySerializer.getInstance();
    }

    if (GenericCollection.class == cl) {
        return GenericCollectionSerializer.getInstance();
    }

    if (GenericMap.class == cl) {
        return GenericMapSerializer.getInstance();
    }

    if (GenericClass.class == cl) {
        return GenericClassSerializer.getInstance();
    }

    return super.getSerializer(cl);
}
 
Example #2
Source File: GenericSingleClassLoaderSofaSerializerFactory.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
@Override
public Serializer getSerializer(Class cl) throws HessianProtocolException {

    if (GenericObject.class == cl) {
        return GenericObjectSerializer.getInstance();
    }

    if (GenericArray.class == cl) {
        return GenericArraySerializer.getInstance();
    }

    if (GenericCollection.class == cl) {
        return GenericCollectionSerializer.getInstance();
    }

    if (GenericMap.class == cl) {
        return GenericMapSerializer.getInstance();
    }

    if (GenericClass.class == cl) {
        return GenericClassSerializer.getInstance();
    }

    return super.getSerializer(cl);
}
 
Example #3
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Object readObject() throws IOException {
	try {
		return hessian2Input.readObject();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #4
Source File: WeakReferenceSerializerFactory.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(@SuppressWarnings("rawtypes") Class cl) throws HessianProtocolException {
    if (WeakReference.class.isAssignableFrom(cl)) {
        return beanDeserializer;
    }
    return null;
}
 
Example #5
Source File: HessionSoftReferenceSerializerFactory.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(@SuppressWarnings("rawtypes") Class cl) throws HessianProtocolException {
    if (SoftReference.class.isAssignableFrom(cl)) {
        return beanSerializer;
    }
    return null;
}
 
Example #6
Source File: HessionSoftReferenceSerializerFactory.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(@SuppressWarnings("rawtypes") Class cl) throws HessianProtocolException {
    if (SoftReference.class.isAssignableFrom(cl)) {
        return beanDeserializer;
    }
    return null;
}
 
Example #7
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public boolean readBoolean() throws IOException {
	try {
		return hessian2Input.readBoolean();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #8
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public int readBytes(byte[] arg0, int arg1, int arg2) throws IOException {
	try {
		return hessian2Input.readBytes(arg0, arg1, arg2);
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #9
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public double readDouble() throws IOException {
	try {
		return hessian2Input.readDouble();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #10
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public int readInt() throws IOException {
	try {
		return hessian2Input.readInt();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #11
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public long readLong() throws IOException {
	try {
		return hessian2Input.readLong();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #12
Source File: HessionBigDecimalSerializerFactory.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(@SuppressWarnings("rawtypes") Class cl) throws HessianProtocolException {
    if (BigDecimal.class.isAssignableFrom(cl)) {
        return BIG_DECIMAL_DESERIALIZER;
    }
    return null;
}
 
Example #13
Source File: HessianObjectInput.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public String readString() throws IOException {
	try {
		return hessian2Input.readString();
	}
	catch (HessianProtocolException e) {
		throw new IOException(e.getMessage(),e);
	}
}
 
Example #14
Source File: FaultDetailSerialiserFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(Class cls) throws HessianProtocolException {

	Deserializer deserializer = null;
       if (FaultDetail.class.isAssignableFrom(cls)) {
           deserializer = new FaultDetailDeserialiser(cls, transcriptionParams);
       }

	return deserializer;
}
 
Example #15
Source File: FaultDetailSerialiserFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(Class cls) throws HessianProtocolException {

	Serializer serializer = null;

       if (FaultDetail.class.isAssignableFrom(cls)) {
           serializer = new FaultDetailSerialiser(transcriptionParams);
       }

	return serializer;
}
 
Example #16
Source File: TranscribableSerialiserFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(Class cls) throws HessianProtocolException {

	Serializer serializer = null;

	if (Transcribable.class.isAssignableFrom(cls)) {
		serializer = new TranscribableSerialiser(transcriptionParams, client);
	}

	return serializer;
}
 
Example #17
Source File: CougarSerializerFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a deserializer based on a string type.
 */
public Deserializer getDeserializer(String type)
        throws HessianProtocolException
{
    if (type == null || type.equals("")) {
        return null;
    }

    if (!transcriptionParams.contains(TranscribableParams.MajorOnlyPackageNaming)) {
        // look for vMajor
        type = ClassnameCompatibilityMapper.toMajorOnlyPackaging(type);
    }

    return optimizedGetDeserializer(type);
}
 
Example #18
Source File: CougarSerializerFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
/**
 * If a Cougar server response contains a class the client doesn't know about (which is legal and backwards compatible
 * in cases) then the default behavior of Hessian is to perform a lookup, fail, throw an exception and log it.
 * This has been measured at about 25 times slower than the happy path, and Hessian does not negatively cache 'misses',
 * so this is a per-response slowdown. This implementation caches type lookup misses, and so eradicates the problem.
 */
private Deserializer optimizedGetDeserializer(String type)
        throws HessianProtocolException {
    if (missingTypes.contains(type)) {
        return null;
    }
    Deserializer answer = super.getDeserializer(type);
    if (answer == null) {
        missingTypes.add(type);
    }
    return answer;
}
 
Example #19
Source File: EnumSerialiserFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(Class cls) throws HessianProtocolException {

	Deserializer deserializer = null;
       if (cls != null && TranscribableEnum.class.isAssignableFrom(cls)) {
           deserializer = new TranscribableEnumDeserializer(cls, transcriptionParams);
       }


	return deserializer;
}
 
Example #20
Source File: EnumSerialiserFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(Class cls) throws HessianProtocolException {

       if (cls != null && TranscribableEnum.class.isAssignableFrom(cls)) {
	    return new TranscribableEnumSerializer(cls, transcriptionParams);
       }
       return null;
}
 
Example #21
Source File: ExecutionVenueNioClient.java    From cougar with Apache License 2.0 5 votes vote down vote up
private boolean causeContainsHessianProtocolException(Throwable t) {
    Throwable cause = t;
    while (cause != null) {
        if (cause instanceof HessianProtocolException) {
            return true;
        }
        cause = cause.getCause();
    }
    return false;
}
 
Example #22
Source File: KryoSerialization.java    From learnjavabug with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see SerializerFactory#getSerializer(Class)
 */
@Override
public Serializer getSerializer ( Class cl ) throws HessianProtocolException {
  Serializer serializer = super.getSerializer(cl);

  if ( serializer instanceof WriteReplaceSerializer) {
    return UnsafeSerializer.create(cl);
  }
  return serializer;
}
 
Example #23
Source File: JMXSerializerFactory.java    From sofa-hessian with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the deserializer for a class.
 *
 * @param cl the class of the object that needs to be deserialized.
 *
 * @return a deserializer object for the serialization.
 */
public Deserializer getDeserializer(Class cl)
    throws HessianProtocolException
{
    if (ObjectName.class.equals(cl)) {
        return new StringValueDeserializer(cl);
    }
    else if (ObjectInstance.class.equals(cl)) {
        return new ObjectInstanceDeserializer();
    }
    else if (MBeanAttributeInfo.class.isAssignableFrom(cl)) {
        return new MBeanAttributeInfoDeserializer();
    }
    else if (MBeanConstructorInfo.class.isAssignableFrom(cl)) {
        return new MBeanConstructorInfoDeserializer();
    }
    else if (MBeanOperationInfo.class.isAssignableFrom(cl)) {
        return new MBeanOperationInfoDeserializer();
    }
    else if (MBeanParameterInfo.class.isAssignableFrom(cl)) {
        return new MBeanParameterInfoDeserializer();
    }
    else if (MBeanNotificationInfo.class.isAssignableFrom(cl)) {
        return new MBeanNotificationInfoDeserializer();
    }
    /*
    else if (MBeanInfo.class.equals(cl)) {
      return new MBeanInfoDeserializer();
    }
    */

    return null;
}
 
Example #24
Source File: MyListSerializeFactory.java    From sofa-hessian with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(Class cl) throws HessianProtocolException {
    if (MyList.class.isAssignableFrom(cl)) {
        return new MyListSerializer(cl);
    }
    return null;
}
 
Example #25
Source File: MyListSerializeFactory.java    From sofa-hessian with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(Class cl) throws HessianProtocolException {
    if (MyList.class.isAssignableFrom(cl)) {
        return new MyListDeserializer(cl);
    }
    return null;
}
 
Example #26
Source File: HessianSerialization.java    From learnjavabug with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see com.caucho.hessian.io.SerializerFactory#getSerializer(java.lang.Class)
 */
@Override
public Serializer getSerializer ( Class cl ) throws HessianProtocolException {
  Serializer serializer = super.getSerializer(cl);

  if ( serializer instanceof WriteReplaceSerializer) {
    return UnsafeSerializer.create(cl);
  }
  return serializer;
}
 
Example #27
Source File: WeakReferenceSerializerFactory.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
@Override
public Serializer getSerializer(@SuppressWarnings("rawtypes") Class cl) throws HessianProtocolException {
    if (WeakReference.class.isAssignableFrom(cl)) {
        return beanSerializer;
    }
    return null;
}
 
Example #28
Source File: NoWriteReplaceSerializerFactory.java    From learnjavabug with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see SerializerFactory#getSerializer(Class)
 */
@Override
public Serializer getSerializer(Class cl) throws HessianProtocolException {
  Serializer serializer = super.getSerializer(cl);

  if (serializer instanceof WriteReplaceSerializer) {
    return UnsafeSerializer.create(cl);
  }
  return serializer;
}
 
Example #29
Source File: GenericSingleClassLoaderSofaSerializerFactory.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(String type) throws HessianProtocolException {

    // 如果类型在过滤列表, 说明是jdk自带类, 直接委托父类处理
    if (StringUtils.isEmpty(type) || ClassFilter.filterExcludeClass(type)) {
        return super.getDeserializer(type);
    }

    // 如果是数组类型, 且在name过滤列表, 说明jdk类, 直接委托父类处理
    if (type.charAt(0) == ARRAY_PREFIX && ClassFilter.arrayFilter(type)) {
        return super.getDeserializer(type);
    }

    // 查看是否已经包含反序列化器
    Deserializer deserializer = DESERIALIZER_MAP.get(type);
    if (deserializer != null) {
        return deserializer;
    }

    // 新建反序列化器, 如果是java.lang.Class使用GenericClassDeserializer,否则使用GenericDeserializer
    if (ClassFilter.CLASS_NAME.equals(type)) {
        deserializer = GenericClassDeserializer.getInstance();
    } else {
        deserializer = new GenericDeserializer(type);
    }

    DESERIALIZER_MAP.putIfAbsent(type, deserializer);
    return deserializer;
}
 
Example #30
Source File: GenericMultipleClassLoaderSofaSerializerFactory.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
@Override
public Deserializer getDeserializer(String type) throws HessianProtocolException {

    // 如果类型在过滤列表, 说明是jdk自带类, 直接委托父类处理
    if (StringUtils.isEmpty(type) || ClassFilter.filterExcludeClass(type)) {
        return super.getDeserializer(type);
    }

    // 如果是数组类型, 且在name过滤列表, 说明jdk类, 直接委托父类处理
    if (type.charAt(0) == ARRAY_PREFIX && ClassFilter.arrayFilter(type)) {
        return super.getDeserializer(type);
    }

    // 查看是否已经包含反序列化器
    Deserializer deserializer = DESERIALIZER_MAP.get(type);
    if (deserializer != null) {
        return deserializer;
    }

    // 新建反序列化器, 如果是java.lang.Class使用GenericClassDeserializer,否则使用GenericDeserializer
    if (ClassFilter.CLASS_NAME.equals(type)) {
        deserializer = GenericClassDeserializer.getInstance();
    } else {
        deserializer = new GenericDeserializer(type);
    }

    DESERIALIZER_MAP.putIfAbsent(type, deserializer);
    return deserializer;
}