OSGI Blueprint入门之七

阅读更多
    Blueprint既然是DI规范,自然在注入方面有很多的需求。在前几篇中,我们已接触了服务引用的注入:

 
 



    上例中,reference节点定义了对一个OSGI服务的引用,然后在bean节点内用property子节点将该服务引用注入bean中,注入是blueprint通过bean的setCoder(com.ponder.ICoder)这个setter方法实现的。

注入基础类型的常量:

 
 



    上例将19.99这个值注入bean中,用的是setPrice这个setter方法,那么它注入的是数值19.99还是字符串“19.99”呢?这个就要看setter方法的参数类型了,这个你懂的... ...。

注入非基础类型的常量:




true
 


823899238




bean的注入:








 


集合的注入:





  hello
  world
  !





  hello
  world
  !




  hello
  world
  !





properties的注入:




  hello
  


 


MAP的注入:



  
  
  
  
  
  
   
  
    
  
  
  92873873242323
  
  
  
  92873873242323
  
   
   
        2323
        
            
             hello
             world
             !
           
        
   





Blueprint运行时环境上下文的注入:











你可能感兴趣的:(osgi,bean,blueprint,properties,map)