This repository comprises the API and optional Apache Felix Gogo Command to generate a DOT graph of the Service Component Runtime (SCR).
- Java 8
- OSGi R7
This project comprises the following list of bundles -
in.bytehue.osgi.scr.graph
- The Service Component Runtime(SCR) Graph API and Implementationin.bytehue.osgi.scr.graph.example
- Example project for usages
To use it in the OSGi environment, you only need to install in.bytehue.osgi.scr.graph
.
Import as Eclipse Projects
- Install Bndtools
- Import all the projects (
File -> Import -> General -> Existing Projects into Workspace
)
Run ./gradlew clean build
in the project root directory
Amit Kumar Mondal (admin@amitinside.com)
Want to contribute? Great! Check out Contribution Guide
This project is licensed under Apache License Version 2.0
Note that, the command will only work if and only if Felix Gogo bundles are installed in the OSGi runtime.
Copy the DOT graph representation format to a file having an extension of .dot
and execute the following to convert them to PNG/SVG
dot -Tpng filename.dot -o filename.png
dot -Tsvg filename.dot -o filename.svg
To install dot
in your computer, please follow this link
@Component
public final class GraphGenrator {
@Reference
private ScrGraph scrGraph;
public String graph() {
final Graph<ScrComponent, DefaultEdge> graph = scrGraph.getGraph();
final Writer writer = new StringWriter();
scrGraph.exportGraph(graph, writer);
return writer.toString();
}
}
@Component
public final class GraphCycleFinder {
@Reference
private ScrGraph scrGraph;
public String cycle() {
final List<List<ScrComponent>> cycles = scrGraph.getCycles();
if (cycles.isEmpty()) {
return "No SCR cycle exists";
}
final Graph<ScrComponent, DefaultEdge> cyclesAsGraph = scrGraph.getCyclesAsGraph();
final Writer writer = new StringWriter();
scrGraph.exportGraph(cyclesAsGraph, writer);
return writer.toString();
}
}