Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How to get ServiceReference from service instance?
How to get ServiceReference from service instance? [message #73326] Tue, 19 September 2006 13:02 Go to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Hi,

I'm trying to rewrite the following example to use declarative services:
http://www.knopflerfish.org/osgi_service_tutorial.html#white

My component metadata looks like:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0"
name="org.eclipse.net4j.http.ServletRegistrar">
<implementation
class="org.eclipse.net4j.http.internal.ServletRegistrarImpl "/>
<reference
name="httpServices"
cardinality="0..n"
policy="dynamic"
bind="addHttpService"
unbind="removeHttpService"/>
<reference
name="servlets"
cardinality="0..n"
policy="dynamic"
bind="addServlet"
unbind="removeServlet"/>
</scr:component>

The signature of the bind method for the servlets reference is:

protected synchronized void addServlet(Servlet servlet)

Now my problem:
I want to register the new servlet with each of the already known HttpService instances.
For this purpose I need access to the ServiceReference of the servlet because this is the
entity that should know the alias property to use in registerServlet().

Any idea how to get this ServiceReference?

Cheers
/Eike
Re: How to get ServiceReference from service instance? [message #73384 is a reply to message #73326] Tue, 19 September 2006 15:51 Go to previous message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Have solved it:

void addServlet(ServiceReference serviceReference)



Eike Stepper schrieb:
> Hi,
>
> I'm trying to rewrite the following example to use declarative services:
> http://www.knopflerfish.org/osgi_service_tutorial.html#white
>
> My component metadata looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0"
> name="org.eclipse.net4j.http.ServletRegistrar">
> <implementation
> class="org.eclipse.net4j.http.internal.ServletRegistrarImpl "/>
> <reference
> name="httpServices"
> cardinality="0..n"
> policy="dynamic"
> bind="addHttpService"
> unbind="removeHttpService"/>
> <reference
> name="servlets"
> cardinality="0..n"
> policy="dynamic"
> bind="addServlet"
> unbind="removeServlet"/>
> </scr:component>
>
> The signature of the bind method for the servlets reference is:
>
> protected synchronized void addServlet(Servlet servlet)
>
> Now my problem:
> I want to register the new servlet with each of the already known
> HttpService instances.
> For this purpose I need access to the ServiceReference of the servlet
> because this is the
> entity that should know the alias property to use in registerServlet().
>
> Any idea how to get this ServiceReference?
>
> Cheers
> /Eike
Previous Topic:Why does ServiceLocator not use OSGi services?
Next Topic:Bundle ActivatorClass not found in tomcat / servlet-bridge
Goto Forum:
  


Current Time: Thu Apr 25 06:43:15 GMT 2024

Powered by FUDForum. Page generated in 0.02997 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top