Search in sources :

Example 6 with RelationshipInfo

use of org.apache.aries.samples.goat.api.RelationshipInfo in project aries by apache.

the class ModelInfoEnhancerService method removeSyntheticServiceArtefactsAndNotifyListeners.

private void removeSyntheticServiceArtefactsAndNotifyListeners(RelationshipInfo r) {
    // We need to remove our two relationships and the synthetic
    // component
    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();
    RelationshipInfo registrationRelationship = relationships.get(registrationRelationshipId);
    // The consumers have type "service usage", and the
    // original name, and the new provided by
    String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + componentId;
    RelationshipInfo usageRelationship = relationships.get(usageRelationshipId);
    relationships.remove(usageRelationshipId);
    relationships.remove(registrationRelationshipId);
    for (RelationshipInfoListener listener : rlisteners) {
        if (usageRelationship != null) {
            listener.removeRelationship(usageRelationship);
        }
        if (registrationRelationship != null) {
            listener.removeRelationship(registrationRelationship);
        }
    }
    ComponentInfo component = components.remove(componentId);
    if (component != null) {
        // Tell our listeners their service component went away
        for (ComponentInfoListener listener : clisteners) {
            listener.removeComponent(component);
        }
    }
}
Also used : RelationshipInfo(org.apache.aries.samples.goat.api.RelationshipInfo) ComponentInfo(org.apache.aries.samples.goat.api.ComponentInfo)

Aggregations

RelationshipInfo (org.apache.aries.samples.goat.api.RelationshipInfo)6 ComponentInfo (org.apache.aries.samples.goat.api.ComponentInfo)5 ArrayList (java.util.ArrayList)3 RelationshipInfoImpl (org.apache.aries.samples.goat.info.RelationshipInfoImpl)3 ServiceReference (org.osgi.framework.ServiceReference)2 ServletContext (javax.servlet.ServletContext)1 ComponentInfoProvider (org.apache.aries.samples.goat.api.ComponentInfoProvider)1 ModelInfoService (org.apache.aries.samples.goat.api.ModelInfoService)1 RelationshipAspect (org.apache.aries.samples.goat.api.RelationshipAspect)1 RelationshipInfoProvider (org.apache.aries.samples.goat.api.RelationshipInfoProvider)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 ExportedPackage (org.osgi.service.packageadmin.ExportedPackage)1 PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)1