Hi Kasun, Main drawback of the pojo mediator is, it does not have access to message context, so everything it need to access need to pass as parameters in sequence. Also in most custom mediator cases, it is required to modify contents of message context which is not possible with pojo mediator.
IMO using class mediator vs pojo is purely a decision of connector developer. There can be situations where for pojo mediator will be better suite than class mediator and it's totally fine to use pojo mediator in such cases. Since connector is kind of a meta synapse artifact, it can use any other synapse artifacts based on usecase to implement connector library. On Wed, Jul 31, 2013 at 2:20 PM, Kasun Indrasiri <[email protected]> wrote: > We are in the process of implementing several components which involves > java sdks (twitter), although the class mediator approach works fine, it > seems to introduce some usability issues. > > - Basically, a given class mediator simply get all the required properties > from the message context where property names are hard coded in both > template and class mediator. [1] > > - One possible approach that we can use is to use POJO mediator, so that > we can dynamically resolve the incoming parameters and we could have > minimal java code when implementing our connector. > - We can even get more flexibility with spring mediator as well[2]. > - However, class mediator approach is better when it comes to performance > (since we use reflection in other two approaches). > > - We will do a PoC on these approaches and see how it goes. > > This is a sample config with POJO Mediator > eg: > > package org.apache.twitter; > > import org.apache.synapse.Command; > > public class TwitterInvokeMediator implements Command { > > private String twitterSecrect; > > private String twitterId; > > private String message; > > public void execute() { > > System.out.println("TwitterID :" + twitterId); > > twitterId = "CDE"; > > } > > > public String getTwitterSecrect() { > > return twitterSecrect; > > } > > public void setTwitterSecrect(String twitterSecrect) { > > this.twitterSecrect = twitterSecrect; > > } > > public String getTwitterId() { > > return twitterId; > > } > > public void setTwitterId(String twitterId) { > > this.twitterId = twitterId; > > } > > public String getMessage() { > > return message; > > } > > public void setMessage(String message) { > > this.message = message; > > } > > } > > > Invocation : > > > <pojoCommand name="org.apache.twitter.TwitterInvokeMediator"> > > <axis2ns1:property xmlns:axis2ns1=" > http://ws.apache.org/ns/synapse" > > name="twitterId" > > expression="$ctx:TWID" > > action="ReadMessage"/> > > <axis2ns1:property xmlns:axis2ns1=" > http://ws.apache.org/ns/synapse" > > name="twitterId" > > context-name="updatedID" > > > action="UpdateContext"/> > > </pojoCommand> > > > > [1] > https://svn.wso2.org/repos/wso2/carbon/platform/branches/4.1.0/components/mediation/mediation-library/connectors/org.wso2.carbon.mediation.library.connectors.twitter/4.1.0/src/main/java/org/wso2/carbon/mediation/library/connectors/twitter/TwitterUpdateStatusMediator.java > > [2] > https://svn.wso2.org/repos/wso2/carbon/platform/branches/4.1.0/dependencies/synapse/2.1.1-wso2v3/modules/samples/src/main/java/samples/mediators/extensions/SpringCustomLogger.java > -- > Kasun Indrasiri > Software Architect > WSO2, Inc.; http://wso2.com > lean.enterprise.middleware > > cell: +94 71 536 4128 > Blog : http://kasunpanorama.blogspot.com/ > > _______________________________________________ > Architecture mailing list > [email protected] > https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture > > -- Miyuru Wanninayaka Technical Lead WSO2 Inc. : http://wso2.com Mobile : +94 77 209 9788 Blog : http://miyurudw.blogspot.com Flickr : http://www.flickr.com/photos/miyuru_daminda
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
