/** * Gets a property by name. * @param name the property name * @return the property description with the given name, {@code null} if there is no property with the given name. * @since 1.11.0 */ public PropertyDescription getPropertyByName(String name) { for (PropertyDescription desc :m_properties) { if (name.equals(desc.getName())) { return desc; } } return null; }
/** * Gets a property by name. * @param name the property name * @return the property description with the given name, {@code null} if there is no property with the given name. * @since 1.11.0 */ public PropertyDescription getPropertyByName(String name) { for (PropertyDescription desc :m_properties) { if (name.equals(desc.getName())) { return desc; } } return null; }
/** * Adds a configuration properties to the component type. * * @param pd : the property to add */ public void addProperty(PropertyDescription pd) { //NOPMD remove the instance name of the 'name' property. String name = pd.getName(); // Check if the property is not already in the array for (int i = 0; i < m_properties.length; i++) { PropertyDescription desc = m_properties[i]; if (desc.getName().equals(name)) { return; } } PropertyDescription[] newProps = new PropertyDescription[m_properties.length + 1]; System.arraycopy(m_properties, 0, newProps, 0, m_properties.length); newProps[m_properties.length] = pd; m_properties = newProps; }
/** * Does the factory support the given property ? This method check if the property is contained in the given property description array. * @param name : name of the property * @param props : list of property description * @return true if the factory support this property */ private boolean containsProperty(String name, org.apache.felix.ipojo.architecture.PropertyDescription[] props) { for (int i = 0; props != null && i < props.length; i++) { if (props[i].getName().equalsIgnoreCase(name)) { return true; } } if (name.equalsIgnoreCase("name")) { return true; } // Skip the name property return false; }
/** * Adds a configuration properties to the component type. * * @param pd : the property to add */ public void addProperty(PropertyDescription pd) { //NOPMD remove the instance name of the 'name' property. String name = pd.getName(); // Check if the property is not already in the array for (int i = 0; i < m_properties.length; i++) { PropertyDescription desc = m_properties[i]; if (desc.getName().equals(name)) { return; } } PropertyDescription[] newProps = new PropertyDescription[m_properties.length + 1]; System.arraycopy(m_properties, 0, newProps, 0, m_properties.length); newProps[m_properties.length] = pd; m_properties = newProps; }
/** * Does the factory support the given property ? This method check if the property is contained in the given property description array. * @param name : name of the property * @param props : list of property description * @return true if the factory support this property */ private boolean containsProperty(String name, org.apache.felix.ipojo.architecture.PropertyDescription[] props) { for (int i = 0; props != null && i < props.length; i++) { if (props[i].getName().equalsIgnoreCase(name)) { return true; } } if (name.equalsIgnoreCase("name")) { return true; } // Skip the name property return false; }
/** * Gets the property description for the current property. * @param instance the component instance on which looking for the property. * @return the property description associated with the current property * or <code>null</code> if not found. */ public PropertyDescription getPropertyDescription(ComponentInstance instance) { PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription(); PropertyDescription[] props = desc.getProperties(); for (int i = 0; i < props.length; i++) { if ((m_name != null && m_name.equals(props[i].getName())) || (m_field != null && m_field.equals(props[i].getName()))) { return props[i]; } } return null; }
/** * Computes the default service properties to publish : * factory.name, service.pid, component.providedServiceSpecification, component.properties, component.description, factory.State. * * @return : the dictionary of properties to publish. */ public Dictionary<String, Object> getPropertiesToPublish() { Hashtable<String, Object> props = new Hashtable<String, Object>(); props.put("factory.name", m_factory.getName()); props.put(Constants.SERVICE_PID, m_factory.getName()); // Service PID is required for the integration in the configuration admin. // Add the version if set String v = getVersion(); if (v != null) { props.put(Factory.FACTORY_VERSION_PROPERTY, v); } props.put("component.providedServiceSpecifications", m_providedServiceSpecification); props.put("component.properties", m_properties); props.put("component.description", this); // add every immutable property for (PropertyDescription m_property : m_properties) { if (m_property.isImmutable() && m_property.getValue() != null) { props.put(m_property.getName(), m_property.getObjectValue(m_factory.getBundleContext())); } } // Add factory state props.put("factory.state", m_factory.getState()); return props; }
/** * Computes the default service properties to publish : * factory.name, service.pid, component.providedServiceSpecification, component.properties, component.description, factory.State. * * @return : the dictionary of properties to publish. */ public Dictionary<String, Object> getPropertiesToPublish() { Hashtable<String, Object> props = new Hashtable<String, Object>(); props.put("factory.name", m_factory.getName()); props.put(Constants.SERVICE_PID, m_factory.getName()); // Service PID is required for the integration in the configuration admin. // Add the version if set String v = getVersion(); if (v != null) { props.put(Factory.FACTORY_VERSION_PROPERTY, v); } props.put("component.providedServiceSpecifications", m_providedServiceSpecification); props.put("component.properties", m_properties); props.put("component.description", this); // add every immutable property for (PropertyDescription m_property : m_properties) { if (m_property.isImmutable() && m_property.getValue() != null) { props.put(m_property.getName(), m_property.getObjectValue(m_factory.getBundleContext())); } } // Add factory state props.put("factory.state", m_factory.getState()); return props; }
if (prop.isImmutable() && conf.get(prop.getName()) != null) { throw new UnacceptableConfiguration("The property " + prop + " cannot be overridden : immutable " + "property"); // The instance configuration tries to override an immutable property. if (prop.isMandatory() && prop.getValue() == null && conf.get(prop.getName()) == null) { throw new UnacceptableConfiguration("The mandatory property " + prop.getName() + " is missing"); // The property must be set.
if (prop.isImmutable() && conf.get(prop.getName()) != null) { throw new UnacceptableConfiguration("The property " + prop + " cannot be overridden : immutable " + "property"); // The instance configuration tries to override an immutable property. if (prop.isMandatory() && prop.getValue() == null && conf.get(prop.getName()) == null) { throw new UnacceptableConfiguration("The mandatory property " + prop.getName() + " is missing"); // The property must be set.
String name = m_properties[i].getName(); Object value = m_properties[i].getValue(); Element property = new Element("property", "");
String name = m_properties[i].getName(); Object value = m_properties[i].getValue(); Element property = new Element("property", "");
prop.addAttribute(new Attribute("name", m_properties[i].getName())); prop.addAttribute(new Attribute("type", m_properties[i].getType())); if (m_properties[i].isMandatory() && m_properties[i].getValue() == null) {
prop.addAttribute(new Attribute("name", m_properties[i].getName())); prop.addAttribute(new Attribute("type", m_properties[i].getType())); if (m_properties[i].isMandatory() && m_properties[i].getValue() == null) {
pw.object(); pw.key("name"); pw.value(props[i].getName()); pw.key("type"); pw.value(props[i].getType());