많은 ServiceTracker를 만드는 번거 로움없이 여러 OSGI 서비스를 추적하는 방법을 찾고 있습니다.
그런 것 :
library.track(Service1.class, Service2.class, Service3.class, new Tracker(){
void servicesAdded(Service1 s1, Service2 s2, Service3 s3){
//do something with all 3 services
}
void servicesRemoved(){
//one of the services is not available, no operation possible
}
});
기본 OSGi API 만 사용하여 둘 이상의 서비스를 추적 할 수 없습니다. 이를 달성하는 가장 쉬운 방법은 일부 필수 서비스 참조 및 즉시 = true로 선언적 서비스 구성 요소를 만드는 것입니다. 이 서비스의 @Activate 메서드는 모든 필수 참조가있을 때 호출됩니다.
@Component(immediate=true)
public class MyComponent {
@Reference
ServiceA sa;
@Reference
ServiceB sb;
@Reference
ServiceC sc;
@Activate
public void activate() {
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다