
org.wildfly.clustering.marshalling.protostream.reflect.ProxyMarshaller Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.marshalling.protostream.reflect;
import java.io.IOException;
import java.lang.reflect.Method;
import org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller;
import org.wildfly.clustering.marshalling.protostream.Scalar;
import org.wildfly.common.function.ExceptionFunction;
/**
* Marshaller for proxies serialized using the writeReplace()/readResolve() pattern.
* @author Paul Ferraro
*/
public class ProxyMarshaller extends FunctionalScalarMarshaller {
public ProxyMarshaller(Class extends T> targetClass) {
super(targetClass, Scalar.ANY, new ExceptionFunction() {
@Override
public Object apply(T object) throws IOException {
Method method = Reflect.findMethod(object.getClass(), "writeReplace");
return Reflect.invoke(object, method);
}
}, new ExceptionFunction
© 2015 - 2025 Weber Informatics LLC | Privacy Policy