I've a class ( Clock
) with a parameterized constructor. I am calling this Clock
class in a plugin using extensions.
try {
for (IConfigurationElement e : config) {
System.out.println("Harsha Evaluating extension of Clock");
o = e.createExecutableExtension("class");
}
} catch (CoreException ex) {
System.out.println(ex.getMessage());
}
The method createExecutableExtenison
is only calling default constructor of Clock
class. How can I call parameterized constructor of Clock
class?
Thanks in advance.
The Javadoc for createExecutableExtension
says:
The specified class is instantiated using its 0-argument public constructor.
so you can't use a parameterized constructor.
You can make your class implement IExecutableExtension
in which case the method:
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException;
will be called straight after construction. This can be used to get extra information from the configuration element.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.