Blueprint入门之五
reference-list除了可以用setter的方式注入OSGI service外,还可以用listener的方法来实现OSGI service的注入。
<?xml version="1.0" encoding="UTF-8"?><blueprintxmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"default-timeout="0"><bean id="coders" interface="com.ponder.ICoder" availability="optional"><reference-listener bind-method="bindICoder" unbind-method="unbindICoder" ref="coders"></reference-listener></reference-list><!-- bean通过使用引用列表里的服务,对外提供com.ponder.ICodeService服务,这个bean就类似于一个"扩展点" --><service id="CoderService" ref="coders" interface="com.ponder.ICodeService"></service></blueprint>