Examples of XMLInjectionPointModel


Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

        Iterator<Field> itField = fieldSet.iterator();

        while (itField.hasNext())
        {
            Field field = itField.next();
            XMLInjectionPointModel model = this.injectableFields.get(field);
            XMLInjectableField injectableField = new XMLInjectableField(field, instance, this, model,creationalContext);

            injectableField.doInjection();
        }
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

     * @param errorMessage error message
     * @return new injection point model
     */
    private static XMLInjectionPointModel getTypeInjectionPointModel(Element typeElement, String errorMessage)
    {
        XMLInjectionPointModel model = null;

        Class<?> clazz = getElementJavaType(typeElement);
        if (clazz == null)
        {
            throw new NonexistentTypeException(
                    errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " is not found in the deployment");
        }

        else if (clazz.isAnnotation() || clazz.isArray() || clazz.isEnum())
        {
            throw new WebBeansConfigurationException(
                    errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " must be class or interface type");
        }

        else
        {
            TypeVariable[] typeVariables = clazz.getTypeParameters();
            int actualTypeArgument = typeVariables.length;
            List<Type> typeArguments = new ArrayList<Type>();
            List<Annotation> bindingAnnots = new ArrayList<Annotation>();

            Class<? extends Annotation> definedBindingType = null;
            Node node;
            Element childElement;
            NodeList ns = typeElement.getChildNodes();
            for (int i = 0; i < ns.getLength(); i++)
            {
                node = ns.item(i);
                if (!(node instanceof Element))
                {
                    continue;
                }
                childElement = (Element) node;
                Type actualType = getElementJavaType(childElement);
                if (actualType == null)
                {
                    throw new NonexistentTypeException(
                            errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " is not found in the deployment");
                }
                else if (((Class) actualType).isArray() || ((Class) actualType).isEnum())
                {
                    throw new WebBeansConfigurationException(
                            errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " must be class or interface type");
                }
                else if (((Class) actualType).isAnnotation())
                {
                    Class<? extends Annotation> annotClazz = (Class<? extends Annotation>) actualType;
                    if (!AnnotationUtil.isQualifierAnnotation(annotClazz))
                    {
                        throw new WebBeansConfigurationException(
                                errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " is not a @Qualifier");
                    }

                    if (definedBindingType == null)
                    {
                        definedBindingType = annotClazz;
                    }
                    else
                    {
                        if (definedBindingType.equals(annotClazz))
                        {
                            throw new IllegalArgumentException(
                                    errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " is duplicated");
                        }
                    }

                    bindingAnnots.add(getXMLDefinedAnnotationMember(childElement, annotClazz, errorMessage));
                }
                else
                {
                    typeArguments.add(actualType);
                }
            }

            if (actualTypeArgument != typeArguments.size())
            {
                throw new WebBeansConfigurationException(errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) +
                                                         " actual type parameters size are not equals defined in the xml");
            }

            int i = 0;
            for (Type type : typeArguments)
            {
                TypeVariable typeVariable = typeVariables[i];
                Type[] bounds = typeVariable.getBounds();

                Class<?> clazzBound = (Class<?>) bounds[0];

                if (!clazzBound.isAssignableFrom((Class<?>) type))
                {
                    throw new WebBeansConfigurationException(
                            errorMessage + log.getTokenString(OWBLogConst.TEXT_JAVA_TYPENAME) + getElementJavaClassName(typeElement) + " actual type parameter bounded exception");
                }

            }

            Type[] typeArray = new Type[typeArguments.size()];
            typeArray = typeArguments.toArray(typeArray);
            model = new XMLInjectionPointModel(clazz, typeArray);

            if (bindingAnnots.isEmpty())
            {
                model.addBindingType(new DefaultLiteral());
            }

            for (Annotation annot : bindingAnnots)
            {
                model.addBindingType(annot);
            }
        }

        return model;
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

     * @param errorMessage error message
     * @return new injection point model
     */
    public static XMLInjectionPointModel getArrayInjectionPointModel(Element typeElement, String errorMessage)
    {
        XMLInjectionPointModel model = null;

        boolean isElementTypeDefined = false;
        Set<Annotation> anns = new HashSet<Annotation>();
        Node node;
        Element childElement;
        NodeList ns = typeElement.getChildNodes();

        for (int i = 0; i < ns.getLength(); i++)
        {
            node = ns.item(i);
            if (!(node instanceof Element))
            {
                continue;
            }
            childElement = (Element) node;
            Class<?> clazz = XMLUtil.getElementJavaType(childElement);

            if (clazz == null)
            {
                throw new NonexistentTypeException(errorMessage + "Class with name : " + XMLUtil.getElementJavaClassName(childElement) + " is not found for Array element type");
            }

            if (clazz.isAnnotation())
            {
                anns.add(getXMLDefinedAnnotationMember(childElement, (Class<? extends Annotation>) clazz, errorMessage));
            }
            else if (clazz.isArray() || clazz.isEnum())
            {
                throw new WebBeansConfigurationException(
                        errorMessage + "<Array> element child with Java type : " + getElementJavaClassName(typeElement) + " must be class or interface type");
            }
            else
            {
                if (isElementTypeDefined)
                {
                    throw new WebBeansConfigurationException(
                            errorMessage + "<Array> element can not have more than one child element. It has one child element that declares its type");
                }
                else
                {
                    model = new XMLInjectionPointModel(clazz);
                    isElementTypeDefined = true;
                }
            }
        }

        if (anns.size() == 0)
        {
            model.addBindingType(new DefaultLiteral());
        }

        for (Annotation ann : anns)
        {
            model.addBindingType(ann);
        }

        return model;
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

                    {
                        throw new WebBeansConfigurationException(
                                errorMessage + "Field name : " + field.getName() + " xml defined class type must be assignable to the field actual class type");
                    }

                    XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(type, errorMessage);

                    WebBeansDecoratorConfig.configureXMLDecoratorClass((AbstractInjectionTargetBean<Object>) component, model);
                }
                else
                {
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

                    throw new WebBeansConfigurationException(errorMessage + "<Produces> element must define at least one java type child");
                }
            }
            else
            {
                XMLInjectionPointModel injectionPointModel = XMLUtil.getInjectionPointModel(childElement, errorMessage);
                injectedParameters.add(injectionPointModel);

            }
        }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

        }
        /* Return type is java type */
        else
        {
            /* Configures the java api types and actual type parameters */
            XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(typeElement, errorMessage);

            producerComponentImpl.setActualTypeArguments(model.getActualTypeArguments());
            producerComponentImpl.addApiType(model.getInjectionClassType());

            if (model.getInjectionClassType().isPrimitive())
            {
                producerComponentImpl.setNullable(false);
            }
        }

View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

                //TODO: verify the first node is element.
                Element typeElement = (Element) childElement.getChildNodes().item(0);

                /* Find disposal method model */
                XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(typeElement, errorMessage);

                component.addInjectionPoint(getXMLMethodInjectionPoint(component, model, disposalMethod));

                /* Binding types for disposal method */
                Set<Annotation> bindingTypes = model.getBindingTypes();
                Annotation[] bindingAnns = new Annotation[bindingTypes.size()];
                bindingAnns = bindingTypes.toArray(bindingAnns);

                Set<Bean<?>> set = InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), bindingAnns);
                producerComponent = (XMLProducerBean<?>) set.iterator().next();

                if (producerComponent == null)
                {
                    throw new UnsatisfiedResolutionException(errorMessage + "Producer method component of the disposal method : "
                                                             + disposalMethod.getName() + "is not found");
                }

                producerComponent.setDisposalMethod(disposalMethod);

            }
            /* Disposal method parameter other than @Disposes */
            else
            {
                otherParameterElements.add(childElement);
            }
        }// end of for childs

        /* Add other params injection point models */
        for (Element otherElement : otherParameterElements)
        {
            XMLInjectionPointModel injectionPointParamModel = XMLUtil.getInjectionPointModel(otherElement, errorMessage);
            producerComponent.addDisposalMethodInjectionPointModel(injectionPointParamModel);
        }
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

                Element typeElement = (Element) childElement.getChildNodes().item(0);

                eventType = (Class<K>) XMLUtil.getElementJavaType(typeElement);

                /* Find observes method model */
                XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(typeElement, errorMessage);

                component.addInjectionPoint(getXMLMethodInjectionPoint(component, model, observesMethod));

                /* Binding types for disposal method */
                Set<Annotation> bindingTypes = model.getBindingTypes();
                Annotation[] bindingAnns = new Annotation[bindingTypes.size()];
                bindingAnns = bindingTypes.toArray(bindingAnns);

                beanObserver = new BeanObserverXMLImpl<K>(component, observesMethod, false,
                                                          bindingAnns, null /** TODO Type! */);

                beanObserver.addXMLInjectionObservesParameter(model);

                NotificationManager.getInstance().addObserver(beanObserver, eventType);

            }
            /* Disposal method parameter other than @Disposes */
            else
            {
                otherParameterElements.add(childElement);
            }
        }// end of for childs

        /* Add other params injection point models */
        if (beanObserver != null)
        {
            for (Element otherElement : otherParameterElements)
            {
                XMLInjectionPointModel injectionPointParamModel = XMLUtil.getInjectionPointModel(otherElement, errorMessage);
                beanObserver.addXMLInjectionObservesParameter(injectionPointParamModel);
            }
        }
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

        Iterator<Field> itField = fieldSet.iterator();

        while (itField.hasNext())
        {
            Field field = itField.next();
            XMLInjectionPointModel model = this.injectableFields.get(field);
            XMLInjectableField injectableField = new XMLInjectableField(field, instance, this, model,creationalContext);

            injectableField.doInjection();
        }
    }
View Full Code Here

Examples of org.apache.webbeans.inject.xml.XMLInjectionPointModel

        XMLInjectableConstructor<T> injectableConstructor = new XMLInjectableConstructor<T>(componentConstructor, component,null);
        int i = 0;
        Constructor<?> constructor = injectableConstructor.getConstructor();
        for (Element element : constructorParameterListElement)
        {
            XMLInjectionPointModel model = XMLUtil.getInjectionPointModel(element, createConfigurationFailedMessage());
            injectableConstructor.addInjectionPointModel(model);
           
            Annotation[] paramAnnos = constructor.getParameterAnnotations()[i++];           
           
            for(Annotation paramAnno : paramAnnos)
            {
                model.addAnnotation(paramAnno);
            }
           
            model.setInjectionMember(constructor);
            model.setType(XMLInjectionModelType.CONSTRUCTOR);
         
            component.addInjectionPoint(InjectionPointFactory.getXMLInjectionPointData(component, model));
        }

        component.setInjectableConstructor(injectableConstructor);
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.