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;
}
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;
}
Aggregations