Examples of ViolationMessageBuilder


Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    }

    public static void throwUnsatisfiedResolutionException(
            Class type, InjectionPoint injectionPoint, Annotation... qualifiers)
    {
        ViolationMessageBuilder violationMessage =
                newViolation("Api type [", type.getName(), "] is not found with the qualifiers ");

        violationMessage.addLine(createQualifierMessage(qualifiers));

        if (injectionPoint != null)
        {
            violationMessage.addLine("for injection into ", injectionPoint.toString());
        }

        throw new UnsatisfiedResolutionException(violationMessage.toString());
    }
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    public static void throwAmbiguousResolutionException(Set<Bean<?>> beans, Class type, InjectionPoint injectionPoint, Annotation... qualifiers)
    {
        String qualifierMessage = createQualifierMessage(qualifiers);

        ViolationMessageBuilder violationMessage;

        if(type != null)
        {
            violationMessage = newViolation("There is more than one api type with : ",
                    ClassUtil.getClass(type).getName(), " with qualifiers : ", qualifierMessage);
            if (injectionPoint != null)
            {
                violationMessage.addLine("for injection into ", injectionPoint.toString());
            }
        }
        else
        {
            violationMessage = newViolation("Ambiguous resolution");
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    public void validateProxyable(OwbBean<?> bean)
    {
        // Unproxyable test for NormalScoped beans
        if (webBeansContext.getBeanManagerImpl().isNormalScope(bean.getScope()))
        {
            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();

            Class<?> beanClass = bean.getReturnType();
           
            if(!beanClass.isInterface() && beanClass != Object.class)
            {
                if(beanClass.isPrimitive())
                {
                    violationMessage.addLine("It isn't possible to proxy a primitive type (" + beanClass.getName(), ")");
                }

                if(beanClass.isArray())
                {
                    violationMessage.addLine("It isn't possible to proxy an array type (", beanClass.getName(), ")");
                }

                if(!violationMessage.containsViolation())
                {
                    if (Modifier.isFinal(beanClass.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow to proxy that.");
                    }

                    String finalMethodName = hasNonPrivateFinalMethod(beanClass);
                    if (finalMethodName != null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has final method "+ finalMethodName + " CDI doesn't allow to proxy that.");
                    }


                    Constructor<?> cons = webBeansContext.getWebBeansUtil().getNoArgConstructor(beanClass);
                    if (cons == null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
                                "A public or protected constructor without args is required!");
                    }
                    else if (Modifier.isPrivate(cons.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow to proxy that.");
                    }
                }

                //Throw Exception
                if(violationMessage.containsViolation())
                {
                    throwUnproxyableResolutionException(violationMessage);
                }
            }
        }
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    public UnproxyableResolutionException validateProxyable(OwbBean<?> bean)
    {
        // Unproxyable test for NormalScoped beans
        if (webBeansContext.getBeanManagerImpl().isNormalScope(bean.getScope()))
        {
            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();

            Class<?> beanClass = bean.getReturnType();
           
            if(!beanClass.isInterface() && beanClass != Object.class)
            {
                if(beanClass.isPrimitive())
                {
                    violationMessage.addLine("It isn't possible to proxy a primitive type (" + beanClass.getName(), ")");
                }

                if(beanClass.isArray())
                {
                    violationMessage.addLine("It isn't possible to proxy an array type (", beanClass.getName(), ")");
                }

                if(!violationMessage.containsViolation())
                {
                    if (Modifier.isFinal(beanClass.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow to proxy that.");
                    }

                    String finalMethodName = hasNonPrivateFinalMethod(beanClass);
                    if (finalMethodName != null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has final method "+ finalMethodName + " CDI doesn't allow to proxy that.");
                    }


                    Constructor<?> cons = webBeansContext.getWebBeansUtil().getNoArgConstructor(beanClass);
                    if (cons == null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
                                "A public or protected constructor without args is required!");
                    }
                    else if (Modifier.isPrivate(cons.getModifiers()))
                    {
                        final boolean containsViolation = violationMessage.containsViolation();
                        violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow to proxy that.");
                        if (!containsViolation)
                        { // lazy
                            return createUnproxyableResolutionException(violationMessage);
                        }
                    }
                }

                //Throw Exception
                if(violationMessage.containsViolation())
                {
                    throwUnproxyableResolutionException(violationMessage);
                }
            }
        }
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    }

    public static void throwUnsatisfiedResolutionException(
            Class type, InjectionPoint injectionPoint, Annotation... qualifiers)
    {
        ViolationMessageBuilder violationMessage =
                newViolation("Api type [", type.getName(), "] is not found with the qualifiers ");

        violationMessage.addLine(createQualifierMessage(qualifiers));

        if (injectionPoint != null)
        {
            violationMessage.addLine("for injection into ", injectionPoint.toString());
        }

        throw new UnsatisfiedResolutionException(violationMessage.toString());
    }
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    public static void throwAmbiguousResolutionException(Set<Bean<?>> beans, Class type, InjectionPoint injectionPoint, Annotation... qualifiers)
    {
        String qualifierMessage = createQualifierMessage(qualifiers);

        ViolationMessageBuilder violationMessage;

        if(type != null)
        {
            violationMessage = newViolation("There is more than one api type with : ",
                    ClassUtil.getClass(type).getName(), " with qualifiers : ", qualifierMessage);
            if (injectionPoint != null)
            {
                violationMessage.addLine("for injection into ", injectionPoint.toString());
            }
        }
        else
        {
            violationMessage = newViolation("Ambiguous resolution");
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

        Asserts.assertNotNull(scopeType, "scopeType parameter can not be null");

        //Unproxiable test for NormalScoped beans
        if (webBeansContext.getBeanManagerImpl().isScopeTypeNormal(scopeType))
        {
            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();

            Class<?> beanClass;
            if (bean instanceof OwbBean)
            {
                beanClass = ((OwbBean)bean).getReturnType();
            }
            else
            {
                beanClass = bean.getBeanClass();
            }
           
            if(!beanClass.isInterface() && beanClass != Object.class)
            {
                if(beanClass.isPrimitive())
                {
                    violationMessage.addLine("It isn't possible to proxy a primitive type (" + beanClass.getName(), ")");
                }

                if(ClassUtil.isArray(beanClass))
                {
                    violationMessage.addLine("It isn't possible to proxy an array type (", beanClass.getName(), ")");
                }

                if(!violationMessage.containsViolation())
                {
                    if (ClassUtil.isFinal(beanClass.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow to proxy that.");
                    }

                    Method[] methods = SecurityUtil.doPrivilegedGetDeclaredMethods(beanClass);
                    for (Method m : methods)
                    {
                        int modifiers = m.getModifiers();
                        if (ClassUtil.isFinal(modifiers) && !Modifier.isPrivate(modifiers) &&
                            !m.isSynthetic() && !m.isBridge())
                        {
                            violationMessage.addLine(beanClass.getName(), " has final method "+ m + " CDI doesn't allow to proxy that.");
                        }
                    }

                    Constructor<?> cons = getNoArgConstructor(beanClass);
                    if (cons == null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
                                "A public or protected constructor without args is required!");
                    }
                    else if (Modifier.isPrivate(cons.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow to proxy that.");
                    }
                }

                //Throw Exception
                if(violationMessage.containsViolation())
                {
                    throwUnproxyableResolutionException(violationMessage);
                }
            }
        }
View Full Code Here

Examples of org.apache.webbeans.exception.helper.ViolationMessageBuilder

    public void validateProxyable(OwbBean<?> bean)
    {
        // Unproxyable test for NormalScoped beans
        if (webBeansContext.getBeanManagerImpl().isNormalScope(bean.getScope()))
        {
            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();

            Class<?> beanClass = bean.getReturnType();
           
            if(!beanClass.isInterface() && beanClass != Object.class)
            {
                if(beanClass.isPrimitive())
                {
                    violationMessage.addLine("It isn't possible to proxy a primitive type (" + beanClass.getName(), ")");
                }

                if(beanClass.isArray())
                {
                    violationMessage.addLine("It isn't possible to proxy an array type (", beanClass.getName(), ")");
                }

                if(!violationMessage.containsViolation())
                {
                    if (Modifier.isFinal(beanClass.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow to proxy that.");
                    }

                    String finalMethodName = hasNonPrivateFinalMethod(beanClass);
                    if (finalMethodName != null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has final method "+ finalMethodName + " CDI doesn't allow to proxy that.");
                    }


                    Constructor<?> cons = webBeansContext.getWebBeansUtil().getNoArgConstructor(beanClass);
                    if (cons == null)
                    {
                        violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
                                "A public or protected constructor without args is required!");
                    }
                    else if (Modifier.isPrivate(cons.getModifiers()))
                    {
                        violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow to proxy that.");
                    }
                }

                //Throw Exception
                if(violationMessage.containsViolation())
                {
                    throwUnproxyableResolutionException(violationMessage);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.