Search in sources :

Example 6 with SimpleFilter

use of io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.

the class Manager method removed.

@SuppressWarnings("unchecked")
public void removed(final Collection listenerInfos) {
    for (ListenerInfo listenerInfo : (Collection<ListenerInfo>) listenerInfos) {
        // Ignore our own listeners or those that don't have any filter
        if (listenerInfo.getBundleContext() == bundleContext || listenerInfo.getFilter() == null) {
            continue;
        }
        SimpleFilter exFilter = listeners.remove(listenerInfo);
        // Iterate through known services and dereference them if needed
        Set<EndpointDescription> matches = remoteEndpoints.match(exFilter);
        for (EndpointDescription endpoint : matches) {
            Map<Long, ImportRegistration> registrations = importedServices.get(endpoint);
            if (registrations != null) {
                ImportRegistration registration = registrations.get(listenerInfo.getBundleContext().getBundle().getBundleId());
                if (registration != null) {
                    registration.removeReference(listenerInfo);
                    if (!registration.hasReferences()) {
                        registration.getImportedService().unregister();
                        registrations.remove(listenerInfo.getBundleContext().getBundle().getBundleId());
                    }
                }
            }
        }
    }
}
Also used : SimpleFilter(io.fabric8.dosgi.capset.SimpleFilter) Collection(java.util.Collection)

Example 7 with SimpleFilter

use of io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.

the class Manager method added.

// 
// ListenerHook
// 
@SuppressWarnings("unchecked")
public void added(final Collection listenerInfos) {
    for (ListenerInfo listenerInfo : (Collection<ListenerInfo>) listenerInfos) {
        // Ignore our own listeners or those that don't have any filter
        if (listenerInfo.getBundleContext() == bundleContext || listenerInfo.getFilter() == null) {
            continue;
        }
        // Make sure we only import remote services
        String filter = "(&" + listenerInfo.getFilter() + "(!(" + ENDPOINT_FRAMEWORK_UUID + "=" + this.uuid + ")))";
        SimpleFilter exFilter = SimpleFilter.parse(filter);
        listeners.put(listenerInfo, exFilter);
        // Iterate through known services and import them if needed
        Set<EndpointDescription> matches = remoteEndpoints.match(exFilter);
        for (EndpointDescription endpoint : matches) {
            doImportService(endpoint, listenerInfo);
        }
    }
}
Also used : SimpleFilter(io.fabric8.dosgi.capset.SimpleFilter) Collection(java.util.Collection)

Example 8 with SimpleFilter

use of io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.

the class SubsystemResolver method getFeatures.

public Map<Resource, String> getFeatures() {
    if (features == null) {
        SimpleFilter sf = createFilter(IDENTITY_NAMESPACE, "*", CAPABILITY_TYPE_ATTRIBUTE, TYPE_FEATURE);
        features = getResourceMapping(sf);
    }
    return features;
}
Also used : SimpleFilter(io.fabric8.agent.resolver.SimpleFilter)

Aggregations

SimpleFilter (io.fabric8.agent.resolver.SimpleFilter)6 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 Capability (org.osgi.resource.Capability)3 Requirement (org.osgi.resource.Requirement)3 SimpleFilter (io.fabric8.dosgi.capset.SimpleFilter)2 List (java.util.List)2 Resource (org.osgi.resource.Resource)2 Wire (org.osgi.resource.Wire)2 CapabilitySet (io.fabric8.agent.resolver.CapabilitySet)1 RequirementImpl (io.fabric8.agent.resolver.RequirementImpl)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 DictionaryAsMap (org.apache.felix.utils.collections.DictionaryAsMap)1