Package org.apache.webbeans.exception

Examples of org.apache.webbeans.exception.WebBeansConfigurationException


        Method[] methods = decoratorClazz.getDeclaredMethods();
        for(Method method : methods)
        {
            if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
            {
                throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz + " can not have producer methods but it has one with name : " + method.getName());
            }
           
            if(AnnotationUtil.hasMethodParameterAnnotation(method, Observes.class))
            {
                throw new WebBeansConfigurationException("Decorator class : " + decoratorClazz + " can not have observer methods but it has one with name : " + method.getName());
            }
        }
       
        Set<Type> decoratorSet = new HashSet<Type>();
        ClassUtil.setInterfaceTypeHierarchy(decoratorSet, decoratorClazz);
View Full Code Here


        if (!decoratorList.isEmpty())
        {
            Class<?> clazz = bean.getReturnType();
            if (ClassUtil.isFinal(clazz.getModifiers()))
            {
                throw new WebBeansConfigurationException("Bean : " + bean.getReturnType().getName() + " can not be declared final, because it has one or more decorators");
            }

            Method[] methods = clazz.getDeclaredMethods();
            for (Method method : methods)
            {
                int modifiers = method.getModifiers();
                if (!method.isSynthetic() && !method.isBridge() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && ClassUtil.isFinal(modifiers))
                {
                    // Check decorator implements this
                    Iterator<Decorator<?>> itDecorator = decoratorList.iterator();
                    while (itDecorator.hasNext())
                    {
                        WebBeansDecorator<?> decorator = (WebBeansDecorator<?>) itDecorator.next();
                        Class<?> decClazz = decorator.getClazz();

                        try
                        {
                            if (decClazz.getMethod(method.getName(), method.getParameterTypes()) != null)
                            {
                                throw new WebBeansConfigurationException("Bean : " + bean.getReturnType().getName() + " can not define non-private, non-static, final method : "
                                                                         + method.getName() + ", because one of its decorators implements this method");
                            }

                        }
                        catch (SecurityException e)
View Full Code Here

            AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(interceptorClass);

            //Validate decorator classes
            if(!annotatedType.isAnnotationPresent(Interceptor.class) && !manager.containsCustomInterceptorClass(interceptorClass))
            {
                throw new WebBeansConfigurationException("Given class : " + interceptorClass + " is not a interceptor class");
            }  
        }               
    }   
View Full Code Here

                    {
                        for (ElementType outerValue : outerValues)
                        {
                            if (outerValue.equals(ElementType.TYPE) && outerValues.length == 1)
                            {
                                throw new WebBeansConfigurationException("Inherited StereoType with class name : " + clazz.getName()
                                                                         + " must have compatible @Target annotation with Stereotype class name : " + clazz.getName());
                            }
                        }
                    }
                    else if (innerValue.equals(ElementType.TYPE) && innerValues.length == 1)
                    {
                        for (ElementType outerValue : outerValues)
                        {
                            if (outerValue.equals(ElementType.METHOD) || outerValue.equals(ElementType.FIELD))
                            {
                                throw new WebBeansConfigurationException("Inherited StereoType with class name : " + clazz.getName()
                                                                         + " must have compatible @Target annotation with Stereotype class name : " + clazz.getName());
                            }
                        }
                    }
                }
View Full Code Here

        Asserts.assertNotNull(candidateObserverMethod, "candidateObserverMethod parameter can not be null");
        Asserts.nullCheckForClass(clazz);

        if (AnnotationUtil.hasMethodMultipleParameterAnnotation(candidateObserverMethod, Observes.class))
        {
            throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : " + clazz.getName()
                                                     + " can not define two parameters with annotated @Observes");
        }

        if (AnnotationUtil.hasMethodAnnotation(candidateObserverMethod, Produces.class) || AnnotationUtil.hasMethodAnnotation(candidateObserverMethod, Inject.class))
        {
            throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : "
                                                     + clazz.getName() + " can not annotated with annotation in the list {@Produces, @Initializer, @Destructor}");

        }

        if (AnnotationUtil.hasMethodParameterAnnotation(candidateObserverMethod, Disposes.class))
        {
            throw new WebBeansConfigurationException("Observer method : " + candidateObserverMethod.getName() + " in class : "
                                                     + clazz.getName() + " can not annotated with annotation @Disposes");
        }               
    }
View Full Code Here

            return false;
        }               

        if (!ClassUtil.isParametrizedType(injectionPoint.getType()))
        {
            throw new WebBeansConfigurationException("@Observable field injection " + injectionPoint
                                                     + " must be ParametrizedType with actual type argument");
        }
        else
        {                       
            if(ClassUtil.isParametrizedType(injectionPoint.getType()))
View Full Code Here

            Class<?> clazz = method.getReturnType();
            if (clazz.isArray() || clazz.isAnnotation())
            {
                if (!AnnotationUtil.hasAnnotation(method.getAnnotations(), Nonbinding.class))
                {
                    throw new WebBeansConfigurationException("Interceptor definition class : " + getClazz().getName() + " @InterceptorBinding : "
                                                             + binding.getName()
                                                             + " must have @NonBinding valued members for its array-valued and annotation valued members");
                }
            }
        }
View Full Code Here

        {
            getAnnotationDB().scanArchives(urlPaths);
        }
        catch (IOException e)
        {
            throw new WebBeansConfigurationException("Error while scanning the JAR archives", e);
        }
    }
View Full Code Here

                    found = true;
                    ipFound = ip;                   
                }
                else
                {
                    throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point. " +
                            "But the decorator bean : " + toString() + " has more than one");
                }
            }           
        }
       
       
        if(ipFound == null)
        {
            throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point." +
                    "But the decorator bean : " + toString() + " has none");
        }
       
        if(!(ipFound.getMember() instanceof Constructor))
        {
            AnnotatedElement element = (AnnotatedElement)ipFound.getMember();
            if(!element.isAnnotationPresent(Inject.class))
            {
                String message = "Error in decorator : "+ toString() + ". The delegate injection point must be an injected field, " +
                        "initializer method parameter or bean constructor method parameter.";

                throw new WebBeansConfigurationException(message);
            }               
        }
       
        initDelegateInternal(ipFound);
       
View Full Code Here

        else
        {
            Field[] fields = ClassUtil.getFieldsWithType(wrappedBean.getWebBeansContext(), returnType, delegateType);
            if(fields.length == 0)
            {
                throw new WebBeansConfigurationException("Delegate injection field is not found for decorator : " + toString());
            }
           
            if(fields.length > 1)
            {
                throw new WebBeansConfigurationException("More than one delegate injection field is found for decorator : " + toString());
            }

            delegateField = fields[0];
        }
       
        Type fieldType = delegateField.getGenericType();

        for (Type decType : getDecoratedTypes())
        {
            if (!(ClassUtil.getClass(decType)).isAssignableFrom(ClassUtil.getClass(fieldType)))
            {
                throw new WebBeansConfigurationException("Decorator : " + toString() + " delegate attribute must implement all of the decorator decorated types" +
                        ", but decorator type " + decType + " is not assignable from delegate type of " + fieldType);
            }
            else
            {
                if(ClassUtil.isParametrizedType(decType) && ClassUtil.isParametrizedType(fieldType))
                {                   
                    if(!fieldType.equals(decType))
                    {
                        throw new WebBeansConfigurationException("Decorator : " + toString() + " generic delegate attribute must be same with decorated type : " + decType);
                    }
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.exception.WebBeansConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.