How to auto-startup a bundle in server-side? [message #69693] |
Wed, 12 July 2006 13:33  |
Eclipse User |
|
|
|
Originally posted by: ltran.serena.com
As we are working on an application in the server-side, we need to have a
way to start up a bundle at launch time (for application's initialization).
I studied Eclipse and found out a way to do that in RCP, which is to extend
the org.eclipse.ui.startup extension point. Do we have the same capability
in the server-side framework ? Thanks a lot.
Luan.
|
|
|
|
|
|
Re: How to auto-startup a bundle in server-side? [message #70016 is a reply to message #69805] |
Thu, 13 July 2006 19:18   |
Eclipse User |
|
|
|
Originally posted by: ltran.serena.com
Hi Simon,
Many thanks for your quick reply.
The dependency on org.eclipse.core.runtime was generated by Eclipse and it
had to be there for the resolvation of all the classes like
BundleContext... in the Bundle Activator (I took it out and saw
compilation errors).
Yes, I ran the ss command and saw that my.test plugin was resolved.
Trying to make it more interesting, I added a test servlet just to print
out "Hello World". The manifest file follows:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test Plug-in
Bundle-SymbolicName: my.test;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: my.test.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.equinox.http.registry,
org.eclipse.core.runtime
Eclipse-LazyStart: true
Import-Package: javax.servlet;resolution:=optional,
javax.servlet.http;resolution:=optional,
javax.servlet.jsp;resolution:=optional
and the plugin.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
id="test"
name="test"
point="org.eclipse.equinox.http.registry.servlets">
<servlet
alias="/test/mytest"
class="my.test.MyTestServlet">
</servlet>
</extension>
</plugin>
I started up the server, and didn't see the debug message printed out.
However, only when I tried to access the servlet, the bundle was loaded
and the debug message was printed out from the bundle activator start()
method.
If I removed the Eclipse-LazyStart properties (above), then the start()
method would never be triggered, even after I successfully access the test
servlet.
I kind of wonder if osgi.bundles in config.ini is just for OSGI BUNDLES'
configuration (and not for every plugin). Again, thanks for any further
inputs.
Luan.
|
|
|
Re: How to auto-startup a bundle in server-side? [message #70037 is a reply to message #70016] |
Thu, 13 July 2006 23:01   |
Eclipse User |
|
|
|
osgi.bundles works for any bundle / plugin. For example eclipse itself ships
with the following value:
org.eclipse.equinox.common@2:start, org.eclipse.update.configurator@3:start,
org.eclipse.core.runtime@start
The lazy start property and the value for osgi.bundles are orthogonal. The
lazy start will automatically start the bundle the first time a class or
resource is loaded from the bundle. The osgi.bundles just tell the fwk to
automatically start the marked bundle.
Make sure you do not have a typo in the bundle name in the osgi,bundles
value and that the file name on the disk matches the symbolic name (this is
a current limitation of this setup). You may also want to pick a start level
for your bundle.
HTH,
PaScaL
"Luan Tran" <ltran@serena.com> wrote in message
news:5222c560e3bf8e10e92fea3ddf529894$1@www.eclipse.org...
> Hi Simon,
>
> Many thanks for your quick reply.
>
> The dependency on org.eclipse.core.runtime was generated by Eclipse and it
> had to be there for the resolvation of all the classes like
> BundleContext... in the Bundle Activator (I took it out and saw
> compilation errors).
>
> Yes, I ran the ss command and saw that my.test plugin was resolved.
> Trying to make it more interesting, I added a test servlet just to print
> out "Hello World". The manifest file follows:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Test Plug-in
> Bundle-SymbolicName: my.test;singleton:=true
> Bundle-Version: 1.0.0
> Bundle-Activator: my.test.Activator
> Bundle-Localization: plugin
> Require-Bundle: org.eclipse.equinox.http.registry,
> org.eclipse.core.runtime
> Eclipse-LazyStart: true
> Import-Package: javax.servlet;resolution:=optional,
> javax.servlet.http;resolution:=optional,
> javax.servlet.jsp;resolution:=optional
>
> and the plugin.xml file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.2"?>
> <plugin>
> <extension
> id="test"
> name="test"
> point="org.eclipse.equinox.http.registry.servlets">
> <servlet
> alias="/test/mytest"
> class="my.test.MyTestServlet">
> </servlet>
> </extension>
>
> </plugin>
>
> I started up the server, and didn't see the debug message printed out.
> However, only when I tried to access the servlet, the bundle was loaded
> and the debug message was printed out from the bundle activator start()
> method.
>
> If I removed the Eclipse-LazyStart properties (above), then the start()
> method would never be triggered, even after I successfully access the test
> servlet.
>
> I kind of wonder if osgi.bundles in config.ini is just for OSGI BUNDLES'
> configuration (and not for every plugin). Again, thanks for any further
> inputs.
>
> Luan.
>
|
|
|
Re: How to auto-startup a bundle in server-side? [message #70181 is a reply to message #70037] |
Mon, 17 July 2006 16:58  |
Eclipse User |
|
|
|
Originally posted by: ltran.serena.com
Thanks all,
I was able to auto-start my bundle. I debugged a bit into
org.eclispe.osgi bundle and found out my error. The trick was that the
name of the plugin jar file should be
<Bundle-SymbolicName>_<Bundle-Version>.jar. Since mine hadn't had the
<Bundle-Version> in the jar file name, the bundle couldn't be loaded
successfully. Once again, thanks for all the help :)
Luan
|
|
|
Powered by
FUDForum. Page generated in 0.07380 seconds