Search in sources :

Example 1 with SerializeFunctionWith

use of org.infinispan.commons.marshall.SerializeFunctionWith in project infinispan by infinispan.

the class CommandsFactoryImpl method getValueMatcher.

private ValueMatcher getValueMatcher(Object o) {
    SerializeFunctionWith ann = o.getClass().getAnnotation(SerializeFunctionWith.class);
    if (ann != null)
        return ValueMatcher.valueOf(ann.valueMatcher().toString());
    Externalizer ext = ((GlobalMarshaller) marshaller).findExternalizerFor(o);
    if (ext instanceof LambdaExternalizer)
        return ValueMatcher.valueOf(((LambdaExternalizer) ext).valueMatcher(o).toString());
    return ValueMatcher.MATCH_ALWAYS;
}
Also used : Externalizer(org.infinispan.commons.marshall.Externalizer) LambdaExternalizer(org.infinispan.commons.marshall.LambdaExternalizer) GlobalMarshaller(org.infinispan.marshall.core.GlobalMarshaller) LambdaExternalizer(org.infinispan.commons.marshall.LambdaExternalizer) SerializeFunctionWith(org.infinispan.commons.marshall.SerializeFunctionWith)

Example 2 with SerializeFunctionWith

use of org.infinispan.commons.marshall.SerializeFunctionWith in project infinispan by infinispan.

the class SerializeWithExtFactory method getExternalizer.

@Override
public Externalizer getExternalizer(Class<?> type) {
    SerializeWith serialWithAnn = type.getAnnotation(SerializeWith.class);
    SerializeFunctionWith lambdaSerialWithAnn = type.getAnnotation(SerializeFunctionWith.class);
    if (serialWithAnn == null && lambdaSerialWithAnn == null) {
        // Check for JBoss Marshaller's @Externalize
        return jbmarExtFactory.getExternalizer(type);
    } else {
        try {
            org.infinispan.commons.marshall.Externalizer ext = serialWithAnn != null ? serialWithAnn.value().newInstance() : lambdaSerialWithAnn.value().newInstance();
            return new JBossExternalizerAdapter(ext);
        } catch (Exception e) {
            throw new IllegalArgumentException(String.format("Cannot instantiate externalizer for %s", type), e);
        }
    }
}
Also used : SerializeFunctionWith(org.infinispan.commons.marshall.SerializeFunctionWith) SerializeWith(org.infinispan.commons.marshall.SerializeWith)

Aggregations

SerializeFunctionWith (org.infinispan.commons.marshall.SerializeFunctionWith)2 Externalizer (org.infinispan.commons.marshall.Externalizer)1 LambdaExternalizer (org.infinispan.commons.marshall.LambdaExternalizer)1 SerializeWith (org.infinispan.commons.marshall.SerializeWith)1 GlobalMarshaller (org.infinispan.marshall.core.GlobalMarshaller)1