문제

Eclipse Virgo를 사용하여 BundlecontextAware를 구현하는 Bean이있는 번들이 있습니다. Addbundlelistener를 추가하고 번들이 시작되거나 중지 될 때 이벤트를 올바르게받습니다. BundleChanged 이벤트에서 번들을 설치하십시오.

이제 설치된 번들의 응용 프로그램 컨텍스트의 모든 콩을 검색해야합니다. 번들의 응용 프로그램 컨텍스트를 검색하는 가장 좋은 방법은 무엇입니까?

 public class PluginManager implements BundleContextAware {
               private BundleContext bundleContext;
          @Override
          public void setBundleContext(BundleContext bundleContext) {
            this.bundleContext = bundleContext;
            bundleContext.addBundleListener(this);
           }

              @Override
         public void bundleChanged(BundleEvent event) {


           Bundle bundle = event.getBundle();

    //HOW TO DO TO GET ALL BEANS OF BUNDLE

        }
}
도움이 되었습니까?

해결책

다른 청취자와의 문제를 해결합니다

  public class PluginManager implements BundleContextAware,OsgiBundleApplicationContextListener {
           private BundleContext bundleContext;
      @Override
      public void setBundleContext(BundleContext bundleContext) {
        this.bundleContext = bundleContext;
        bundleContext.addBundleListener(this);
       }

          @Override
     public void bundleChanged(BundleEvent event) {


       Bundle bundle = event.getBundle();

      //NOW use this method to receive destroy event

    }
    @Override
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {

             Bundle bundle = event.getBundle();

    PluginBundleDescriptor pluginBundleDescriptor = new PluginBundleDescriptor();
    pluginBundleDescriptor.setId(bundle.getBundleId());
    pluginBundleDescriptor.setName(bundle.getSymbolicName());
    pluginBundleDescriptor.setApplicationContext(event
            .getApplicationContext());

} }

인터페이스 osgibundleApplicationcontextListener를 사용하여 서비스를 게시하십시오 (이것은 중요합니다)

 <osgi:service id="bundleContextTrackerOSGi" ref="coreModuleManager"
interface="org.springframework.osgi.context.event.OsgiBundleApplicationContextListener" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top