All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.weld.annotated.slim.backed.BackedAnnotatedMethod Maven / Gradle / Ivy

Go to download

This jar bundles all the bits of Weld and CDI required for running in a Servlet container.

There is a newer version: 6.0.1.Final
Show newest version
package org.jboss.weld.annotated.slim.backed;

import static org.jboss.weld.util.reflection.Reflections.cast;

import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.reflect.Method;

import javax.enterprise.inject.spi.AnnotatedMethod;

import org.jboss.weld.exceptions.InvalidObjectException;
import org.jboss.weld.logging.BeanLogger;
import org.jboss.weld.resources.SharedObjectCache;
import org.jboss.weld.serialization.MethodHolder;
import org.jboss.weld.util.reflection.Formats;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;

@SuppressWarnings(value = { "SE_BAD_FIELD", "SE_NO_SUITABLE_CONSTRUCTOR", "SE_NO_SERIALVERSIONID" }, justification = "False positive from FindBugs - serialization is handled by SerializationProxy.")
public class BackedAnnotatedMethod extends BackedAnnotatedCallable implements AnnotatedMethod, Serializable {

    public static  AnnotatedMethod of(Method method, BackedAnnotatedType declaringType, SharedObjectCache sharedObjectCache) {
        BackedAnnotatedType downcastDeclaringType = cast(declaringType);
        return new BackedAnnotatedMethod(method, downcastDeclaringType, sharedObjectCache);
    }

    public BackedAnnotatedMethod(Method method, BackedAnnotatedType declaringType, SharedObjectCache sharedObjectCache) {
        super(method, method.getGenericReturnType(), declaringType, sharedObjectCache);
    }

    @Override
    public String toString() {
        return Formats.formatAnnotatedMethod(this);
    }

    // Serialization

    private Object writeReplace() throws ObjectStreamException {
        return new SerializationProxy(this);
    }

    private void readObject(ObjectInputStream stream) throws InvalidObjectException {
        throw BeanLogger.LOG.serializationProxyRequired();
    }

    private static class SerializationProxy extends BackedAnnotatedMemberSerializationProxy> {

        private static final long serialVersionUID = 8008578690970722095L;

        public SerializationProxy(BackedAnnotatedMethod method) {
            super(method.getDeclaringType(), MethodHolder.of(method));
        }

        private Object readResolve() throws ObjectStreamException {
            return resolve();
        }

        @Override
        protected Iterable> getCandidates() {
            return cast(type.getMethods());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy