use of org.apache.felix.dm.ComponentDependencyDeclaration in project felix by apache.
the class FELIX4158_DependencyDeclarationTest method testServiceDependencyDeclaration.
public void testServiceDependencyDeclaration() {
DependencyManager m = getDM();
Component c = m.createComponent().setImplementation(new Object()).add(m.createServiceDependency().setService(LogService.class, "(foo=bar)"));
ComponentDeclaration cd = c.getComponentDeclaration();
ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
Assert.assertNotNull(cdds);
Assert.assertNotNull(cdds.length == 1);
Assert.assertEquals(cdds[0].getName(), "org.osgi.service.log.LogService (foo=bar)");
Assert.assertEquals(cdds[0].getSimpleName(), "org.osgi.service.log.LogService");
Assert.assertNotNull(cdds[0].getFilter());
Assert.assertEquals(cdds[0].getFilter(), "(foo=bar)");
m.clear();
}
use of org.apache.felix.dm.ComponentDependencyDeclaration in project felix by apache.
the class FELIX4158_DependencyDeclarationTest method testConfigurationDependencyDeclaration.
public void testConfigurationDependencyDeclaration() {
DependencyManager m = getDM();
Component c = m.createComponent().setImplementation(new Object()).add(m.createConfigurationDependency().setPid("foo"));
ComponentDeclaration cd = c.getComponentDeclaration();
ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
Assert.assertNotNull(cdds);
Assert.assertNotNull(cdds.length == 1);
Assert.assertEquals(cdds[0].getName(), "foo");
Assert.assertEquals(cdds[0].getSimpleName(), "foo");
Assert.assertNull(cdds[0].getFilter());
m.clear();
}
use of org.apache.felix.dm.ComponentDependencyDeclaration in project felix by apache.
the class FELIX4158_DependencyDeclarationTest method testResourceDependencyDeclaration.
public void testResourceDependencyDeclaration() throws MalformedURLException {
DependencyManager m = getDM();
Component c = m.createComponent().setImplementation(new Object()).add(m.createResourceDependency().setResource(new URL("file://localhost/path/to/file1.txt")));
ComponentDeclaration cd = c.getComponentDeclaration();
ComponentDependencyDeclaration[] cdds = cd.getComponentDependencies();
Assert.assertNotNull(cdds);
Assert.assertNotNull(cdds.length == 1);
Assert.assertEquals(cdds[0].getName(), "file://localhost/path/to/file1.txt");
Assert.assertNotNull(cdds[0].getSimpleName());
Assert.assertEquals(cdds[0].getSimpleName(), "file://localhost/path/to/file1.txt");
Assert.assertNull(cdds[0].getFilter());
m.clear();
}
use of org.apache.felix.dm.ComponentDependencyDeclaration in project felix by apache.
the class DependencyGraph method getProviderComponents.
private List<ComponentNode> getProviderComponents(DependencyNode dependencyNode) {
List<ComponentNode> result = new ArrayList<>();
ComponentDependencyDeclaration cdd = dependencyNode.getDependencyDeclaration();
if (!SERVICE.equals(cdd.getType())) {
return result;
}
for (DependencyGraphNode n : m_componentToNode.values()) {
ComponentNode componentNode = (ComponentNode) n;
if (componentProvidesDependency(componentNode, dependencyNode)) {
result.add(componentNode);
}
}
return result;
}
use of org.apache.felix.dm.ComponentDependencyDeclaration in project felix by apache.
the class DependencyGraph method buildDependecyNodesAndEdges.
private void buildDependecyNodesAndEdges() {
for (DependencyGraphNode node : m_componentToNode.values()) {
ComponentNode componentNode = (ComponentNode) node;
ComponentDependencyDeclaration[] dependencyDeclarations = componentNode.getComponentDeclaration().getComponentDependencies();
for (ComponentDependencyDeclaration cdd : dependencyDeclarations) {
if (dependencyMustBeAddedToGraph(cdd)) {
DependencyNode dependencyNode = new DependencyNode(cdd);
m_dependencyToNode.put(cdd, dependencyNode);
// add edges from the component node to newly created dependency node
componentNode.addSuccessor(dependencyNode);
// add edges from the newly created dependency node to the components
// providing those dependencies (only applicable to service dependencies)
List<ComponentNode> providerComponents = getProviderComponents(dependencyNode);
for (ComponentNode p : providerComponents) {
dependencyNode.addSuccessor(p);
}
}
}
}
}
Aggregations