Skip to content

Commit

Permalink
[io] Refactor of ThreadIO
Browse files Browse the repository at this point in the history
The ThreadIO service replaces the System streams so that the output and input on a thread associated with a command can be captured.

Unfortunately, this occupies the singletons of System.in/out/err. There are many others that want to use the same mechanism.

This change introduces a SystemIO service that dispatches the System streams to any number of listeners. The ThreadIO is modified to use this service.

By default, the Gogo runtime will register its own SystemIO service. However, it is possible to disable this with the "org.apache.felix.gogo.systemio.timeout" (SystemIO.TIMEOUT) framework property. If this is set to a numeric value, it will indicate that Gogo should look for an external service. The numeric value indicates the amount of time Gogo should wait for this service. 30000 is a common value. 

Additionally, there is an onClose method added to the session so that it is possible to get a callback when the session closes. Gogo commands can use this to cancel any activity related to a session. The lambda is weakly referenced so it is necessary that the command keeps a strong reference to the callback.

Signed-off-by: Peter Kriens <[email protected]>
  • Loading branch information
pkriens committed Sep 11, 2020
1 parent c3f6eba commit 33f089b
Show file tree
Hide file tree
Showing 20 changed files with 1,820 additions and 1,353 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dependency-reduced-pom.xml
.DS_Store
/.metadata/
/workspace/
gogo/command/.to
2 changes: 1 addition & 1 deletion gogo/command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
<version>6-SNAPSHOT</version>
<version>7-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>

Expand Down
30 changes: 29 additions & 1 deletion gogo/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>gogo-parent</artifactId>
<version>6-SNAPSHOT</version>
<version>7-SNAPSHOT</version>
<relativePath>../gogo-parent/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -84,6 +84,7 @@
org.apache.felix.service.command,
org.apache.felix.service.command.annotations,
org.apache.felix.service.threadio,
org.apache.felix.service.systemio,
</Export-Package>
<Import-Package>
org.osgi.service.event.*; resolution:=optional,
Expand All @@ -94,4 +95,31 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>felix</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>equinox</id>
<dependencies>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.8.0.v20120529-1548</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Loading

0 comments on commit 33f089b

Please sign in to comment.