「Greenpages app」は、Eclipse Virgo サイトで入手できるサンプル Web アプリケーションで、OSGI と Spring DM を一緒に使用する例を提供し、Virgo コンテナーにデプロイできます。http://www.eclipse.org/virgo/samples/を参照してください。エラーなしでアプリを実行できました。しかし、 org.springframework.osgi.context.event.OsgiBundleApplicationContextListenerインターフェースを実装しようとするとすぐに、すべてがうまくいかず、次のエラーが発生し始めます。
java.lang.IllegalArgumentException: 必要なプロパティ 'bundleContext' が設定されていません
OsgiBundleApplicationContextListener インターフェースは、BundleContext イベントをリッスンする方法を提供します。参照: http://docs.spring.io/osgi/docs/current/api/org/springframework/osgi/context/event/OsgiBundleApplicationContextListener.html
私のコード:
public class ApplicationContextObserver implements OsgiBundleApplicationContextListener { private transient int countRefreshed = 0; プライベート トランジェント int countClosed = 0;
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent evt) {
if(evt instanceof
OsgiBundleContextRefreshedEvent) {
countRefreshed++;
} else if(evt instanceof
OsgiBundleContextClosedEvent) {
countClosed++;
}
}
public int getCountRefreshed() {
return countRefreshed;
}
public int getCountClosed() {
return countClosed;
}
}
そして宣言された豆:
<bean id="ApplicationContextObserver" class="greenpages.ApplicationContextObserver" />
<osgi:service ref="ApplicationContextObserver" interface="org.springframework.osgi.context.event.OsgiBundleApplicationContextListener" />
最悪の場合、このエラーがまったく表示されないことがありますが、コンテナーに別のバンドルをデプロイすると、リスナーが呼び出されません。
何がうまくいかないのですか (可能であれば、Virgo Container、SpringDM、およびこのリスナーを使用して実行中の例を添付できますか)?