Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Product Backlog
-
Component/s: Core: Configuration
-
Labels:None
-
User impact:Low
-
Affects Docs:Yes
-
Migration Impact:None
-
Similar Issues:None
Description
Endpoint builders are useful when we need to reference the same endpoint multiple times in the configuration and also simplify the code for dynamic creation of new endpoints at runtime. I would like to propose a ServiceBuilder, which is the extension of the same model to encompass services.
On the configuration level, the user would declare a service template outside of the <mule:model> and then refer the service template (possibly multiple times) inside the model. Looking up the service template from code would return a ServiceBuilder interface, which can be used for parameterizing and creating/looking up the appropriate service.
The service template can be either a separate tag (like <endpoint> vs <inbound-endpoint> and <outbound-endpoint>) or a wrapping tag, which would wrap a regular service tag. We need to provide some mechanism for parameterizing the services. I would suggest that we use the existing evaluators subsystem.
Here are examples for both proposed styles:
<?xml version="1.0" encoding="UTF-8"?> <mule [...thousand and one namespace declarations]> <service name="MyHandler-Template"> <inbound> <inbound-endpoint address="jms://${template-parameter:CODE}-updates.topic"/> </inbound> <outbound> <list-message-splitter-router> <outbound-endpoint ref="chatroom"> <transformers> <transformer class="com.mycompany.transformers.TickToMessage"> <property name="template"> Update for ${template-parameter:CODE}, price: ${xpath:/tick/last-px} volume: ${xpath:/tick/acvol} <property> </transformer> </transformers> </<outbound-endpoint> </list-message-splitter-router> </outbound> </service> <endpoint name="chatroom" address="xmpp://chatroom@jabber.mycompany.com:5222/"/> <model name="Pegi"> <!-- Need to specify the name explicitly --> <service name="XMPP-Forwarder-6758" ref="MyHandler-Template"> <parameter name="CODE" value="6758"/ </service> <service name="Nintendo" ref="MyHandler-Template"> <parameter name="CODE" value="7974"/ </service> </model> </mule>
<?xml version="1.0" encoding="UTF-8"?> <mule [...thousand and one namespace declarations]> <service-template name="MyHandler-Template"> <service name="XMPP-Forwarder-${template-parameter:CODE}"> <inbound> <inbound-endpoint address="jms://${template-parameter:CODE}-updates.topic"/> </inbound> <outbound> <list-message-splitter-router> <outbound-endpoint ref="chatroom"> <transformers> <transformer class="com.mycompany.transformers.TickToMessage"> <property name="template"> Update for ${template-parameter:CODE}, price: ${xpath:/tick/last-px} volume: ${xpath:/tick/acvol} <property> </transformer> </transformers> </<outbound-endpoint> </list-message-splitter-router> </outbound> </service> <service-template> <endpoint name="chatroom" address="xmpp://chatroom@jabber.mycompany.com:5222/"/> <model name="Pegi"> <!-- Name is defined in the template --> <service ref="MyHandler-Template"> <parameter name="CODE" value="6758"/ </service> <!-- Override the name defined in the template --> <service name="Nintendo" ref="MyHandler-Template"> <parameter name="CODE" value="7974"/ </service> </model> </mule>
Implementing this means API and schema changes which is not going to happen before the next minor release.