Package org.apache.felix.ipojo.util

Examples of org.apache.felix.ipojo.util.Property


                    String name = props[j].getAttribute("name");
                    String value = props[j].getAttribute("value");
                    String type = props[j].getAttribute("type");
                    String field = props[j].getAttribute("field");

                    Property prop = new Property(name, field, null, value, type, getInstanceManager(), this);
                    properties[j] = prop;

                    // Check if the instance configuration has a value for this property
                    Object object = configuration.get(prop.getName());
                    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
View Full Code Here


     * @see org.apache.felix.ipojo.FieldInterceptor#onGet(Object, String, Object)
     */
    public Object onGet(Object pojo, String fieldName, Object value) {
        for (ProvidedService svc : m_providedServices) {
            for (int j = 0; j < svc.getProperties().length; j++) {
                Property prop = svc.getProperties()[j];
                if (fieldName.equals(prop.getField())) {
                    // Manage the No Value case.
                    return prop.onGet(pojo, fieldName, value);
                }
            }
            ServiceController ctrl = svc.getController(fieldName);
            if (ctrl != null) {
                return ctrl.getValue();
View Full Code Here

                            break;
                        }
                    }

                    if (injectionsConsistent) {
                        Property contextInjection =
                                new Property("__context", null, null, index, null,
                                        BundleContext.class.getName(), this, null);

                        contextInjection.setValue(getContext());
                        register(index, contextInjection);

                        // We register the first valid BC injection.
                        break;
                    }
View Full Code Here

            String name = configurables[i].getAttribute("name"); // The initialize method has fixed the property name.
            String value = configurables[i].getAttribute("value");

            String type = configurables[i].getAttribute("type"); // The initialize method has fixed the property name.

            Property prop = null;
            if (paramIndex == null) {
                prop = new Property(name, fieldName, methodName, value, type, getInstanceManager(), this);
            } else {
                index = Integer.parseInt(paramIndex);
                prop = new Property(name, fieldName, methodName, index,
                        value, type, getInstanceManager(), this);
            }
            addProperty(prop);

            // Check if the instance configuration contains value for the current property :
            if (configuration.get(name) == null) {
                if (fieldName != null && configuration.get(fieldName) != null) {
                    prop.setValue(configuration.get(fieldName));
                }
            } else {
                prop.setValue(configuration.get(name));
            }

            if (fieldName != null) {
                FieldMetadata field = new FieldMetadata(fieldName, type);
                getInstanceManager().register(field, prop);
View Full Code Here


        // Propagation
        if (m_mustPropagate) {
            for (int i = 0; i < m_configurableProperties.size(); i++) {
                Property prop = (Property) m_configurableProperties.get(i);
                if (prop.getValue() != Property.NO_VALUE && prop.getValue() != null) { // No injected value, or null
                    m_toPropagate.put(prop.getName(), prop.getValue());
                }
            }
            reconfigure(m_toPropagate);
        }


        // Give initial values and reset the 'invoked' flag.
        for (int i = 0; i < m_configurableProperties.size(); i++) {
            Property prop = (Property) m_configurableProperties.get(i);
            prop.reset(); // Clear the invoked flag.
            if (prop.hasField() && prop.getValue() != Property.NO_VALUE && prop.getValue() != null) {
                getInstanceManager().onSet(null, prop.getField(), prop.getValue());
            }
        }

        if (m_managedServicePID != null && m_sr == null) {
            Properties props = new Properties();
View Full Code Here

            String name = (String) keysEnumeration.nextElement();
            Object value = configuration.get(name);
            boolean found = false;
            // Check if the name is a configurable property
            for (int i = 0; i < m_configurableProperties.size(); i++) {
                Property prop = (Property) m_configurableProperties.get(i);
                if (prop.getName().equals(name)) {
                    reconfigureProperty(prop, value);
                    found = true;
                    break; // Exit the search loop
                }
            }
View Full Code Here

     * @param instance : the created object
     * @see org.apache.felix.ipojo.Handler#onCreation(java.lang.Object)
     */
    public void onCreation(Object instance) {
        for (int i = 0; i < m_configurableProperties.size(); i++) {
            Property prop = (Property) m_configurableProperties.get(i);
            if (prop.hasMethod()) {
                prop.invoke(instance);
            }
        }

        try {
            notifyUpdated(instance);
View Full Code Here

                    String name = props[j].getAttribute("name");
                    String value = props[j].getAttribute("value");
                    String type = props[j].getAttribute("type");
                    String field = props[j].getAttribute("field");

                    Property prop = new Property(name, field, null, value, type, getInstanceManager(), this);
                    properties[j] = prop;

                    // Check if the instance configuration has a value for this property
                    Object object = configuration.get(prop.getName());
                    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
View Full Code Here

        // Verify that the field name correspond to a dependency
        for (int i = 0; i < m_providedServices.length; i++) {
            ProvidedService svc = m_providedServices[i];
            boolean update = false;
            for (int j = 0; j < svc.getProperties().length; j++) {
                Property prop = svc.getProperties()[j];
                if (fieldName.equals(prop.getField()) && ! prop.getValue().equals(value)) {
                    // it is the associated property
                    prop.setValue(value);
                    update = true;
                }
            }
            if (update) {
                svc.update();
View Full Code Here

     */
    public Object onGet(Object pojo, String fieldName, Object value) {
        for (int i = 0; i < m_providedServices.length; i++) {
            ProvidedService svc = m_providedServices[i];
            for (int j = 0; j < svc.getProperties().length; j++) {
                Property prop = svc.getProperties()[j];
                if (fieldName.equals(prop.getField())) {
                    // Manage the No Value case.
                    return prop.onGet(pojo, fieldName, value);
                }
            }
            ServiceController ctrl = svc.getController(fieldName);
            if (ctrl != null) {
                return new Boolean(ctrl.getValue());
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.util.Property

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.