Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2008, Red Hat, Inc., and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.weld.bean;
 
 import java.util.Set;
 
 
 
 public class DisposalMethod<X, T> {
 
     private static final String DISPOSER_ANNOTATION = "@Disposes";
     private final BeanManagerImpl beanManager;
     private final AbstractClassBean<X> declaringBean;
 
     private final MethodInjectionPoint<T, ? super X> disposalMethodInjectionPoint;
     private final AnnotatedParameter<? super X> disposesParameter;
 
     private final Set<QualifierInstancerequiredQualifiers;
 
     public static <X, T> DisposalMethod<X, T> of(BeanManagerImpl managerEnhancedAnnotatedMethod<T, ? super X> methodAbstractClassBean<X> declaringBean) {
         return new DisposalMethod<X, T>(managermethoddeclaringBean);
     }
 
     protected DisposalMethod(BeanManagerImpl beanManagerEnhancedAnnotatedMethod<T, ? super X> enhancedAnnotatedMethodAbstractClassBean<X> declaringBean) {
         this. = InjectionPointFactory.instance().createMethodInjectionPoint(enhancedAnnotatedMethoddeclaringBeandeclaringBean.getBeanClass(), truebeanManager);
         this. = beanManager;
         this. = declaringBean;
         EnhancedAnnotatedParameter<?, ? super X> enhancedDisposesParameter = getEnhancedDisposesParameter(enhancedAnnotatedMethod);
         this. = enhancedDisposesParameter.slim();
         this. = getRequiredQualifiers(enhancedDisposesParameter);
         checkDisposalMethod(enhancedAnnotatedMethoddeclaringBean);
     }
 
     private EnhancedAnnotatedParameter<?, ? super X> getEnhancedDisposesParameter(EnhancedAnnotatedMethod<T, ? super X> enhancedAnnotatedMethod) {
         return enhancedAnnotatedMethod.getEnhancedParameters(Disposes.class).get(0);
     }
 
     public AnnotatedParameter<? super X> getDisposesParameter() {
         return ;
     }
 
 
     public AnnotatedMethod<? super X> getAnnotated() {
         return .getAnnotated();
     }
 
     public void invokeDisposeMethod(Object receiverObject instanceCreationalContext<?> creationalContext) {
         if (receiver == null) {
             .invokeWithSpecialValue(nullDisposes.classinstancecreationalContextIllegalArgumentException.class);
         } else {
             .invokeOnInstanceWithSpecialValue(receiverDisposes.classinstancecreationalContextIllegalArgumentException.class);
         }
     }
 
     private void checkDisposalMethod(EnhancedAnnotatedMethod<T, ? super X> enhancedAnnotatedMethodAbstractClassBean<X> declaringBean) {
         if (enhancedAnnotatedMethod.getEnhancedParameters(Disposes.class).size() > 1) {
        }
        if (enhancedAnnotatedMethod.getEnhancedParameters(Observes.class).size() > 0) {
        }
        if (enhancedAnnotatedMethod.getAnnotation(Inject.class) != null) {
        }
        if (enhancedAnnotatedMethod.getAnnotation(Produces.class) != null) {
        }
        if (enhancedAnnotatedMethod.getAnnotation(Specializes.class) != null) {
        }
        if (declaringBean instanceof SessionBean<?>) {
            SessionBean<?> sessionBean = (SessionBean<?>) declaringBean;
            Set<MethodSignaturebusinessMethodSignatures = sessionBean.getBusinessMethodSignatures();
            if (!businessMethodSignatures.contains(enhancedAnnotatedMethod.getSignature())) {
                throw ..methodNotBusinessMethod(enhancedAnnotatedMethoddeclaringBean);
            }
        }
            Class<?> rawType = Reflections.getRawType(ip.getType());
            if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) {
                Validator.checkBeanMetadataInjectionPoint(thisipgetDisposesParameter().getBaseType());
            }
        }
    }
    public Type getGenericType() {
        return getDisposesParameter().getBaseType();
    }
        return ;
    }
    public AbstractClassBean<X> getDeclaringBean() {
        return ;
    }
    @Override
    public String toString() {
        return "Disposer method [" + getDisposesParameter().getDeclaringCallable() + "]";
    }
    }

    
A disposer method is bound to a producer if the producer is assignable to the disposed parameter.

Parameters:
enhancedDisposedParameter
Returns:
the set of required qualifiers for the given disposed parameter
    private Set<QualifierInstancegetRequiredQualifiers(EnhancedAnnotatedParameter<?, ? super X> enhancedDisposedParameter) {
        Set<AnnotationdisposedParameterQualifiers = enhancedDisposedParameter.getMetaAnnotations(Qualifier.class);
        if (disposedParameterQualifiers.isEmpty()) {
            disposedParameterQualifiers = Collections.<Annotationsingleton(.);
        }
        return .getServices().get(MetaAnnotationStore.class).getQualifierInstances(disposedParameterQualifiers);
    }
New to GrepCode? Check out our FAQ X