Package org.apache.felix.ipojo.util

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


        m_serviceSpecifications = specification;

        // Add instance name, factory name and factory version is set.
        try {
            addProperty(new Property("instance.name", null, null, handler.getInstanceManager().getInstanceName(), String.class.getName(), handler.getInstanceManager(), handler));
            addProperty(new Property("factory.name", null, null, handler.getInstanceManager().getFactory().getFactoryName(), String.class.getName(), handler.getInstanceManager(), handler));

            if (handler.getInstanceManager().getFactory().getVersion() != null) {
                addProperty(new Property("factory.version", null, null, handler.getInstanceManager().getFactory().getVersion(), String.class.getName(), handler.getInstanceManager(), handler));
            }

            // Add the service.* if defined
            if (conf.get(Constants.SERVICE_PID) != null) {
                addProperty(new Property(Constants.SERVICE_PID, null, null, (String) conf.get(Constants.SERVICE_PID), String.class.getName(), handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_RANKING) != null) {
                addProperty(new Property(Constants.SERVICE_RANKING, null, null, (String) conf.get(Constants.SERVICE_RANKING), "int", handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_VENDOR) != null) {
                addProperty(new Property(Constants.SERVICE_VENDOR, null, null, (String) conf.get(Constants.SERVICE_VENDOR), String.class.getName(), handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_DESCRIPTION) != null) {
                addProperty(new Property(Constants.SERVICE_DESCRIPTION, null, null, (String) conf.get(Constants.SERVICE_DESCRIPTION), String.class.getName(), handler.getInstanceManager(), handler));
            }

        } catch (ConfigurationException e) {
            m_handler.error("An exception occurs when adding instance.name and factory.name property : " + e.getMessage());
        }
View Full Code Here


                }
            }

            if (! alreadyExisting) {
                try {
                    Property prop = new Property(key, null, null, value.toString(), value.getClass().getName(), getInstanceManager(), m_handler);
                    addProperty(prop);
                    updated = true;
                } catch (ConfigurationException e) {
                    m_handler.error("The propagated property " + key + " cannot be created correctly : " + e.getMessage());
                }
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;
            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

                    || name.equals(Constants.SERVICE_PID)
                    || name.equals(MANAGED_SERVICE_PID)) {
                continue;
            }
            // Do we have a property.
            Property p = getPropertyByName(name);
            if (p != null) {
                // Change detection based on the value.
                if (p.getValue() == null) {
                    return true;
                } else if (! p.getValue().equals(value)) {
                    return true;
                }
            } else {
                // Was it propagated ?
                if (m_propagatedFromCA != null) {
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

    public void onSet(Object pojo, String fieldName, Object value) {
        // Verify that the field name correspond to a dependency
        for (ProvidedService svc : m_providedServices) {
            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

     * @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

            m_policy = CUSTOM_STRATEGY;
        }

        // Add instance name, factory name and factory version is set.
        try {
            addProperty(new Property(Factory.INSTANCE_NAME_PROPERTY, null, null, handler.getInstanceManager().getInstanceName(), String.class.getName(), handler.getInstanceManager(), handler));
            addProperty(new Property("factory.name", null, null, handler.getInstanceManager().getFactory().getFactoryName(), String.class.getName(), handler.getInstanceManager(), handler));

            if (handler.getInstanceManager().getFactory().getVersion() != null) {
                addProperty(new Property(Factory.FACTORY_VERSION_PROPERTY, null, null, handler.getInstanceManager().getFactory().getVersion(), String.class.getName(), handler.getInstanceManager(), handler));
            }

            // Add the service.* if defined
            if (conf.get(Constants.SERVICE_PID) != null) {
                addProperty(new Property(Constants.SERVICE_PID, null, null, (String) conf.get(Constants.SERVICE_PID), String.class.getName(), handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_RANKING) != null) {
                addProperty(new Property(Constants.SERVICE_RANKING, null, null, (String) conf.get(Constants.SERVICE_RANKING), "int", handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_VENDOR) != null) {
                addProperty(new Property(Constants.SERVICE_VENDOR, null, null, (String) conf.get(Constants.SERVICE_VENDOR), String.class.getName(), handler.getInstanceManager(), handler));
            }
            if (conf.get(Constants.SERVICE_DESCRIPTION) != null) {
                addProperty(new Property(Constants.SERVICE_DESCRIPTION, null, null, (String) conf.get(Constants.SERVICE_DESCRIPTION), String.class.getName(), handler.getInstanceManager(), handler));
            }

        } catch (ConfigurationException e) {
            m_handler.error("An exception occurs when adding instance.name and factory.name property : " + e.getMessage());
        }
View Full Code Here

        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            Object value = props.get(key);

            // m_properties can be modified by another thread, we need to make a stack confinement
            Property property;
            synchronized (this) {
                property = m_properties.get(key);
            }

            if (property != null) {
                // Already existing property
                if (property.getValue() == null || !value.equals(property.getValue())) {
                    property.setValue(value);
                    updated = true;
                }
            } else {
                try {
                    // Create the property.
                    property = new Property(key, null, null, value, getInstanceManager(), m_handler);
                    addProperty(property);
                    updated = true;
                } catch (ConfigurationException e) {
                    m_handler.error("The propagated property " + key + " cannot be created correctly : " + e.getMessage());
                }
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.