IExtension Interface
- public interface IExtension
This is the primary interface implemented by extensions to the IDE. Extensions are not required to implement this
interface, but if the extension defines any services or any extension-xml handlers, this interface must be implemented.
The main purpose of this interface is to retrieve implementation objects for the two significant extension mechanisms
of the IDE: Services and extension-xml handlers. Services and handlers are declared in the extension xml. This
interface is then used to retrieve the objects implementing the declared features.
The extension.xml file has the following format:
<extension-definition>
<extension-info class="{class}" [exithandler="true"] [initialize="true"]>
<service interface="{interface}" [class="class"]/>*
<extension-xml-handler id="{handler-id}"/>*
</extension-info>
</extension-definition>
<extension-xml id="{handler-id">{xml}</extension-xml>*
{} indicates a string defined below.
[] indicates optional items.
* indicates the tag may appear 0 or more times
class - The class name to instantiate that implements the IExtension interface or service interface.
interface - The interface for the service.
handler-id - The unique string identifying the xml handler (for usage see below).
xml - A set of xml in the format specified for the given handler-id.
The exithandler attribute is optional. If set to true, the canExit method of the extension will be called prior to the
IDE shutting down. This will allow an extension to override shutdown of the ide, perhaps in response to a dialog or
some internal state.
The intialize attribute is also optional. If set to true, it will force the IDE to instantiate the extension object
no later than the completion of all extension parsing. Note that the IDE may instantiate it prior to that time in order
to obtain Xml handlers.
More information on serivices and xml handlers is available below on the methods that pertain to them.
-
All Known Implementing Classes
-
DefaultExtension
canExit() Method
public boolean canExit()
Called before shutdown on all extensions with exit-handler=true
Returns
- true to indicate shutdown may proceed, false to halt shutdown.
getHandler(String) Method
public IExtensionXmlHandler
getHandler(String
sId)
Obtains an instance of the xml handler associated with the given id string. An extension xml-handler is a
mechanism for allowing other extensions to customize or add features to a service or extension. An extension
may define zero or more XML handlers to customize the features it exposes.
By convention the id used is a URN of the form:
urn:{package}:{subsystem}
for example, the Document service of the ide allows documents to be defined using the document extension handler
with the ide "urn:com-bea-ide:document". The format of the xml is completely defined by the handler.
Extensions should declare their available handlers in the extension-definition tag. Then any other extensions that
contain an <extension-xml id="{handler-id}"/> fragment will have that fragment parsed by the declared handler.
For more on the how handlers work see IExtensionXmlHandler
Parameters
-
sId
- the handler-id string of the xml handler to get
Returns
- an object implementing the IExtensionXmlHandler interface that can handle xml for the given id
getServiceImpl(String) Method
public Object
getServiceImpl(String
sInterface)
Obtains an instance of an object implementing the string interface provided. The object will be used as the
single instance of the given interface. This is typically used to implement services within the IDE. A service
is an interface that is implemented by a singleton instance that is globally accessible. Typically the service
is wrapped by a class that will fetch and store the singleton instance using a static get() method for convienience.
Application
is an example of this service.
This method is used by the application to obtain the instance. It should only ever return a single object for any
given interface. The same object may be used to implement several interfaces.
Parameters
-
sInterface
- the interface of the service being requested
Returns
- The instance of a class implementing the desired interface.