Skip to content

Commit 83ed448

Browse files
committed
Update Java osgi service
1 parent bccd60d commit 83ed448

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

content/posts/java-osgi-service.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,24 @@ public interface IDoingSomethingService {
4545
```
4646
- Create the service implementation that implements service interface.
4747
```java
48+
@Component(service = { DoingSomethingService.class, IDoingSomethingService.class }, immediate = false)
49+
public class DoingSomethingService implements IDoingSomethingService{
50+
51+
@Override
52+
public void doSomething(){
53+
syserr("DoingSomethingService did something");
54+
}
55+
56+
}
4857

4958
```
5059

5160

52-
- Testing
61+
- Testing: [ServiceCaller](https://help.eclipse.org/latest/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/ServiceCaller.html)
62+
```java
63+
ServiceCaller.callOnce(MyClass.class, IDoingSomethingService.class, (myService) -> myService.doSomething());
64+
65+
```
5366

5467
## 3 DS Annotations
5568
### 3.1. @Component

0 commit comments

Comments
 (0)