2013-11-09 134 views
1

我想使用Event Admin Handlers使用Apache Felix iPOJO事件管理處理程序

我試圖運行下面的代碼:

import org.apache.felix.ipojo.handlers.event.Publishes; 
import org.apache.felix.ipojo.handlers.event.Subscriber; 
import org.apache.felix.ipojo.handlers.event.publisher.Publisher; 
... 
@Component(immediate = true, publicFactory = false) 
@Provides(specifications = {Test.class}) 
@Instantiate 
public class Test { 
... 
    @Publishes(name = "myPublisher", topics = "foo") 
    private Publisher m_publisher; 
... 
    @Subscriber(name = "mySubscriber", topics = "foo") 
    public void receive(Event pEvent) { 
    ... 
    } 
} 

但有錯誤:

! instances 
... 
Instance test.Test-0 -> invalid 
... 

! instance test.Test-0 
gogo: NullPointerException: null 

據我瞭解,不能得到Publisher組件的實例。我有活動的「Apache Felix iPOJO事件管理處理程序(1.8.0)」包。

用途:

  • 阿帕奇菲利克斯4.2.1
  • org.apache.felix.ipojo.annotations(1.11.0)
  • org.apache.felix.ipojo.api(1.11.0 )
  • org.apache.felix.ipojo.handler.eventadmin(1.8.0)

有什麼不對?謝謝。


這是捆綁列表:

! lb 
START LEVEL 1 
    ID|State  |Level|Name 
    0|Active  | 0|System Bundle (4.2.1) 
    1|Active  | 1|Commons Codec (1.8.0) 
    4|Active  | 1|Commons IO (2.4.0) 
    5|Active  | 1|Commons Lang (2.6.0) 
    6|Active  | 1|Commons Lang (3.1.0) 
    7|Active  | 1|jcl-over-slf4j (1.7.5) 
    10|Active  | 1|Apache Felix Bundle Repository (1.6.6) 
    12|Active  | 1|Apache Felix Gogo Command (0.12.0) 
    13|Active  | 1|Apache Felix Gogo Runtime (0.10.0) 
    14|Active  | 1|Apache Felix Gogo Shell (0.10.0) 
    15|Active  | 1|Apache Felix iPOJO (1.11.0) 
    16|Active  | 1|Apache Felix iPOJO API (1.11.0) 
    17|Active  | 1|Apache Felix iPOJO Gogo Command (1.11.0) 
    18|Active  | 1|Apache Felix iPOJO Event Admin Handler (1.8.0) 
    19|Active  | 1|osgi.cmpn (4.2.0.200908310645) 
    20|Active  | 1|slf4j-api (1.7.5) 

回答