# com.bea.ide.core
DefaultExtension Class

public class DefaultExtension
extends `Object`
implements `IExtension`

This class provides a default implementation of the IExtension interface that simplifies the implementation for extension writers. This should be used as a base class that is extended. By calling the two protected methods `DefaultExtension.addService(String, Object)``` and `DefaultExtension.addHandler(String, IExtensionXmlHandler)``` in the no-argument constructor the extending class can very simply hook in to the IDE.

Hierarchy
  `Object`
  `DefaultExtension`

All Implemented Interfaces
  `IExtension`

## Constructor Summary

DefaultExtension()

## Method Summary

`protected void` | `addHandler`(`String` sId, `IExtensionXmlHandler` handler) Adds the given object to a map with the given handler-id as the key.
`protected void` | `addService`(`String` sInterface, `Object` impl) Adds the given object to a map with the given interface as the key.
`public boolean` | `canExit`() Called before shutdown on all extensions with exit-handler=true This implementation always returns true.
`public `IExtensionXmlHandler`` | `getHandler`(`String` sId) Obtains an instance of the xml handler associated with the given id string. This implementation looks up the handler in a map that can be set using the `DefaultExtension.addHandler(String, IExtensionXmlHandler)``` method.
`public `Object`` | `getServiceImpl`(`String` sInterface) Obtains an instance of an object implementing the string interface provided. This implementation looks up the service in a map that can be set using the `DefaultExtension.addService(String, Object)``` method.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `com.bea.ide.core.`IExtension``
``canExit`, `getHandler`, `getServiceImpl``

## Constructor Detail

### DefaultExtension

    public DefaultExtension()

## Method Detail

### addHandler(String, IExtensionXmlHandler) Method

    protected void addHandler(String sId,
                              IExtensionXmlHandler handler)

Adds the given object to a map with the given handler-id as the key. This map will be used by the `DefaultExtension.getHandler(String)``` method to look up the handler using the handler-id string

#### Parameters

sId
  handler id of the xml handler

handler
  implementation of the xml handler interface that corresponds to the specified id

### addService(String, Object) Method

    protected void addService(String sInterface,
                              Object impl)

Adds the given object to a map with the given interface as the key. This map will be used by the `DefaultExtension.getServiceImpl(String)``` method to look up the service using the interface string.

#### Parameters

sInterface
  interface the service implements

impl
  implementation object for the specified interface

### canExit() Method

    public boolean canExit()

Called before shutdown on all extensions with exit-handler=true This implementation always returns 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``` This implementation looks up the handler in a map that can be set using the `DefaultExtension.addHandler(String, IExtensionXmlHandler)``` method.

#### 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. This implementation looks up the service in a map that can be set using the `DefaultExtension.addService(String, Object)``` method.

#### Parameters

sInterface
  the interface of the service being requested

#### Returns

The instance of a class implementing the desired interface.