After creating a handler class, register the handler with the portal.
Registration assigns a string, or type, to the handler. The author of an XML script can reference the handler by specifying the type in the objectClass attribute of a <Context> tag or the id attribute of an <Action> tag.
Registering Handlers
Create a portal service, which will be used to register the handler.
Make the service start automatically when deployed by setting the startup property in the service-config section of the portalapp.xml file to true .
In the init() method of the service, register the handler as follows:
public void init(IServiceContext serviceContext) { mm_serviceContext = serviceContext; IGenericCreatorRegister myRegisterService = (IGenericCreatorRegister) PortalRuntime.getRuntimeResources() .getService(IGenericCreatorRegister.KEY); myRegisterService.registerHandler("myHandlerType", MyHandler.class); }
In the above example, myHandlerType is the handler's type, which is added as an attribute in <Context> and <Action> tags to specify this handler.
Unregistering Handlers
In the destroy method of the service used for registration, unregister the handler, as follows:
public voiddestroy() { IGenericCreatorRegister myRegisterService = (IGenericCreatorRegister) PortalRuntime.getRuntimeResources() .getService(IGenericCreatorRegister.KEY); myRegisterService.unRegisterHandler("myHandlerKey"); }