MBaev
MBaev

Reputation: 373

Can I add factory class to custom extension point

Creating the extension point: Picture

Attach to extension point class: Picture

Can I add factory class to the custom extension point, which returns a different class depending on some rule?

Upvotes: 0

Views: 116

Answers (1)

greg-449
greg-449

Reputation: 111142

To make your class a factory it can implement the IExecutableExtensionFactory class, The Eclipse extension manager will call the

public Object create() throws CoreException

method to ask your factory to create the extension class.

Many factory classes also implement IExecutableExtension which has the single method:

public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException

The extension manager will call setInitializationData before calling create. It gives you the entire configuration element from the plugin.xml so you can look at any attributes you want.

Upvotes: 1

Related Questions