|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
DS and bundle stop/startI came across an interesting problem today involving DS and expicitly starting/stopping bundles. After chatting with Tom he suggested I raise it here for general awareness and to discuss whether the behaviour makes sense. In various places in p2 today we explicitly start bundles for various reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this purpose. We are starting to use DS in p2 today, and we have a few places where a bundle acquires a service that it registered via DS in its own BundleActivator.start method. It turns out that DS only processes/starts service components synchronously for bundles that are lazy started. If you start a bundle explicitly the DS processing occurs asynchronously, and as a result the services provided via DS are not available at the time the bundle starts. The result is subtlely different bundle behaviour (or outright failures), if a bundle is started explicitly via Bundle#start versus implicitly via lazy activation: 1) Lazy start case: a) bundle's service component is processed and services provided by the component are registered by DS b) bundle activator starts, and can use services registered in 1a) 2) Activation via Bundle.start(Bundle.START_TRANSIENT): a) bundle's activator starts, and services are not yet available b) bundle's service component is processed and services provided by the component are registered by DS It turns out there is a coding pattern that can be used to make the explicit start case match the lazy start case: final Bundle bundle = ...;//get some bundle bundle.start(Bundle.START_ACTIVATION_POLICY); bundle.start(Bundle.START_TRANSIENT); The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process the bundle and register its component services, but does not start the bundle. The second call to start with Bundle.START_TRANSIENT actually starts the bundle. The moral of the story seems to be that we need to use this "double start" coding pattern anywhere we are starting bundles, because those bundles might be using DS and relying on the activation order. Or, perhaps someone has a suggestion for changes that can be made to the framework or DS so that these cases behave consistently... John _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startWhy doesn't DS just asynchronously process
bundles which are lazy activated (not lazy started which is an incorrect
term)? Then you have the same behavior (async processing) regardless of
whether the bundle is lazily or eagerly activated.
--
I came across an interesting problem today involving DS and expicitly starting/stopping bundles. After chatting with Tom he suggested I raise it here for general awareness and to discuss whether the behaviour makes sense. In various places in p2 today we explicitly start bundles for various reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this purpose. We are starting to use DS in p2 today, and we have a few places where a bundle acquires a service that it registered via DS in its own BundleActivator.start method. It turns out that DS only processes/starts service components synchronously for bundles that are lazy started. If you start a bundle explicitly the DS processing occurs asynchronously, and as a result the services provided via DS are not available at the time the bundle starts. The result is subtlely different bundle behaviour (or outright failures), if a bundle is started explicitly via Bundle#start versus implicitly via lazy activation: 1) Lazy start case: a) bundle's service component is processed and services provided by the component are registered by DS b) bundle activator starts, and can use services registered in 1a) 2) Activation via Bundle.start(Bundle.START_TRANSIENT): a) bundle's activator starts, and services are not yet available b) bundle's service component is processed and services provided by the component are registered by DS It turns out there is a coding pattern that can be used to make the explicit start case match the lazy start case: final Bundle bundle = ...;//get some bundle bundle.start(Bundle.START_ACTIVATION_POLICY); bundle.start(Bundle.START_TRANSIENT); The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process the bundle and register its component services, but does not start the bundle. The second call to start with Bundle.START_TRANSIENT actually starts the bundle. The moral of the story seems to be that we need to use this "double start" coding pattern anywhere we are starting bundles, because those bundles might be using DS and relying on the activation order. Or, perhaps someone has a suggestion for changes that can be made to the framework or DS so that these cases behave consistently... John_______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startHmmm, I thought the original design of lazy activation and DS components was to synchronously make service components available in the service registry as long as they are immediately resolvable. The reason for this was to ensure these services were synchronously available before we entered the Eclipse application entry point.
Why doesn't DS just asynchronously process bundles which are lazy activated (not lazy started which is an incorrect term)? Then you have the same behavior (async processing) regardless of whether the bundle is lazily or eagerly activated. --
I came across an interesting problem today involving DS and expicitly starting/stopping bundles. After chatting with Tom he suggested I raise it here for general awareness and to discuss whether the behaviour makes sense. In various places in p2 today we explicitly start bundles for various reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this purpose. We are starting to use DS in p2 today, and we have a few places where a bundle acquires a service that it registered via DS in its own BundleActivator.start method. It turns out that DS only processes/starts service components synchronously for bundles that are lazy started. If you start a bundle explicitly the DS processing occurs asynchronously, and as a result the services provided via DS are not available at the time the bundle starts. The result is subtlely different bundle behaviour (or outright failures), if a bundle is started explicitly via Bundle#start versus implicitly via lazy activation: 1) Lazy start case: a) bundle's service component is processed and services provided by the component are registered by DS b) bundle activator starts, and can use services registered in 1a) 2) Activation via Bundle.start(Bundle.START_TRANSIENT): a) bundle's activator starts, and services are not yet available b) bundle's service component is processed and services provided by the component are registered by DS It turns out there is a coding pattern that can be used to make the explicit start case match the lazy start case: final Bundle bundle = ...;//get some bundle bundle.start(Bundle.START_ACTIVATION_POLICY); bundle.start(Bundle.START_TRANSIENT); The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process the bundle and register its component services, but does not start the bundle. The second call to start with Bundle.START_TRANSIENT actually starts the bundle. The moral of the story seems to be that we need to use this "double start" coding pattern anywhere we are starting bundles, because those bundles might be using DS and relying on the activation order. Or, perhaps someone has a suggestion for changes that can be made to the framework or DS so that these cases behave consistently... John_______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startYes. No bundle should expect another bundle
to register some service during it activation. A bundle should depend upon
services using DS or ServiceTracker (or even ServiceListener).
--
Hmmm, I thought the original design of lazy activation and DS components was to synchronously make service components available in the service registry as long as they are immediately resolvable. The reason for this was to ensure these services were synchronously available before we entered the Eclipse application entry point. This points out a deficiency in the way most of Eclipse handles dynamic registration of services. If every eclipse bundle was written from day one to handle dynamic registration and unregistration of services then it would not matter that the service registration happened asynchronously. Tom
Why doesn't DS just asynchronously process bundles which are lazy activated (not lazy started which is an incorrect term)? Then you have the same behavior (async processing) regardless of whether the bundle is lazily or eagerly activated. --
I came across an interesting problem today involving DS and expicitly starting/stopping bundles. After chatting with Tom he suggested I raise it here for general awareness and to discuss whether the behaviour makes sense. In various places in p2 today we explicitly start bundles for various reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this purpose. We are starting to use DS in p2 today, and we have a few places where a bundle acquires a service that it registered via DS in its own BundleActivator.start method. It turns out that DS only processes/starts service components synchronously for bundles that are lazy started. If you start a bundle explicitly the DS processing occurs asynchronously, and as a result the services provided via DS are not available at the time the bundle starts. The result is subtlely different bundle behaviour (or outright failures), if a bundle is started explicitly via Bundle#start versus implicitly via lazy activation: 1) Lazy start case: a) bundle's service component is processed and services provided by the component are registered by DS b) bundle activator starts, and can use services registered in 1a) 2) Activation via Bundle.start(Bundle.START_TRANSIENT): a) bundle's activator starts, and services are not yet available b) bundle's service component is processed and services provided by the component are registered by DS It turns out there is a coding pattern that can be used to make the explicit start case match the lazy start case: final Bundle bundle = ...;//get some bundle bundle.start(Bundle.START_ACTIVATION_POLICY); bundle.start(Bundle.START_TRANSIENT); The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process the bundle and register its component services, but does not start the bundle. The second call to start with Bundle.START_TRANSIENT actually starts the bundle. The moral of the story seems to be that we need to use this "double start" coding pattern anywhere we are starting bundles, because those bundles might be using DS and relying on the activation order. Or, perhaps someone has a suggestion for changes that can be made to the framework or DS so that these cases behave consistently... John_______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startBJ Hargrave wrote: > Why doesn't DS just asynchronously process bundles which are lazy > activated (not lazy started which is an incorrect term)? Then you have > the same behavior (async processing) regardless of whether the bundle is > lazily or eagerly activated. The DS components of activated bundles are processed by DS when it receives BundleEvent.STARTED (for normal activated bundles) or BundleEvent.LAZY_ACTIVATION (for lazy activated bundles). These events are processed in DS by a SynchronousBundleListener. Actually DS processes synchronously the components in both cases. The difference comes with the fact that BundleEvent.STARTED is sent by the framework after the bundle's activator is started. We cannot modify DS to process only BundleEvent.STARTED because in this case lazy activated bundles will not be processed at all. What we can do in DS is to process the DS components of a bundle when DS receives BundleEvent.STARTING event instead of BundleEvent.STARTED. This way DS will process the components before the framework calls the bundle activator's start method and the behavior would be similar to the one when processing lazy activated bundles. However, the DS specification always speaks of DS processing started bundles. So, I am not sure whether it is appropriate to process the DS components of a bundle before it is fully started. Stoyan > -- > > *BJ Hargrave* > Senior Technical Staff Member, IBM > OSGi Fellow and CTO of the _OSGi Alliance_ <http://www.osgi.org/>_ > __hargrave@... <mailto:hargrave@...> > > office: +1 386 848 1781 > mobile: +1 386 848 3788 > > > > > From: John Arthorne <John_Arthorne@...> > To: equinox-dev@... > Date: 2009/10/26 14:32 > Subject: [equinox-dev] DS and bundle stop/start > Sent by: equinox-dev-bounces@... > > > ------------------------------------------------------------------------ > > > > > I came across an interesting problem today involving DS and expicitly > starting/stopping bundles. After chatting with Tom he suggested I raise > it here for general awareness and to discuss whether the behaviour makes > sense. > > In various places in p2 today we explicitly start bundles for various > reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this > purpose. We are starting to use DS in p2 today, and we have a few places > where a bundle acquires a service that it registered via DS in its own > BundleActivator.start method. It turns out that DS only processes/starts > service components synchronously for bundles that are lazy started. If > you start a bundle explicitly the DS processing occurs asynchronously, > and as a result the services provided via DS are not available at the > time the bundle starts. The result is subtlely different bundle > behaviour (or outright failures), if a bundle is started explicitly via > Bundle#start versus implicitly via lazy activation: > > 1) Lazy start case: > a) bundle's service component is processed and services provided by the > component are registered by DS > b) bundle activator starts, and can use services registered in 1a) > > 2) Activation via Bundle.start(Bundle.START_TRANSIENT): > a) bundle's activator starts, and services are not yet available > b) bundle's service component is processed and services provided by the > component are registered by DS > > It turns out there is a coding pattern that can be used to make the > explicit start case match the lazy start case: > > *final* Bundle bundle = ...;//get some bundle > bundle.start(Bundle.START_ACTIVATION_POLICY); > bundle.start(Bundle.START_TRANSIENT); > > The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process > the bundle and register its component services, but does not start the > bundle. The second call to start with Bundle.START_TRANSIENT actually > starts the bundle. > > The moral of the story seems to be that we need to use this "double > start" coding pattern anywhere we are starting bundles, because those > bundles might be using DS and relying on the activation order. Or, > perhaps someone has a suggestion for changes that can be made to the > framework or DS so that these cases behave consistently... > > John_______________________________________________ > equinox-dev mailing list > equinox-dev@... > https://dev.eclipse.org/mailman/listinfo/equinox-dev > > > ------------------------------------------------------------------------ > > _______________________________________________ > equinox-dev mailing list > equinox-dev@... > https://dev.eclipse.org/mailman/listinfo/equinox-dev -- --------------------------------------------------------- dipl. eng. Stoyan Boshev . Department manager ProSyst Labs EOOD 1606 Sofia, Bulgaria . 48 Vladajska Str. Tel. +359 2 953 05 88; Fax +359 2 953 26 17 Mobile: +359 88 898 29 17 http://www.prosyst.com . s.boshev@... --------------------------------------------------------- stay in touch with your product --------------------------------------------------------- _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startWhy not have DS hand off processing of
the components to another thread when the LAZY_ACTIVATION event is received?
This will allow the bundle start to complete while the DS processing occurs
async.
I don't think we should change to process on STARTING. This whole discussion seems to point out that we are, perhaps unwisely, blending using DS and BundleActivator where the activators have a dependency on DS having alread processed the bundle. Perhaps what is needed is a form of immediate component that is not activated when DS processed the bundle but is activated when the bundle's STARTED event is fired. This would delay creation of the immediate component until the bundle activation was lazily triggered and allow the immediate component to be injected with any other services of the bundle. This design change seems a much better idea that combining BundleActivators and DS with specific ordering. --
BJ Hargrave wrote: > Why doesn't DS just asynchronously process bundles which are lazy > activated (not lazy started which is an incorrect term)? Then you have > the same behavior (async processing) regardless of whether the bundle is > lazily or eagerly activated. The DS components of activated bundles are processed by DS when it receives BundleEvent.STARTED (for normal activated bundles) or BundleEvent.LAZY_ACTIVATION (for lazy activated bundles). These events are processed in DS by a SynchronousBundleListener. Actually DS processes synchronously the components in both cases. The difference comes with the fact that BundleEvent.STARTED is sent by the framework after the bundle's activator is started. We cannot modify DS to process only BundleEvent.STARTED because in this case lazy activated bundles will not be processed at all. What we can do in DS is to process the DS components of a bundle when DS receives BundleEvent.STARTING event instead of BundleEvent.STARTED. This way DS will process the components before the framework calls the bundle activator's start method and the behavior would be similar to the one when processing lazy activated bundles. However, the DS specification always speaks of DS processing started bundles. So, I am not sure whether it is appropriate to process the DS components of a bundle before it is fully started. Stoyan > -- > > *BJ Hargrave* > Senior Technical Staff Member, IBM > OSGi Fellow and CTO of the _OSGi Alliance_ <http://www.osgi.org/>_ > __hargrave@... <mailto:hargrave@...> > > office: +1 386 848 1781 > mobile: +1 386 848 3788 > > > > > From: John Arthorne <John_Arthorne@...> > To: equinox-dev@... > Date: 2009/10/26 14:32 > Subject: [equinox-dev] DS and bundle stop/start > Sent by: equinox-dev-bounces@... > > > ------------------------------------------------------------------------ > > > > > I came across an interesting problem today involving DS and expicitly > starting/stopping bundles. After chatting with Tom he suggested I raise > it here for general awareness and to discuss whether the behaviour makes > sense. > > In various places in p2 today we explicitly start bundles for various > reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this > purpose. We are starting to use DS in p2 today, and we have a few places > where a bundle acquires a service that it registered via DS in its own > BundleActivator.start method. It turns out that DS only processes/starts > service components synchronously for bundles that are lazy started. If > you start a bundle explicitly the DS processing occurs asynchronously, > and as a result the services provided via DS are not available at the > time the bundle starts. The result is subtlely different bundle > behaviour (or outright failures), if a bundle is started explicitly via > Bundle#start versus implicitly via lazy activation: > > 1) Lazy start case: > a) bundle's service component is processed and services provided by the > component are registered by DS > b) bundle activator starts, and can use services registered in 1a) > > 2) Activation via Bundle.start(Bundle.START_TRANSIENT): > a) bundle's activator starts, and services are not yet available > b) bundle's service component is processed and services provided by the > component are registered by DS > > It turns out there is a coding pattern that can be used to make the > explicit start case match the lazy start case: > > *final* Bundle bundle = ...;//get some bundle > bundle.start(Bundle.START_ACTIVATION_POLICY); > bundle.start(Bundle.START_TRANSIENT); > > The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process > the bundle and register its component services, but does not start the > bundle. The second call to start with Bundle.START_TRANSIENT actually > starts the bundle. > > The moral of the story seems to be that we need to use this "double > start" coding pattern anywhere we are starting bundles, because those > bundles might be using DS and relying on the activation order. Or, > perhaps someone has a suggestion for changes that can be made to the > framework or DS so that these cases behave consistently... > > John_______________________________________________ > equinox-dev mailing list > equinox-dev@... > https://dev.eclipse.org/mailman/listinfo/equinox-dev > > > ------------------------------------------------------------------------ > > _______________________________________________ > equinox-dev mailing list > equinox-dev@... > https://dev.eclipse.org/mailman/listinfo/equinox-dev -- --------------------------------------------------------- dipl. eng. Stoyan Boshev . Department manager ProSyst Labs EOOD 1606 Sofia, Bulgaria . 48 Vladajska Str. Tel. +359 2 953 05 88; Fax +359 2 953 26 17 Mobile: +359 88 898 29 17 http://www.prosyst.com . s.boshev@... --------------------------------------------------------- stay in touch with your product --------------------------------------------------------- _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
|||||||||||||||||||||||||||||||||||||||||||
|
|
Re: DS and bundle stop/startYes, in an ideal world everyone would handle all services completely dynamically. In reality this adds a lot of complexity to application code, so people make simplying assumptions that services provided by bundles they require are already available (since referencing the service interface would cause that bundle to be activated and the service made available). In my particular case the bundle was assuming that a service provided by *itself* was already registered if the bundle was activated. This was true when the bundle was registering that service in its activator, but when that registration was moved to DS it opened a new window in which the bundle is activated but the service is not registered - only in the case where the bundle has been started explicitly via Bundle.start(). This is a subtle difference that is likely to bite people as they switch to DS. John
Yes. No bundle should expect another bundle to register some service during it activation. A bundle should depend upon services using DS or ServiceTracker (or even ServiceListener). --
Hmmm, I thought the original design of lazy activation and DS components was to synchronously make service components available in the service registry as long as they are immediately resolvable. The reason for this was to ensure these services were synchronously available before we entered the Eclipse application entry point. This points out a deficiency in the way most of Eclipse handles dynamic registration of services. If every eclipse bundle was written from day one to handle dynamic registration and unregistration of services then it would not matter that the service registration happened asynchronously. Tom
Why doesn't DS just asynchronously process bundles which are lazy activated (not lazy started which is an incorrect term)? Then you have the same behavior (async processing) regardless of whether the bundle is lazily or eagerly activated. --
I came across an interesting problem today involving DS and expicitly starting/stopping bundles. After chatting with Tom he suggested I raise it here for general awareness and to discuss whether the behaviour makes sense. In various places in p2 today we explicitly start bundles for various reasons. We typically use Bundle.start(Bundle.START_TRANSIENT) for this purpose. We are starting to use DS in p2 today, and we have a few places where a bundle acquires a service that it registered via DS in its own BundleActivator.start method. It turns out that DS only processes/starts service components synchronously for bundles that are lazy started. If you start a bundle explicitly the DS processing occurs asynchronously, and as a result the services provided via DS are not available at the time the bundle starts. The result is subtlely different bundle behaviour (or outright failures), if a bundle is started explicitly via Bundle#start versus implicitly via lazy activation: 1) Lazy start case: a) bundle's service component is processed and services provided by the component are registered by DS b) bundle activator starts, and can use services registered in 1a) 2) Activation via Bundle.start(Bundle.START_TRANSIENT): a) bundle's activator starts, and services are not yet available b) bundle's service component is processed and services provided by the component are registered by DS It turns out there is a coding pattern that can be used to make the explicit start case match the lazy start case: final Bundle bundle = ...;//get some bundle bundle.start(Bundle.START_ACTIVATION_POLICY); bundle.start(Bundle.START_TRANSIENT); The call to start(Bundle.START_ACTIVATION_POLICY) causes DS to process the bundle and register its component services, but does not start the bundle. The second call to start with Bundle.START_TRANSIENT actually starts the bundle. The moral of the story seems to be that we need to use this "double start" coding pattern anywhere we are starting bundles, because those bundles might be using DS and relying on the activation order. Or, perhaps someone has a suggestion for changes that can be made to the framework or DS so that these cases behave consistently... John_______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev _______________________________________________ equinox-dev mailing list equinox-dev@... https://dev.eclipse.org/mailman/listinfo/equinox-dev |
| Free embeddable forum powered by Nabble | Forum Help |