2
votes

I like to write a Custom Mediator for the WSO2 ESB. I found some Tutorials for this, but I don't get it working in the 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.

There I created a new ESB Mediator Project called "b64writer" with this content:

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". The config for this is:

  • Group ID: org.wso2.carbon.b64mediator
  • Artifact ID: b64mediator
  • Version: 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".

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. Where's my mistake?

4

4 Answers

1
votes

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. (Bring up the new wizard box, and select 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. You have to restart the ESB every time you update the jar or if you're running the ESB when you add the jar.

I hope this helps.

0
votes

Place the archive inside repository/components/dropins or repository/components/lib (if you don't build it as an osgi bundle) directory.

0
votes

you should deploy class mediators as java Library artifact and refer them from class Mediators. That is, deply the jar you craeted from dev studio and keep taht in repository/components/lib folder and restart the server. Then refer like;

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

from your sequence

0
votes

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. Next I exported to Java/JAR file right clicking in my project and selecting "export generated class files and resources" in the properties.

The JAR file you have to place into repository/components/lib folder and restart your ESB