Hi Peter, Peter schrieb: > Hi I have a small problem. > > I want to use declarative services for my app. And so far everything is > well. > But unfortunately my declared component needs to register to the Http > service > of OSGi, so to be clean I would like to unregister it when my service > gets undeployed. > > Is there any way my service gets a callback when it is undeployed ?
If you use declarative services to manage your component, you may implement two lifecycle methods in your component: // called when the component is activated (aka started) protected void activate(ComponentContext context); // called when the component is deactivated (aka stopped) protected void deactivate(ComponentContext context); Depending on how you inject the HttpService to you component (I assume your component is a Servlet, right ?) you may register the component with the HttpService upon activate and unregister upon deactivate. For an example, you might want to look at the OsgiManager servlet [1] of the Felix Web Console. Hope this helps. Regards Felix [1] http://svn.apache.org/repos/asf/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java > > > Thanks in advance > > > Peter > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

