Package org.apache.felix.ipojo.parser

Examples of org.apache.felix.ipojo.parser.FieldMetadata


            } else {
                prop.setValue(configuration.get(name));
            }

            if (fieldName != null) {
                FieldMetadata field = new FieldMetadata(fieldName, type);
                getInstanceManager().register(field, prop);
            }

            if (index != -1) {
                getInstanceManager().register(index, prop);
View Full Code Here


                    if (object != null) {
                        prop.setValue(object);
                    }

                    if (field != null) {
                        getInstanceManager().register(new FieldMetadata(field, type), this);
                        // Cannot register the property as the interception is necessary
                        // to deal with registration update.
                    }
                }

                // Attach to properties to the provided service
                svc.setProperties(properties);
            }

            Element[] controllers = providedServices[i].getElements("Controller");
            if (controllers != null) {
                for (int k = 0; k < controllers.length; k++) {
                    String field = controllers[k].getAttribute("field");
                    if (field == null) {
                        throw new ConfigurationException("The field attribute of a controller is mandatory");
                    }

                    String v = controllers[k].getAttribute("value");
                    boolean value = ! (v != null  && v.equalsIgnoreCase("false"));
                    String s = controllers[k].getAttribute("specification");
                    if (s == null) {
                        s ="ALL";
                    }
                    svc.setController(field, value, s);

                    getInstanceManager().register(new FieldMetadata(field, "boolean"), this);
                }
            }

            if (checkProvidedService(svc)) {
                addProvidedService(svc);
View Full Code Here

                // Check type if not already set
                if (type == null) {
                    if (field == null) {
                        throw new ConfigurationException("The property " + name + " has neither type nor field.");
                    }
                    FieldMetadata fieldMeta = manipulation.getField(field);
                    if (fieldMeta == null) {
                        throw new ConfigurationException("A declared property was not found in the implementation class : " + field);
                    }
                    type = fieldMeta.getFieldType();
                    props[j].addAttribute(new Attribute("type", type));
                }

                // Is the property set to immutable
                boolean immutable = false;
View Full Code Here

            }

        }

        if (field != null) {
            FieldMetadata meta = manipulation.getField(field);
            if (meta == null) {
                throw new ConfigurationException("Requirement Callback : A requirement field "
                        + field
                        + " does not exist in the implementation class");
            }
            String type = meta.getFieldType();
            if (type.endsWith("[]")) {
                if (dep.isProxy()) {
                    info("Arrays cannot be used for proxied dependencies - Disabling the proxy mode");
                    dep.setProxy(false);
                }
                // Set the dependency to multiple
                dep.setAggregate(true);
                type = type.substring(0, type.length() - 2);
            } else if (type.equals(List.class.getName()) || type.equals(Collection.class.getName())) {
                dep.setType(LIST);
                type = null;
            } else if (type.equals(Vector.class.getName())) {
                dep.setType(VECTOR);
                if (dep.isProxy()) {
                    warn("Vectors cannot be used for proxied dependencies - Disabling the proxy mode");
                    dep.setProxy(false);
                }
                type = null;
            } else if (type.equals(Set.class.getName())) {
                dep.setType(SET);
                type = null;
            } else {
                if (dep.isAggregate()) {
                    throw new ConfigurationException("A required service is not correct : the field "
                            + meta.getFieldName()
                            + " must be an array to support aggregate injections");
                }
            }
            setSpecification(dep, type, true); // Throws an exception if the field type mismatch.
        }
View Full Code Here

        //First get Pojo Metadata metadata :
        PojoMetadata pojoMeta = getPojoMetadata();
        Enumeration e = m_properties.keys();
        while (e.hasMoreElements()) {
            String field = (String) e.nextElement();
            FieldMetadata fm = pojoMeta.getField(field);

            if (fm == null) { // The field does not exist
                throw new ConfigurationException("The field " + field + " is declared in the properties file but does not exist in the pojo");
            }

            // Then check that the field is a String field
            if (!fm.getFieldType().equals(String.class.getName())) {
                throw new ConfigurationException("The field " + field + " exists in the pojo, but is not a String");
            }

            // All checks are ok, register the interceptor.
            getInstanceManager().register(fm, this);
View Full Code Here

     * @return the type of the field or {@code null} if it wasn't found
     */
    private static String getTypeFromAttributeField(String fieldRequire,
            PojoMetadata manipulation) {

        FieldMetadata field = manipulation.getField(fieldRequire);
        if (field == null) {
            return null;
        } else {
            return FieldMetadata.getReflectionType(field.getFieldType());
        }
    }
View Full Code Here

                error("One temporal dependency must be attached to a field or the field is already used");
                return;
            }
            String field = deps[i].getAttribute("field");

            FieldMetadata fieldmeta = manipulation.getField(field);
            if (fieldmeta == null) {
                error("The field " + field + " does not exist in the class " + getInstanceManager().getClassName());
                return;
            }

            String fil = deps[i].getAttribute("filter");
            Filter filter = null;
            if (fil != null) {
                try {
                    filter = getInstanceManager().getContext().createFilter(fil);
                } catch (InvalidSyntaxException e) {
                    error("Cannot create the field from " + fil + ": " + e.getMessage());
                    return;
                }
            }

            boolean agg = false;
            boolean collection = false;
            String spec = fieldmeta.getFieldType();
            if (spec.endsWith("[]")) {
                agg = true;
                spec = spec.substring(0, spec.length() - 2);
            } else if (Collection.class.getName().equals(spec)) {
                agg = true;
View Full Code Here

            throw new ConfigurationException("The handler " + NAMESPACE + ":" + NAME + " cannot be declared several times");
        }

        String field = elements[0].getAttribute(FIELD_ATTRIBUTE);
        if (field != null) {
            FieldMetadata meta = getPojoMetadata().getField(field);
            if (meta == null) {
                throw new ConfigurationException("The transaction field does not exist in the pojo class : " + field);
            }
            if (! meta.getFieldType().equals(Transaction.class.getName())) {
                throw new ConfigurationException("The transaction field type must be " + Transaction.class.getName());
            }
            // Register the interceptor
            getInstanceManager().register(meta, this);
View Full Code Here

                    }
                });
            } else if (element.containsAttribute("field")) {
                String field = element.getAttribute("field");
                final BundleContext injected = bc;
                FieldMetadata fm = getFactory().getPojoMetadata().getField(field);
                if (fm == null) {
                    throw new ConfigurationException("Cannot inject the bundle context in the field " + field + " - " +
                            "reason: the field does not exist in " + getInstanceManager().getClassName());
                }
                if (!BundleContext.class.getName().equals(fm.getFieldType())) {
                    throw new ConfigurationException("Cannot inject the bundle context in the field " + field + " - " +
                            "reason: the field " + field + " from " + getInstanceManager().getClassName() + " is not " +
                            "from the BundleContext type");
                }
                getInstanceManager().register(fm, new FieldInterceptor() {
View Full Code Here

                    }
                    type = method[0].getMethodArguments()[0];
                    configurables[i].addAttribute(new Attribute("type", type)); // Add the type to avoid configure checking
                }
            } else if (fieldName != null) {
                FieldMetadata field = manipulation.getField(fieldName);
                if (field == null) {
                    throw new ConfigurationException("Malformed property : The field " + fieldName + " does not exist in the implementation class");
                }
                type = field.getFieldType();
                configurables[i].addAttribute(new Attribute("type", type)); // Add the type to avoid configure checking
            } else if (paramIndex != null) {
                int index = Integer.parseInt(paramIndex);
                type = configurables[i].getAttribute("type");
                MethodMetadata[] cts = manipulation.getConstructors();
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.parser.FieldMetadata

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.