https://github.com/amitjoy/osgi-scr-graph
Prepares a Graph for OSGi Service Component Runtime (SCR)
https://github.com/amitjoy/osgi-scr-graph
java osgi osgi-declarative-services osgi-scr
Last synced: 6 months ago
JSON representation
Prepares a Graph for OSGi Service Component Runtime (SCR)
- Host: GitHub
- URL: https://github.com/amitjoy/osgi-scr-graph
- Owner: amitjoy
- License: apache-2.0
- Created: 2021-01-29T19:52:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-13T13:31:02.000Z (over 3 years ago)
- Last Synced: 2025-01-30T22:06:22.157Z (8 months ago)
- Topics: java, osgi, osgi-declarative-services, osgi-scr
- Language: Java
- Homepage:
- Size: 5.21 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![]()
This repository comprises the API and optional Apache Felix Gogo Command to generate a DOT graph of the Service Component Runtime (SCR).
----------------------------------------------------------------------------------------------------------
[](https://github.com/amitjoy/osgi-scr-graph)
[](https://github.com/amitjoy/osgi-scr-graph)
[](https://github.com/amitjoy/osgi-scr-graph)
[](#license)
[](https://github.com/amitjoy/osgi-scr-graph/runs/1485969918)
[](https://github.com/amitjoy/osgi-scr-graph/releases/)
-----------------------------------------------------------------------------------------------------------### 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 [](https://github.com/amitjoy/osgi-scr-graph/issues)
Want to contribute? Great! Check out [Contribution Guide](https://github.com/amitjoy/osgi-scr-graph/blob/master/CONTRIBUTING.md)
--------------------------------------------------------------------------------------------------------------
### License
This project is licensed under Apache License Version 2.0 [](https://www.apache.org/licenses/LICENSE-2.0)
--------------------------------------------------------------------------------------------------------------
### 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
##### Cycle Detection
--------------------------------------------------------------------------------------------------------------
#### 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](https://graphviz.org/download/)
--------------------------------------------------------------------------------------------------------------
##### SCR Runtime

##### Cycle Detection

--------------------------------------------------------------------------------------------------------------
#### API Usage Examples
--------------------------------------------------------------------------------------------------------------
##### Graph Generation:
```java
@Component
public final class GraphGenrator {@Reference
private ScrGraph scrGraph;public String graph() {
final Graph graph = scrGraph.getGraph();final Writer writer = new StringWriter();
scrGraph.exportGraph(graph, writer);return writer.toString();
}
}
```
--------------------------------------------------------------------------------------------------------------##### Cycle Detection:
```java
@Component
public final class GraphCycleFinder {@Reference
private ScrGraph scrGraph;public String cycle() {
final List> cycles = scrGraph.getCycles();
if (cycles.isEmpty()) {
return "No SCR cycle exists";
}
final Graph cyclesAsGraph = scrGraph.getCyclesAsGraph();
final Writer writer = new StringWriter();
scrGraph.exportGraph(cyclesAsGraph, writer);return writer.toString();
}}
```
--------------------------------------------------------------------------------------------------------------