Skip to content

Commit f55963e

Browse files
committed
[io] Refactor of ThreadIO
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]>
1 parent 2278487 commit f55963e

File tree

19 files changed

+1818
-1351
lines changed

19 files changed

+1818
-1351
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ dependency-reduced-pom.xml
1818
/.metadata/
1919
/workspace/
2020
.vscode
21+
gogo/command/.to

gogo/runtime/pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
org.apache.felix.service.command,
8686
org.apache.felix.service.command.annotations,
8787
org.apache.felix.service.threadio,
88+
org.apache.felix.service.systemio,
8889
</Export-Package>
8990
<Import-Package>
9091
org.osgi.service.event.*; resolution:=optional,
@@ -95,4 +96,31 @@
9596
</plugin>
9697
</plugins>
9798
</build>
99+
<profiles>
100+
<profile>
101+
<id>felix</id>
102+
<activation>
103+
<activeByDefault>true</activeByDefault>
104+
</activation>
105+
<dependencies>
106+
<dependency>
107+
<groupId>org.apache.felix</groupId>
108+
<artifactId>org.apache.felix.framework</artifactId>
109+
<scope>test</scope>
110+
</dependency>
111+
</dependencies>
112+
</profile>
113+
<profile>
114+
<id>equinox</id>
115+
<dependencies>
116+
<dependency>
117+
<groupId>org.eclipse</groupId>
118+
<artifactId>org.eclipse.osgi</artifactId>
119+
<version>3.8.0.v20120529-1548</version>
120+
<scope>test</scope>
121+
</dependency>
122+
</dependencies>
123+
</profile>
124+
</profiles>
125+
98126
</project>

0 commit comments

Comments
 (0)