In this post I will explain the UI component of a ESB mediator using the BAM mediator (Carbon version 4.0.5). UI component (i.e.: org.wso2.carbon.mediator.bam.ui) is responsible for the BAM mediator specific UIs in the following UI.
Mediator UI
When BAM mediator is selected in the above mediator sequence (there is only the BAM mediator is available here anyway) the UI located under the sequence UI, is specified in the mediator UI component. Anyway not all the UI under it comes from the UI component. UI between the bar named Mediator and Update button comes from the UI component. Actually this is the edit-mediator.jsp JSP located in the resources package in org.wso2.carbon.mediator.bam.ui component.
After the changes are made on UI the user can click on the above mentioned Update button. This event will call the update-mediator.jsp JSP adjacent to the edit-mediator.jsp JSP.
When switch to source view is clicked the following source appears.
And you can return back to design view by clicking on switch to design view link. This toggling mechanism need the implementation of UI component. In simple terms this functionality need the implementation of,
- BamMediator UI class - similar to BamMediator class in backend component
- serialize method - similar to serializeSpecificMediator method in BamMediatorSerializer class in backend component
- build method - similar to createSpecificMediator method in BamMediatorFactory class in backend component
Abstract Mediator Class (UI)
The difference of UI component with backend component is, that both serialize method and build method are included in the BamMediator UI class. BamMediator UI class can be found in org.wso2.carbon.mediator.bam.ui package.
BamMediator class should inherit from org.wso2.carbon.mediator.service.ui.AbstractMediator.
And also it should implement getTagLocalName method, similar to getTagQName used in backend. And also the serialize and build methods as mentioned earlier should be implemented.
public class BamMediator extends AbstractMediator { public String getTagLocalName() { } public OMElement serialize(OMElement parent) { } public void build(OMElement omElement) { } }
Abstract Mediator Service Class
public class BamMediatorService extends AbstractMediatorService { public String getTagLocalName() { return "bam"; } public String getDisplayName() { return "BAM"; } public String getLogicalName() { return "BamMediator"; } public String getGroupName() { return "Agent"; } public Mediator getMediator() { return new BamMediator(); } }As the example says every Mediator Service should inherit the org.wso2.carbon.mediator.service.AbstractMediatorService class.
Note how the name BAM is used as the sequence editor under the sub menu item named Agent. See how the getMediator method is used to execute the BamMediator UI class which we have discussed earlier.
Bundle Activator Class
Basically the Bundle Activator should inherit the org.osgi.framework.BundleActivator class and should implement start and stop methods. For further information read this article.
Properties props = new Properties(); bundleContext.registerService(MediatorService.class.getName(), new BamMediatorService(), props);Note how the BamMediatorService class is used.
Congratulations, you have finished the post series of how to write a custom mediator with WSO2 ESB. If you could not understand this well, most probably that is because you are not familiar with WSO2 Carbon platform. If you search more you will be able to catch them.