OSGi 서비스 확인자(service(Class<T> serviceType))를 사용하여 OSGi 번들 컨텍스트에서 유형별로 서비스를 쉽게 검색할 수 있습니다.
public class MyKuraRouter extends KuraRouter {
@Override
public void configure() throws Exception {
MyService myService = service(MyService.class);
...
}
}
public class MyKuraRouter extends KuraRouter {
@Override
public void configure() throws Exception {
MyService myService = service(MyService.class);
...
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
서비스를 찾을 수 없는 경우 null 값이 반환됩니다. 서비스를 사용할 수 없는 경우 애플리케이션을 실패하는 경우 requiredService(Class) 메서드를 대신 사용하십시오. requiredService 는 서비스를 찾을 수 없는 경우 IllegalStateException 을 throw합니다.
public class MyKuraRouter extends KuraRouter {
@Override
public void configure() throws Exception {
MyService myService = requiredService(MyService.class);
...
}
}
public class MyKuraRouter extends KuraRouter {
@Override
public void configure() throws Exception {
MyService myService = requiredService(MyService.class);
...
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow