You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Pat Warren <pw...@gmail.com> on 2015/03/29 23:18:24 UTC
Karaf 3.0.3: Blueprint: Service Registration Listener related
question
Hi,
I implemented a Service and leveraged declarative registration using
Blueprint (via blueprint.xml).
...
<service id="aService"
interface="AService"
ref="aServiceImpl">
<registration-listener ref="activator" registration-method="register"
unregistration-method="unregister"/>
</service>
...
The service deploys fine and if I do service:list in the Karaf command
prompt I see the service successfully installed and started. However, the
activator's registration and unregistration callback methods are not getting
invoked.
Clearly, I am not doing something right and would appreciate any insights.
public class Activator implements BundleActivator {
// ... start and stop methods removed for brevity ...
public void register(final AService aServ, final Map properties) {
System.out.println("Register invoked...");
}
public void unregister(final AService aServ, final Map properties) {
System.out.println("Unregister called...");
}
}
There isnt anything in the log to indicate any attempts to call register or
unregister, i.e., no failures on trying to call these methods. It appears
that no callback is not happening
Thanks for any help.
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-3-Blueprint-Service-Registration-Listener-related-question-tp4039368.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.
Re: Karaf 3.0.3: Blueprint: Service Registration Listener related
question
Posted by Pat Warren <pw...@gmail.com>.
Hi Christian,
Thanks for the insights.
The blueprint.xml is as follows:
<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="aSImpl" class="test.ASImpl">
<argument ref="wServ"/>
<argument ref="tServ"/>
</bean>
<bean id="activator" class="test.Activator">
</bean>
<bean id="mypojo" class="test.MyPojo">
</bean>
<reference id="wServ" activation="eager" availability="mandatory"
interface="test.WServ">
</reference>
<reference id="tServ" availability="mandatory" activation="eager"
interface="test.TServ">
</reference>
<service id="aService"
interface="test.AServ"
ref="aSImpl">
<registration-listener ref="activator" registration-method="register"
unregistration-method="unregister"/>
</service>
</blueprint>
NOTE: as such mypojo is not used in the above config. Now, if I switch the
ref in <registration-listener> from "activator" to "mypojo" there is still
no call back.
NOTE 2: ASImpl implements AServ interface, the service interface
MyPojo is a simple pojo that provides implementation for two methods
register and unregister:
public void register(AServ aServ, Map props) {
System.out.println("register called");
}
public void unregister(AServ aServ, Map props) {
System.out.println("unregister called");
}
Thanks for any insights.
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-3-Blueprint-Service-Registration-Listener-related-question-tp4039368p4039386.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.
Re: Karaf 3.0.3: Blueprint: Service Registration Listener related
question
Posted by Christian Schneider <ch...@die-schneider.net>.
You should use a pojo for the callbacks.
If you mix Activator and blueprint you will end up with two instances of
the Activator. One created by blueprint and one by the OSGi framework.
Can you post your full blueprint.xml and ideally your project? Maybe you
got a small error somewhere?
Christian
On 30.03.2015 14:55, Pat Warren wrote:
> Hi Achim,
>
> Thank you for the response.
>
> Apologies, but I am not sure I fully understand.
>
> The Service is getting registered by the Blueprint-Extender as you point
> out. I am not registering the service in the Activator. The Activator's
> start method is getting called as normal.
>
> What is not happening is that the registration-listener is not getting
> called back post service registration. The callback methods for the
> registration callbacks happen to be on the Activator, but I also tried using
> a POJO's methods for the callback with no success.
>
> Can you kindly clarify for my understanding how can we get a call back post
> registration?
>
> Thanks for any help.
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-3-Blueprint-Service-Registration-Listener-related-question-tp4039368p4039382.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
Re: Karaf 3.0.3: Blueprint: Service Registration Listener related
question
Posted by Pat Warren <pw...@gmail.com>.
Hi Achim,
Thank you for the response.
Apologies, but I am not sure I fully understand.
The Service is getting registered by the Blueprint-Extender as you point
out. I am not registering the service in the Activator. The Activator's
start method is getting called as normal.
What is not happening is that the registration-listener is not getting
called back post service registration. The callback methods for the
registration callbacks happen to be on the Activator, but I also tried using
a POJO's methods for the callback with no success.
Can you kindly clarify for my understanding how can we get a call back post
registration?
Thanks for any help.
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-3-0-3-Blueprint-Service-Registration-Listener-related-question-tp4039368p4039382.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.
Re: Karaf 3.0.3: Blueprint: Service Registration Listener related question
Posted by Achim Nierbeck <bc...@googlemail.com>.
Your mixing two different approaches here.
Either register your services by means of an Activator or by using the
Blueprint-Extender.
As you're using a blueprint.xml the blueprint-Extender automatically kicks
in and starts the bundle for you, so no need to use the Activator any
longer and therefore the Activator isn't called.
regards, Achim
2015-03-29 23:18 GMT+02:00 Pat Warren <pw...@gmail.com>:
> Hi,
>
> I implemented a Service and leveraged declarative registration using
> Blueprint (via blueprint.xml).
>
> ...
> <service id="aService"
> interface="AService"
> ref="aServiceImpl">
> <registration-listener ref="activator"
> registration-method="register"
> unregistration-method="unregister"/>
> </service>
> ...
> The service deploys fine and if I do service:list in the Karaf command
> prompt I see the service successfully installed and started. However, the
> activator's registration and unregistration callback methods are not
> getting
> invoked.
>
> Clearly, I am not doing something right and would appreciate any insights.
>
> public class Activator implements BundleActivator {
>
> // ... start and stop methods removed for brevity ...
>
> public void register(final AService aServ, final Map properties) {
> System.out.println("Register invoked...");
> }
>
> public void unregister(final AService aServ, final Map properties)
> {
> System.out.println("Unregister called...");
> }
> }
>
> There isnt anything in the log to indicate any attempts to call register or
> unregister, i.e., no failures on trying to call these methods. It appears
> that no callback is not happening
>
> Thanks for any help.
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Karaf-3-0-3-Blueprint-Service-Registration-Listener-related-question-tp4039368.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
Software Architect / Project Manager / Scrum Master