use of org.apache.felix.dm.BundleDependency in project felix by apache.
the class DependencyBuilder method createBundleDependency.
private Dependency createBundleDependency(DependencyManager dm, String added, String changed, String removed, boolean required, boolean propagate, String filter, int stateMask) {
BundleDependency bd = dm.createBundleDependency();
bd.setCallbacks(added, changed, removed);
bd.setRequired(required);
bd.setPropagate(propagate);
if (filter != null) {
bd.setFilter(filter);
}
if (stateMask != -1) {
bd.setStateMask(stateMask);
}
return bd;
}
use of org.apache.felix.dm.BundleDependency in project felix by apache.
the class BundleDependencyBuilderImpl method build.
@Override
public BundleDependency build() {
DependencyManager dm = m_component.getDependencyManager();
BundleDependency dep = dm.createBundleDependency();
if (!m_requiredSet) {
m_required = Helpers.isDependencyRequiredByDefault(m_component);
}
dep.setRequired(m_required);
if (m_filter != null) {
dep.setFilter(m_filter);
}
if (m_bundle != null) {
dep.setBundle(m_bundle);
}
if (m_stateMask != -1) {
dep.setStateMask(m_stateMask);
}
if (m_propagate) {
dep.setPropagate(true);
} else if (m_propagateInstance != null) {
dep.setPropagate(m_propagateInstance, m_propagateMethod);
} else if (m_propagateCallback != null) {
dep.setPropagate(new Propagate(), "propagate");
}
if (m_added != null || m_changed != null || m_removed != null) {
dep.setCallbacks(m_instance, m_added, m_changed, m_removed);
} else if (m_refs.size() > 0) {
Object cb = createCallbackInstance();
dep.setCallbacks(cb, "add", "change", "remove");
}
dep.setAutoConfig(m_autoConfig);
return dep;
}
use of org.apache.felix.dm.BundleDependency 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.BundleDependency in project felix by apache.
the class DependencyBuilder method createBundleDependency.
/**
* Creates a BundleDependency that we parsed from a component descriptor entry.
* @param b
* @param dm
* @param parser
* @return
*/
private Dependency createBundleDependency(DependencyManager dm) {
String added = m_metaData.getString(Params.added, null);
String changed = m_metaData.getString(Params.changed, null);
String removed = m_metaData.getString(Params.removed, null);
boolean required = "true".equals(m_metaData.getString(Params.required, "true"));
String filter = m_metaData.getString(Params.filter, null);
int stateMask = m_metaData.getInt(Params.stateMask, -1);
boolean propagate = "true".equals(m_metaData.getString(Params.propagate, "false"));
Dependency dp = createBundleDependency(dm, added, changed, removed, required, propagate, filter, stateMask);
return dp;
}
Aggregations