| Summary: | [PDE Templates] Remove Activator | ||
|---|---|---|---|
| Product: | [Eclipse Project] PDE | Reporter: | Lars Vogel <Lars.Vogel> |
| Component: | UI | Assignee: | PDE-UI-Inbox <pde-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | caniszczyk, curtis.windatt.public, Lars.Vogel, njbartlett, ralf |
| Version: | 3.5 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Lars Vogel
Are DS components that well-established already? Hi Ralf, you don't need DS or the Activator. You can use directly FrameworkUtil. See http://www.vogella.de/blog/2009/12/08/eclipse-rcp-proxy-preference/ for an example. Best regards, Lars Hmm, for tracking services, ok. But you may want to publish services which are coupled to the lifecycle to the bundle or just do some initialization/cleanup work when the bundle starts/stops. An activator is imo fine for this, even if it can be replaced with DS components. Thought you referred to Neil's blog post http://neilbartlett.name/blog/2009/11/30/osgi-its-time-to-ban-bundle-activators/ . Using FrameworkUtil to resolve the bundle seems nice, inserting an example here for further reference: new ServiceTracker( FrameworkUtil.getBundle(this.getClass()).getBundleContext(), ISomeService.class.getName(), null); Is this best practice? Should the PDE templates do it like that? (In reply to comment #3) > Hmm, for tracking services, ok. But you may want to publish services which are > coupled to the lifecycle to the bundle or just do some initialization/cleanup > work when the bundle starts/stops. A DS component is probably better than an Activator in these cases too. For service publishing certainly, because the service is published without needing to create a classloader for the bundle. Even for simple initialization and cleanup, it's an advantage to be able to write this without using the OSGi APIs. Also a DS component will have easier access to configuration and services. But the main reason for not enabling Activator generation by default is simply that the Activator generated by PDE is useless. Most bundles do not need it, and in some cases it gets in the way, so just flip the default. > new ServiceTracker( > FrameworkUtil.getBundle(this.getClass()).getBundleContext(), > ISomeService.class.getName(), null); > > Is this best practice? Should the PDE templates do it like that? I think this is bad practice. The Bundle.getBundleContext() method was never designed to be used as a matter of course by bundles to get their own context; it was designed to make it possible to implement extender bundles like the DS runtime or Spring-DM etc that work across different framework implementations. When a Java security manager is in force, this method may be disabled for use by "normal" bundles. I just realized that the templates do not need an update. The activator is not generated if the flag "Generate Activator" is not set. Marking this bug as duplicate of : https://bugs.eclipse.org/bugs/show_bug.cgi?id=297143 *** This bug has been marked as a duplicate of bug 297143 *** |