Search in sources :

Example 6 with RelationshipInfoImpl

use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.

the class ModelInfoEnhancerService method updateSyntheticServiceArtefactsAndNotifyListeners.

private void updateSyntheticServiceArtefactsAndNotifyListeners(RelationshipInfo r) {
    // We need to update our two relationships and the synthetic
    // component
    // Hopefully the thing which changed won't prevent us
    // from finding our relationship
    String componentId = constructServiceComponentId(r);
    // Do the relationships first
    // The registration has type "service registration", and the
    // original provider and name
    String registrationRelationshipId = SERVICE_REGISTRATION + "/" + r.getName() + "/" + r.getProvidedBy().getId();
    RelationshipInfoImpl registrationRelationship = (RelationshipInfoImpl) relationships.get(registrationRelationshipId);
    registrationRelationship.setName(r.getName());
    registrationRelationship.setRelationshipAspects(r.getRelationshipAspects());
    // The consumers have type "service usage", and the
    // original name, and the new provided by
    String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + componentId;
    RelationshipInfoImpl usageRelationship = (RelationshipInfoImpl) relationships.get(usageRelationshipId);
    // The consumers may have changed, so we update the usage relationship
    usageRelationship.setConsumedBy(r.getConsumedBy());
    usageRelationship.setName(r.getName());
    usageRelationship.setRelationshipAspects(r.getRelationshipAspects());
    for (RelationshipInfoListener listener : rlisteners) {
        if (usageRelationship != null) {
            listener.updateRelationship(usageRelationship);
        }
        if (registrationRelationship != null) {
            listener.updateRelationship(registrationRelationship);
        }
    }
    ComponentInfo component = components.get(componentId);
    if (component != null) {
        // Tell our listeners their service component was updated
        for (ComponentInfoListener listener : clisteners) {
            listener.updateComponent(component);
        }
    }
}
Also used : RelationshipInfoImpl(org.apache.aries.samples.goat.info.RelationshipInfoImpl) ComponentInfo(org.apache.aries.samples.goat.api.ComponentInfo)

Aggregations

ComponentInfo (org.apache.aries.samples.goat.api.ComponentInfo)6 RelationshipInfoImpl (org.apache.aries.samples.goat.info.RelationshipInfoImpl)6 ArrayList (java.util.ArrayList)3 RelationshipInfo (org.apache.aries.samples.goat.api.RelationshipInfo)3 RelationshipAspect (org.apache.aries.samples.goat.api.RelationshipAspect)2 Bundle (org.osgi.framework.Bundle)2 ServiceReference (org.osgi.framework.ServiceReference)2 ExportedPackage (org.osgi.service.packageadmin.ExportedPackage)1 PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)1