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

org.jboss.weld.annotated.slim.backed.BackedAnnotatedMember 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.0.Beta4
Show newest version
package org.jboss.weld.annotated.slim.backed;

import java.io.Serializable;
import java.lang.reflect.Member;
import java.lang.reflect.Type;

import javax.enterprise.inject.spi.AnnotatedMember;

import org.jboss.weld.logging.BeanLogger;
import org.jboss.weld.resources.ReflectionCache;
import org.jboss.weld.resources.SharedObjectCache;
import org.jboss.weld.serialization.AbstractSerializableHolder;
import org.jboss.weld.util.reflection.Reflections;

public abstract class BackedAnnotatedMember extends BackedAnnotated implements AnnotatedMember {

    private BackedAnnotatedType declaringType;

    public BackedAnnotatedMember(Type baseType, BackedAnnotatedType declaringType, SharedObjectCache sharedObjectCache) {
        super(baseType, sharedObjectCache);
        this.declaringType = declaringType;
    }

    public boolean isStatic() {
        return Reflections.isStatic(getJavaMember());
    }

    public BackedAnnotatedType getDeclaringType() {
        return declaringType;
    }

    @Override
    protected ReflectionCache getReflectionCache() {
        return getDeclaringType().getReflectionCache();
    }

    protected abstract static class BackedAnnotatedMemberSerializationProxy> implements Serializable {

        private static final long serialVersionUID = 450947485748828056L;
        protected final BackedAnnotatedType type;
        private final AbstractSerializableHolder memberHolder;

        public BackedAnnotatedMemberSerializationProxy(BackedAnnotatedType type, AbstractSerializableHolder memberHolder) {
            this.type = type;
            this.memberHolder = memberHolder;
        }

        protected A resolve() {
            for (A annotatedMember : getCandidates()) {
                if (annotatedMember.getJavaMember().equals(memberHolder.get())) {
                    return annotatedMember;
                }
            }
            throw BeanLogger.LOG.unableToLoadMember(memberHolder.get());
        }

        protected abstract Iterable getCandidates();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy