简体   繁体   English

在createExecutableExtension中调用参数化的构造函数

[英]Calling parameterized constructor in createExecutableExtension

I've a class ( Clock ) with a parameterized constructor. 我有一个带有参数化构造函数的类( Clock )。 I am calling this Clock class in a plugin using extensions. 我在使用扩展的插件中调用此Clock类。

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. 方法createExecutableExtenison仅调用Clock类的默认构造函数。 How can I call parameterized constructor of Clock class? 如何调用Clock类的参数化构造函数?

Thanks in advance. 提前致谢。

The Javadoc for createExecutableExtension says: 用于createExecutableExtension的Javadoc说:

The specified class is instantiated using its 0-argument public constructor. 使用0参数的public构造函数实例化指定的类。

so you can't use a parameterized constructor. 因此您不能使用参数化的构造函数。

You can make your class implement IExecutableExtension in which case the method: 您可以使您的类实现IExecutableExtension在这种情况下,该方法为:

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. 这可用于从配置元素获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM