I've got it. It is not so intuitive, but it works for me. There is an instance implementing the IApplicationContext
interface. (The interface depends on the org.eclipse.equinox.app
.) The instance is reachable by the injection mechanism. The method getArguments()
returns a map. But it does not return a map of some command line parameters and their values. It returns some map, where it is under the key "application.args"
stored an array. Exampli gratia:
@PostConstruct
public void createControls(Composite parent, HtmlEditorService editorService, IApplicationContext iac) {
System.out.println(iac.getArguments().get("application.args").getClass().getCanonicalName());
...
}
Then it prints out java.lang.String[]
. However the array contains just my custom arguments instead all arguments. Fortunately it does not matter for me. I need to get my custom arguments only.
Additional hint for a plug-in activator
public class Aktivator implements BundleActivator {
@Override
public void start(BundleContext context) throws Exception {
ServiceReference<?> ser = context.getServiceReference(IApplicationContext.class);
IApplicationContext iac = (IApplicationContext)context.getService(ser);
System.out.println(iac.getArguments().get("application.args").getClass().getCanonicalName());
}
@Override
public void stop(BundleContext context) throws Exception {
}
}