I'm facing a case where the UI framework is sending a destroy request when
a page is destroyed and I want to use that to also deactivate the
component, so that its "host" can then automatically get deactivated and so
on so forth as needed.
As shown below I tried to use disableComponent. That results in some errors
as it runs under [SCR Component Actor] thread that is not session aware and
also looking at the stack trace it seems to be deactivating the full user
session, which is not what I'm expecting.
So am I deactivating correctly here, how can I make sure this runs in a
session aware thread (as I don't control here this separate thread
launch/run) and is there a utility to better understand service instance
dependencies that would allow tracking the impact of a deactivation.
Cheers,
Alain
Here's the case:
@Component(service = ViewpointsViewModeTabViewModel.class, scope =
ServiceScope.PROTOTYPE)
public class ViewpointsViewModeTabViewModel extends
ViewModeTabboxItemViewModel {
...
@Reference(scope = ReferenceScope.PROTOTYPE_REQUIRED)
private BaViewPointsViewModel baViewPointsViewModel;
...
}
and
@Component(service = BaViewPointsViewModel.class,
scope=ServiceScope.PROTOTYPE)
@Init(superclass = true)
public final class BaViewPointsViewModel extends
ViewPointsViewModel<ViewpointTabboxItemViewModel>
implements ZkViewModel, BaItem, MasterDetailTopMenuListener {
...
@Activate
private void activate(ComponentContext context, Map<String, Object>
properties) {
this.context = context;
pid = (String)properties.get(ComponentConstants.COMPONENT_NAME);
log.trace("Activating {}/{}", getClass(),
System.identityHashCode(this)); //$NON-NLS-1$
initTabs();
}
@Deactivate
private void deactivate() {
log.trace("Deactivating {}/{}", getClass(),
System.identityHashCode(this)); //$NON-NLS-1$
super.zkDestroy();
ungetServices();
clearTabs();
}
@Override
@Destroy
public void zkDestroy() {
log.trace("Destroying {}/{}", getClass(), System.identityHashCode(this));
//$NON-NLS-1$
deactivate();
context.disableComponent(pid); //attempt to manually deactivate itself.
}
}
Alain Picard
Chief Strategy Officer
Castor Technologies Inc
o:514-360-7208
m:813-787-3424
[email protected]
www.castortech.com
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev