Hi Tom,
I'm running equinox using the generic OSGi Framework launcher in the
IDE but in production I'm using the default equinox launcher.
I think I understood what is happen now. When I set the bundle's
startlevel to 1 I got the start event.
So, is there any way to ensure that a bundle will be started after
all other bundles be already started other than set this startlevel
to a high value?
Is there anyway to know what is the latest startlevel and then
listen for STARTLEVEL_CHANGED ?
thanks again,
Cristiano
On 06/07/2016 09:41, Thomas Watson
wrote:
It depends on the
launcher you are using.
Here I am going to assume you are using the Equinox launcher
as-is.
The thing about FrameworkEvent.STARTED is that it is only fired
when
the framework has reached its "beginning framework start-level"
during the call to Framework.start(). By default this is
start-level 1.
The Equinox launcher simply uses the default beginning
framework
start level of 1 when it starts the framework. Once the
framework
has been started the Framework.STARTED event is fired. Then the
Equinox
launcher proceeds to set the framework start-level to its final
start-level
(this defaults to 4 for the equinox launcher). That ends up
activating
all the other bundles installed in the system when their
start-level is
met. The Equinox launcher could have decided to set the
configuration
of the beginning start-level to the final one of 4 instead of
starting
the framework using the default beginning framework start-level
Your bundle is activated at
start-level
3, this will be well after the Framework.STARTED event was
fired. Similarly
the STOPPED events are not fired until the framework start-level
has reached
zero. At that time your bundle will have already been
de-activated.
When a bundle is de-activated all of its left-over listeners
are
flushed from the system so the framework does not hold onto
stale objects
and create a leak. The only way to see one of the STOPPED
events
is to implement your own launcher which uses the Framework
launching API.
The Equinox launcher could have
decided
to set the configuration of the beginning start-level to the
final one
of 4 instead of starting the framework using the default
beginning framework
start-level of 1 and then later setting the final framework
start-level
to 4. That would have allowed your bundle to sometimes see teh
STARTED
event. But even then there are times you would not see the
event.
For example, if the bundle was installed and started after the
framework
was already started.
Tom
From:
Cristiano Gavião
<cvgaviao@xxxxxxxxx>
To:
Equinox development
mailing list <equinox-dev@xxxxxxxxxxx>
Date:
07/06/2016 06:15 AM
Subject:
[equinox-dev]
receiving a FrameworkEvent.STARTED event?
Sent by:
equinox-dev-bounces@xxxxxxxxxxx
Hello all,
I'm facing a problem and would like to ask for some information.
I have a bundle whose activator is registering a
FrameworkListener inside
the start() method. This bundle is set to start at level 3.
frameworkListener = new FrameworkListener() {
public
void frameworkEvent(FrameworkEvent event) {
if (event.getType() == FrameworkEvent.STARTED) {
try {
initiateProcess();
} catch (Exception e) {
logger.error("Failure occurred while executing "
+ "initial process.");
}
}
}
pBundleContext.addFrameworkListener(frameworkListener);
When executing that bundle with a OSGi Framework launcher then
the unique
event being captured is STARTLEVEL_CHANGED. I can't find a way
to it to
also receive a FrameworkEvent.STARTED.
And I'm not also receiving the FrameworkEvent.STOP after type a
close command
and leave the session.
Please, could someone explain me what am I missing here?
thanks,
Cristiano_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or
unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/equinox-dev
|