Can I add factory class to custom extension point

110 Views Asked by At

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?

1

There are 1 best solutions below

0
greg-449 On BEST ANSWER

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.