简体   繁体   English

如何在wso2 esb /中创建类中介

[英]How to create Class Mediator in wso2 esb /

I would like to create class mediator. 我想创建类中介。 I tried with ordinary java class i put into components/lib folder then i restart this system. 我试过普通的java类我把它放到components / lib文件夹然后我重新启动这个系统。

Can anyone tell me step by step procedure. 谁能告诉我一步一步的程序。

  1. Write a class which implements org.apache.synapse.Mediator and override the mediate(MessageContext mc) method and create a jar file. 编写一个实现org.apache.synapse.Mediator的类,并覆盖mediate(MessageContext mc)方法并创建一个jar文件。

     public class SimpleClassMediator implements Mediator { private String varible1="10"; private String varible2="10"; public boolean mediate(MessageContext mc) { //To test you can print something here return true; } //getters and setters } 
  2. Copy the jar to ESB_HOME/repository/components/lib and start the ESB. 将jar复制到ESB_HOME / repository / components / lib并启动ESB。

  3. Then in synapse config you can call this mediator as follow . 然后在synapse配置中,您可以调用此调解器, 如下所示

     class name="packageName.ClassName" 
  1. You can create class mediator easily by extending the "AbstractMediator". 您可以通过扩展“AbstractMediator”轻松创建类中介。

  2. Mediator can be an OSGI build or jar file. Mediator可以是OSGI构建或jar文件。 Both can be deployed with WSO2 ESB. 两者都可以与WSO2 ESB一起部署。 If You need to deploy the Jar file in to /repository/components/lib directory. 如果需要将Jar文件部署到/ repository / components / lib目录中。 If it is an OSGI bundle, it must be deployed in to /repository/components/dropins directory. 如果它是OSGI包,则必须将其部署到/ repository / components / dropins目录中。 If there are any external dependent libraries, you can put them it to /repository/components/lib directory 如果有任何外部依赖库,您可以将它们放到/ repository / components / lib目录中

  3. Update the synapse configure with the full qualified class name 使用完全限定的类名更新synapse configure

You can find sample more detail from here . 您可以从这里找到更多详细信息 It contains a sample mediator code that you can look in to. 它包含您可以查看的示例介体代码。

1. First create a Maven module e.g org.wso2.carbon.mediator and then  create e.g ESBMessageMediator class  which is extended from AbstractMediator. 

2. Above maven module can be configured as OSGI budle or jar file.

3. Build the module using maven.

4. If it is OSGI bundle put it in to the /repository/components/dropins else put it to the 
   /repository/components/lib

5. configure synapse.xml file located in the "/repository/deployment/server/synapse-configs/default"
  e.g <class name="org.wso2.carbon.mediator.ESBMessageMediator">
    <property name="defaultPercentage" value="10"/>
</class>
6.Run the ESB and try to create a proxy service by adding the above meaditor as class mediator.if it load succesfully it is done. 

you can read about class mediator in WSO2 in this site [ 1 ] 你可以在这个网站上阅读WSO2中的班级调解员[ 1 ]

You can write the logic in the mediate() method :) 你可以在mediate()方法中编写逻辑:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM