protostream icon indicating copy to clipboard operation
protostream copied to clipboard

Support for generic marshallers

Open johnou opened this issue 3 years ago • 3 comments

I would like a way to use generic marshallers without relying on deprecated methods, right now org.infinispan.protostream.impl.SerializationContextImpl looks up marshallers using a hashmap with the class as a key which doesn't find a compatible marshaller. I am currently working around this by creating a MarshallerProvider.. would you consider keeping MarshallerProvider in order to maintain this functionality?

 serializationContext.registerMarshallerProvider(new MarshallerProvider() {
            @Override
            public BaseMarshaller<?> getMarshaller(String typeName) {
                return null;
            }

            @Override
            public BaseMarshaller<?> getMarshaller(Class<?> javaClass) {
                if (AbstractActor.class.isAssignableFrom(javaClass)) {
                    return getContext().getMarshaller(AbstractActor.class);
                }
                if (ActorObserver.class.isAssignableFrom(javaClass)) {
                    return getContext().getMarshaller(ActorObserver.class);
                }
                if (RemoteReference.class.isAssignableFrom(javaClass)) {
                    return getContext().getMarshaller(RemoteReference.class);
                }
                return null;
            }
        });

johnou avatar Apr 12 '22 10:04 johnou

doesn't void registerMarshallerProvider(InstanceMarshallerProvider<?> marshallerProvider); work for you ?

tristantarrant avatar May 19 '22 12:05 tristantarrant

doesn't void registerMarshallerProvider(InstanceMarshallerProvider<?> marshallerProvider); work for you ?

it does but it is marked deprecated.

johnou avatar May 19 '22 16:05 johnou

@Deprecated
void registerMarshallerProvider(MarshallerProvider marshallerProvider);

is deprecated, but

void registerMarshallerProvider(InstanceMarshallerProvider<?> marshallerProvider);

is not.

tristantarrant avatar May 19 '22 16:05 tristantarrant