Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How to auto-startup a bundle in server-side?
How to auto-startup a bundle in server-side? [message #69693] Wed, 12 July 2006 17:33 Go to next message
Eclipse UserFriend
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 #69775 is a reply to message #69693] Thu, 13 July 2006 03:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Hi Luan,

There's no equivalent to the org.eclipse.ui.startup extension point for
server-side eclipse. If you want to it should be easy enough to write a
similar extension point yourself.

That said, probably the easiest way for static environments is to add
yourbundle@start to the osgi.bundles in config.ini
-Simon
Re: How to auto-startup a bundle in server-side? [message #69793 is a reply to message #69775] Thu, 13 July 2006 18:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ltran.serena.com

Hi Simon,

I really appricate your help and response. However, I have already tried
it that way and somehow it didn't work. Below is how I experienced it:

1. Created a simple plugin "my.test". The generated manifest file had the
following content:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test Plug-in
Bundle-SymbolicName: my.test
Bundle-Version: 1.0.0
Bundle-Activator: my.test.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime
Eclipse-LazyStart: true

2. Inserted a println() debug statement in the start() method of the
bundle activator.

3. Edited config.ini, appended "my.test@start" to osgi.bundles.

4. Restart the server. The start method had never been called at startup
(no debug statement printed out).

I tried to remove the Eclipse-LazyStart property from the manifest and got
the same result. Do you see anything wrong in my test? Thanks in advance.

Luan
Re: How to auto-startup a bundle in server-side? [message #69805 is a reply to message #69793] Thu, 13 July 2006 20:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.kaegi.cognos.com

Hi Luan,

I see a dependency on "org.eclipse.core.runtime" so my guess is that your
bundle is not resolving.
If you really need the core.runtime you'll need to ensure that all of its
dependencies are present e.g.
org.eclipse.osgi
org.eclipse.equinox.common
org.eclipse.core.jobs
org.eclipse.equinox.registry
org.eclipse.equinox.preferences
org.eclipse.core.contenttype
org.eclipse.core.runtime.compatibility.auth

You can verify that your component is resolved with the "console" and the
"ss" command.
--
That said I suspect you don't probably don't need it (at least at this
point) and might be better off selectively importing the java packages with
"Import-Package" instead of using "Require-Bundle"

e.g. something like...
Import-Package: org.eclipse.osgi.framework.log,
org.eclipse.osgi.util,
org.osgi.framework,
etc.

-Simon

"Luan Tran" <ltran@serena.com> wrote in message
news:cc62a74856d3abd37035971250e0c53d$1@www.eclipse.org...
> Hi Simon,
>
> I really appricate your help and response. However, I have already tried
> it that way and somehow it didn't work. Below is how I experienced it:
>
> 1. Created a simple plugin "my.test". The generated manifest file had the
> following content:
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Test Plug-in
> Bundle-SymbolicName: my.test
> Bundle-Version: 1.0.0
> Bundle-Activator: my.test.Activator
> Bundle-Localization: plugin
> Require-Bundle: org.eclipse.core.runtime
> Eclipse-LazyStart: true
>
> 2. Inserted a println() debug statement in the start() method of the
> bundle activator.
> 3. Edited config.ini, appended "my.test@start" to osgi.bundles.
>
> 4. Restart the server. The start method had never been called at startup
> (no debug statement printed out).
>
> I tried to remove the Eclipse-LazyStart property from the manifest and got
> the same result. Do you see anything wrong in my test? Thanks in
> advance.
>
> Luan
>
Re: How to auto-startup a bundle in server-side? [message #70016 is a reply to message #69805] Thu, 13 July 2006 23:18 Go to previous messageGo to next message
Eclipse UserFriend
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] Fri, 14 July 2006 03:01 Go to previous messageGo to next message
Pascal Rapicault is currently offline Pascal RapicaultFriend
Messages: 333
Registered: July 2009
Location: Ottawa
Senior Member
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 20:58 Go to previous message
Eclipse UserFriend
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
Previous Topic:Difference between Bundles and Management Bundles
Next Topic:Debugging in OSGI -- not all bundles starting
Goto Forum:
  


Current Time: Thu Apr 18 12:49:12 GMT 2024

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

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

Back to the top