Hi Forrest,
As far as I am aware (mandatory) service registrations cannot be used
from inside the same blueprint. The reason for this is that the
blueprint container waits for all (mandatory) service references to be
satisfied before it starts creating components. See section 121.3.2.1
for the details. So if serviceref1 is not satisfied by some other
bundle it should never get satisfied since creating serverbean1 and
exporting it as a service waits for serviceref1 to be satisfied.
If you really wanted to use a service, I suppose you could make the
service reference availability=optional, but I can't see why you
wouldn't just inject serverbean1 directly into callservicebean.
Regards,
Valentin
On 15 Dec 2009, at 14:16, Forrest Xia wrote:
Hi blueprint experts,
Can I make a blueprint definition like this?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="serverbean1"
class="org.apache.aries.samples.blueprint.complex.server.ServerBean1"
init-method="doSomething">
<argument value="ServerBean1's Name"></argument>
</bean>
<service ref="serverbean1"
interface
="org.apache.aries.samples.blueprint.complex.api.ServiceInterface1"/>
<reference id="serviceref1"
interface
="org.apache.aries.samples.blueprint.complex.api.ServiceInterface1"/>
<bean id="callservicebean"
class="org.apache.aries.samples.blueprint.complex.Bean6"
init-method="startUp">
<argument ref="serviceref1"/>
</bean>
</blueprint>
ServerBean1 and Bean6 are in the same blueprint bundle. I find this
bundle
cannot be started, the blueprint state shows failure.
Any comments?
Thanks!
Forrest