Search in sources :

Example 11 with ServiceDependency

use of org.apache.felix.dm.ServiceDependency in project felix by apache.

the class DependencyBuilder method build.

public Dependency build(Bundle b, DependencyManager dm) throws Exception {
    Dependency dp = null;
    DependencyType type;
    try {
        type = DependencyType.valueOf(m_metaData.getString(Params.type));
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("no \"type\" parameter found from metaData: " + m_metaData);
    }
    switch(type) {
        case ServiceDependency:
            dp = createServiceDependency(b, dm);
            break;
        case ConfigurationDependency:
            dp = createConfigurationDependency(b, dm);
            break;
        case BundleDependency:
            dp = createBundleDependency(dm);
            break;
        case ResourceDependency:
            dp = createResourceDependency(dm);
            break;
        default:
            throw new IllegalArgumentException("Can't build service dependency: " + type);
    }
    return dp;
}
Also used : ConfigurationDependency(org.apache.felix.dm.ConfigurationDependency) Dependency(org.apache.felix.dm.Dependency) ResourceDependency(org.apache.felix.dm.ResourceDependency) BundleDependency(org.apache.felix.dm.BundleDependency) ServiceDependency(org.apache.felix.dm.ServiceDependency)

Example 12 with ServiceDependency

use of org.apache.felix.dm.ServiceDependency in project felix by apache.

the class DependencyBuilder method createServiceDependency.

private Dependency createServiceDependency(DependencyManager dm, Class<?> serviceClass, String serviceFilter, Class<?> defaultServiceImplClass, String added, String changed, String removed, String swap, String autoConfigField, long timeout, boolean required, boolean propagate, boolean dereference) {
    ServiceDependency sd = timeout != -1 ? dm.createTemporalServiceDependency(timeout) : dm.createServiceDependency();
    sd.setService(serviceClass, serviceFilter);
    if (defaultServiceImplClass != null) {
        sd.setDefaultImplementation(defaultServiceImplClass);
    }
    sd.setCallbacks(added, changed, removed, swap);
    if (autoConfigField != null) {
        sd.setAutoConfig(autoConfigField);
    }
    if (timeout == -1) {
        sd.setRequired(required);
    }
    sd.setPropagate(propagate);
    sd.setDereference(dereference);
    return sd;
}
Also used : ServiceDependency(org.apache.felix.dm.ServiceDependency)

Aggregations

ServiceDependency (org.apache.felix.dm.ServiceDependency)12 Component (org.apache.felix.dm.Component)9 DependencyManager (org.apache.felix.dm.DependencyManager)8 Ensure (org.apache.felix.dm.itest.util.Ensure)4 DependencyGraph (org.apache.felix.dm.diagnostics.DependencyGraph)3 ArrayList (java.util.ArrayList)2 Hashtable (java.util.Hashtable)2 ComponentDeclaration (org.apache.felix.dm.ComponentDeclaration)2 ConfigurationDependency (org.apache.felix.dm.ConfigurationDependency)2 IOException (java.io.IOException)1 List (java.util.List)1 Properties (java.util.Properties)1 ForkJoinPool (java.util.concurrent.ForkJoinPool)1 TimeUnit (java.util.concurrent.TimeUnit)1 BundleDependency (org.apache.felix.dm.BundleDependency)1 ComponentStateListener (org.apache.felix.dm.ComponentStateListener)1 Dependency (org.apache.felix.dm.Dependency)1 ResourceDependency (org.apache.felix.dm.ResourceDependency)1 MissingDependency (org.apache.felix.dm.diagnostics.MissingDependency)1 TestBase (org.apache.felix.dm.itest.util.TestBase)1