other initialization } // ... other methods } In the above example, a call to
MyPluginClass.getInstance()
will always return an initialized instance of
MyPluginClass
.
Constructors and life cycle methods
If the plugin.xml of a plug-in indicates <?eclipse version="3.0"?> and its prerequisite list includes org.eclipse.core.runtime
, the default constructor of the plug-in class is used and {@link #start(BundleContext)} and {@link #stop(BundleContext)} arecalled as life cycle methods.
If the plugin.xml of a plug-in indicates <?eclipse version="3.0"?> and its prerequisite list includes org.eclipse.core.runtime.compatibility
, the {@link #Plugin(IPluginDescriptor)}constructor is used and {@link #startup()} and {@link #shutdown()} are called as life cycle methods.Note that in this situation, start() is called before startup() and stop() is called after shutdown.
If the plugin.xml of your plug-in does not indicate <?eclipse version="3.0"?> it is therefore not a 3.0 plug-in. Consequently the {@link #Plugin(IPluginDescriptor)} is used and {@link #startup()} and {@link #shutdown()} are called as life cycle methods.
Since Eclipse 3.0 APIs of the Plugin class can be called only when the Plugin is in an active state, i.e., after it was started up and before it is shutdown. In particular, it means that Plugin APIs should not be called from overrides of {@link #Plugin()}.