-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "constructor-injection" with IConfigurationElement#createExecutableExtension #8
Comments
This is overall a good idea, but then implementations would not be backward compatible: imagine an extension made for 4.25 that does use a constructor with args because it's supported, then this extension wouldn't run with 4.24 because it would be missing a no-arg constructor. Although it may not be a strong blocker, we need an elegant way to ensure people understand that limitation. |
@mickaelistria I implemented that for the org.eclipse.ui.views extention point a few years ago. Users had to / could opt in to this via the additional Inject parameter on the extension point. |
I think in general one can't expect such kind of compatibility (I won't call this backward compatible) because plugins written fro newer eclipse versions will generally require newer features/API already.
According to the implementation, no I don't see any way for that, for sure one could do so afterwards but this would always need additional techniques (e.g. E4). |
I agree. However, for things like new API or new extension points, there are versioning guards that make them well use. As per what is allowed in extension class, it's not as easy. We'd need to document it properly on related extension point that enable it (from which version constructor params are enabled; are no-op constructors still useful...?) |
If one want be super compatible he can create a default constructor as well (if suitable), if a default constructor is not suitable then it won't make sense of course. |
This issue has been inactive for 180 days and is therefore labeled as stale. |
This issue has been inactive for 180 days and is therefore labeled as stale. |
This issue has been inactive for 180 days and is therefore labeled as stale. |
This issue has been inactive for 180 days and is therefore labeled as stale. |
I found that one source of using static methods are extensions declared with
plugin.xml
The reason for this is, that a extension must have either a default constructor, or implement
IExecutableExtensionFactory
where both do not allow to pass any items at construction time. Also the creator can not pass additional data when creating the extension...Example:
So I'd like to propose the following:
IConfigurationElement
with the following signature:Object createExecutableExtension(String propertyName, Object... args) throws CoreException;
That way the example can then be enhanced to pass a
workspace
object for example:"old" implementations won't need to adapt, but newer ones could add a new constructor where they get a workspace object injected instead of calling static methods to fetch the required items.
The text was updated successfully, but these errors were encountered: