Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » how to get bundle context in the servlet registered by the org.eclipse.equinox.http.registry
how to get bundle context in the servlet registered by the org.eclipse.equinox.http.registry [message #101414] Sun, 11 November 2007 07:47 Go to next message
Eclipse UserFriend
Originally posted by: bob.yang.unison.net.cn

hi,

I am using the org.eclipse.equinox.http.registry bundle to register a
servlet by specify the extension
'org.eclipse.equinox.http.registry.servlets', I want to use the OSGI
services in the servlet so I need a BundleContext object reference, how
can I get it?

Below is the exertion of the plugin.xml:

<extension
point="org.eclipse.equinox.http.registry.servlets">
<servlet
alias="/hello"
class="com.example.http.application.HelloServlet">
<init-param
name="message"
value="some values">
</init-param>
</servlet>
</extension>

Thanks!

Bob Yang
Re: how to get bundle context in the servlet registered by the org.eclipse.equinox.http.registry [message #101446 is a reply to message #101414] Sun, 11 November 2007 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Hi Bob,

There are a couple of approaches:
1) You can save the BundleContext in a static variable in your Bundle
Activator. If you take this approach make sure to synchronize the setter and
getter.
2) Instead of putting the Servlet class in the extension put an
"IExecutableExtensionFacory" that will generate a Servlet instance with the
BundleContext pre-injected. A nice variation on this is to inject the actual
services you'll need instead of the BundleContext.

If you're starting to do anything OSGi specific in your Servlet you might
also consider directly using the Http Service instead of doing youre
registration declaratively via http.registry's extensions.

HTH
-Simon





"Bob Yang" <bob.yang@unison.net.cn> wrote in message
news:fh6bm9$c4l$1@build.eclipse.org...
> hi,
>
> I am using the org.eclipse.equinox.http.registry bundle to register a
> servlet by specify the extension
> 'org.eclipse.equinox.http.registry.servlets', I want to use the OSGI
> services in the servlet so I need a BundleContext object reference, how
> can I get it?
>
> Below is the exertion of the plugin.xml:
>
> <extension
> point="org.eclipse.equinox.http.registry.servlets">
> <servlet
> alias="/hello"
> class="com.example.http.application.HelloServlet">
> <init-param
> name="message"
> value="some values">
> </init-param>
> </servlet>
> </extension>
>
> Thanks!
>
> Bob Yang
Re: how to get bundle context in the servlet registered by the org.eclipse.equinox.http.registry [message #101455 is a reply to message #101414] Mon, 12 November 2007 01:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lifesting.gmail.com

Bob Yang wrote:
> hi,
>
> I am using the org.eclipse.equinox.http.registry bundle to register a
> servlet by specify the extension
> 'org.eclipse.equinox.http.registry.servlets', I want to use the OSGI
> services in the servlet so I need a BundleContext object reference, how
> can I get it?
>
> Below is the exertion of the plugin.xml:
>
> <extension
> point="org.eclipse.equinox.http.registry.servlets">
> <servlet
> alias="/hello"
> class="com.example.http.application.HelloServlet">
> <init-param
> name="message"
> value="some values">
> </init-param>
> </servlet>
> </extension>
>
> Thanks!
>
> Bob Yang
You can use Spring-OSGi to inject any service into the target Servlet,
that means using Spring Declaring instead of Eclipse extension.
Re: how to get bundle context in the servlet registered by the org.eclipse.equinox.http.registry [message #1782794 is a reply to message #101455] Thu, 01 March 2018 14:27 Go to previous message
Selim Dincer is currently offline Selim DincerFriend
Messages: 12
Registered: November 2017
Junior Member
sorry, wrong thread

[Updated on: Thu, 01 March 2018 14:28]

Report message to a moderator

Previous Topic:Error when launching marketplace
Next Topic:Problem importing mysql JDBC driver
Goto Forum:
  


Current Time: Thu Jun 21 18:30:35 GMT 2018

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

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

Back to the top