Search in sources :

Example 1 with Designate

use of org.eclipse.kura.configuration.metatype.Designate in project kura by eclipse.

the class ComponentMetaTypeBundleTracker method processBundleMetaType.

// ----------------------------------------------------------------
// 
// Private APIs
// 
// ----------------------------------------------------------------
private void processBundleMetaType(Bundle bundle) {
    // Push the latest configuration merging the properties in ConfigAdmin
    // with the default properties read from the component's meta-type.
    // This allows components to incrementally add new configuration
    // properties in the meta-type.
    // Only the new default properties are merged with the configuration
    // properties in ConfigurationAdmin.
    // Note: configuration properties in snapshots no longer present in
    // the meta-type are not purged.
    Map<String, Tmetadata> metas = ComponentUtil.getMetadata(this.m_context, bundle);
    for (String metatypePid : metas.keySet()) {
        try {
            // register the OCD for all the contained services
            Tmetadata metadata = metas.get(metatypePid);
            if (metadata != null) {
                // check if this component is a factory
                boolean isFactory = false;
                Designate designate = ComponentUtil.getDesignate(metadata, metatypePid);
                if (designate.getFactoryPid() != null && !designate.getFactoryPid().isEmpty()) {
                    isFactory = true;
                }
                // register the pid with the OCD and whether it is a factory
                OCD ocd = ComponentUtil.getOCD(metadata, metatypePid);
                this.m_configurationService.registerComponentOCD(metatypePid, (Tocd) ocd, isFactory);
            }
        } catch (Exception e) {
            s_logger.error("Error seeding configuration for pid: " + metatypePid, e);
        }
    }
}
Also used : OCD(org.eclipse.kura.configuration.metatype.OCD) Tmetadata(org.eclipse.kura.core.configuration.metatype.Tmetadata) Designate(org.eclipse.kura.configuration.metatype.Designate) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Aggregations

Designate (org.eclipse.kura.configuration.metatype.Designate)1 OCD (org.eclipse.kura.configuration.metatype.OCD)1 Tmetadata (org.eclipse.kura.core.configuration.metatype.Tmetadata)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1