简体   繁体   English

WSO2 ESB使用自定义介体

[英]WSO2 ESB use of Custom Mediator

I like to write a Custom Mediator for the WSO2 ESB. 我喜欢为WSO2 ESB编写自定义介体。 I found some Tutorials for this, but I don't get it working in the WSO2 ESB. 我找到了一些与此相关的教程,但是我没有在WSO2 ESB中使用它。 I think I maybe have an error in the path I need for the Class Mediator, but let me explain everything: 我想我在类调解器所需的路径上可能有一个错误,但让我解释一下所有内容:

For writing this Mediator I use the WSO2 developer Studio for Eclipse Juno. 为了编写此介体,我使用WSO2开发人员Studio for Eclipse Juno。

There I created a new ESB Mediator Project called "b64writer" with this content: 在那里,我创建了一个新的ESB Mediator项目,名为“ b64writer”,其内容如下:

package org.wso2.carbon;
import org.apache.synapse.MessageContext; 
import org.apache.synapse.mediators.AbstractMediator;
public class B64Mediator extends AbstractMediator { 
    public boolean mediate(MessageContext context) { 
        // TODO Implement your mediation logic here         
        String inhalt = context.getEnvelope().toString();
        trace.trace("Message: " + inhalt);
        return true;
    }
}

In the next step I created a new Carbon Application Project, with the Mediator selected on "Dependencies". 在下一步中,我创建了一个新的Carbon Application Project,并在“ Dependencies”上选择了Mediator。 The config for this is: 的配置是:

  • Group ID: org.wso2.carbon.b64mediator 组ID:org.wso2.carbon.b64mediator
  • Artifact ID: b64mediator 工件ID:b64mediator
  • Version: 1.0.0 版本:1.0.0

I used the button on the right side to create an archive. 我使用了右侧的按钮来创建档案。 This archive I copied to "C:\\wso2esb\\repository\\carbonapps\\0". 我将此存档复制到“ C:\\ wso2esb \\ repository \\ carbonapps \\ 0”。

And now my question: How can I use this Mediator? 现在我的问题是:如何使用此调解器? It should work like this: 它应该像这样工作:

<class name="org.wso2.carbon.B64Mediator" />

But it isn't. 但事实并非如此。 WSO2 ESB can't find the class. WSO2 ESB找不到该类。 Where's my mistake? 我的错在哪里

Ok, I had the same issue as you, and I managed to add the mediator by using the WSO2 Developer Studio add-on for eclipse to make a mediation library. 好的,我遇到了与您相同的问题,并且设法通过使用WSO2 Developer Studio插件(用于eclipse)添加中介程序来制作中介库。 (Bring up the new wizard box, and select WSO2/Extensions/Project Types/Mediator Project) (调出新的向导框,然后选择WSO2 / Extensions / Project Types / Mediator Project)

Then create your mediator or put into the project, and export it as a jar file to the /repository/components/lib folder. 然后创建您的介体或放入项目中,并将其作为jar文件导出到/ repository / components / lib文件夹中。 You have to restart the ESB every time you update the jar or if you're running the ESB when you add the jar. 每次更新jar或添加jar时如果正在运行ESB,则必须重新启动ESB。

I hope this helps. 我希望这有帮助。

将归档文件放在repository/components/dropinsrepository/components/lib (if you don't build it as an osgi bundle)目录中。

you should deploy class mediators as java Library artifact and refer them from class Mediators. 您应该将类​​介体部署为java库构件,并从类Mediators中引用它们。 That is, deply the jar you craeted from dev studio and keep taht in repository/components/lib folder and restart the server. 也就是说,将您从dev studio放下的jar放进去,并将其保留在repository / components / lib文件夹中,然后重新启动服务器。 Then refer like; 然后像这样引用;

<class name="org.wso2.carbon.B64Mediator" />

from your sequence 从你的顺序

I don't know if you have solved your problem. 我不知道您是否解决了问题。 I had the same issue but I could solved it. 我有同样的问题,但我可以解决。

I created my mediator using the WSO2 Developer Studio "Mediator Project" in Eclipse Kepler. 我使用Eclipse Kepler中的WSO2 Developer Studio“调解器项目”创建了调解器。 Next I exported to Java/JAR file right clicking in my project and selecting "export generated class files and resources" in the properties. 接下来,我右键单击项目并在属性中选择“导出生成的类文件和资源”,将其导出到Java / JAR文件。

The JAR file you have to place into repository/components/lib folder and restart your ESB 您必须将JAR文件放入repository / components / lib文件夹并重新启动ESB

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

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