Skip to content

Prepares a Graph for OSGi Service Component Runtime (SCR)

License

Notifications You must be signed in to change notification settings

amitjoy/osgi-scr-graph

Repository files navigation

logo

This repository comprises the API and optional Apache Felix Gogo Command to generate a DOT graph of the Service Component Runtime (SCR).


amitjoy - osgi-scr-graph stars - osgi-scr-graph forks - osgi-scr-graph License - Apache Build - Passing GitHub release

Minimum Requirements

  1. Java 8
  2. OSGi R7

Modules

This project comprises the following list of bundles -

  1. in.bytehue.osgi.scr.graph - The Service Component Runtime(SCR) Graph API and Implementation
  2. in.bytehue.osgi.scr.graph.example - Example project for usages

Installation

To use it in the OSGi environment, you only need to install in.bytehue.osgi.scr.graph.


Project Import

Import as Eclipse Projects

  1. Install Bndtools
  2. Import all the projects (File -> Import -> General -> Existing Projects into Workspace)

Building from Source

Run ./gradlew clean build in the project root directory


Developer

Amit Kumar Mondal (admin@amitinside.com)


Contribution contributions welcome

Want to contribute? Great! Check out Contribution Guide


License

This project is licensed under Apache License Version 2.0 License


Usage


Apache Felix Gogo Command


Note that, the command will only work if and only if Felix Gogo bundles are installed in the OSGi runtime.

Graph Generation

help-graph

gogo

Cycle Detection

help-cycle

cycle_gogo

plain-cycle

Screenshot 2021-02-02 at 12 01 20


DOT Graph

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


SCR Runtime

graph

Cycle Detection

cycle


API Usage Examples


Graph Generation:
@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();
    }
}

Cycle Detection:
@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();
    }

}

About

Prepares a Graph for OSGi Service Component Runtime (SCR)

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages