Developping Component Extension

Hello everybody.

With Mediator 7.2, in order to create my own component, I used a java class named message from the xbr.jar. In this class there is getProperties() function which retruns the Mediator Xbridge properties into a map.

I want to do the same whith Mediator 7.3.1 but the new message class doesn’t include any getProperties() function.
The new function have name like a(), b(), c(), and so on, and I don’t know which one matches with the old getProperties() function.

Does anyone know which function I can use ?
I have the same problem with the following functions:
- getPayload()
- setProperties()
- setPayload()

Thanks a lot for your help.

Hello Nynyves,
To avoid a user needs to use internal system methods, which in fact is always dangerous in regard of possible differences between different product version, we provided in 7.3.1 two methods to create custom components. This are the Mediator Component Extensions and the Java Object Gateway. Please refere to the product documentation.
I hope it helps.
Regards
Andreas

I am developping a Java custom extension for Mediator 7.3.1.

I am getting troubles when it comes to debugging. I tried to insert System.out.println statement but I cannot figure out where they are displayed (neither HostManager or JBoss consoles displayed them).

I have another question:my extension expects the message payload as argument, how this can be achieved

Thanks
Jeff

Hi Jeff,

System.out.println is going to go into the great nothing and nowhere else. The ComponentFactory where your custom extension is running in a seperate JVM which does not output to a cmd window. You could stop the component factory and then start it with the StartFactory.bat file located in the directory “/Program Files/Software AG/EntireX XML Mediator/host/bin” if you are running on a windows platform. For Unix look to the directory $XBD_HOST/bin.
For the long term you may want to add some code to your custom component which writes your debugging information to the file system.

Regards,

- Matthew G.

Thanks for the tip.
I tried to log on a file but I wasn’t able to find the file on my disks. So I suspect my extension class is not loaded.
Do you know how can I get loading information from Mediator. I changed the trace level to DEBUG but it says it calls my extensions.

Thanks
Jeff


This is actually rather simple because you can redirect System.out to a file: there is a method java.lang.System.setOut which allows you to do that.

Kind regards,
Rolf

Hi Jeff,

If the component was not loaded then it will not show up in the SMH component list for that component factory or it will show up but will not be active (red instead of green light).

If it isn’t showing up in SMH you probably have an error somewhere in the extension configuration file.

- Matthew G.

I am now able to call my component from a sequence. Now my component needs to get the message payload as an argument and returned a modified payload as a result.
How can I pass the message payload as an argument to my component function ?

Thanks
Jeff

Jeff,

You’ll use a Java Object Gateway step to make
a copy of the message payload. The copy will
be input to your component. The attached sequence might help.

Regards,

Jason
fopComp.xml (2.45 KB)

Hi Jeff,

Some bad news for you before you get too involved trying to get this running… There is a bug in the JOG Gateway which may prevent you from getting this up and running. A new patch should be released in July which corrects this problem.

I will describe passing payloads to custom components for you in any case.

To pass the payload to your component you first need to create an object. You do this by calling the JOG Gateway using the “message” function and choosing the “getContent” action.
The actual step would look something like:



The call to your component should then look like:

<step component="MyComponent"
my.prefix.function=“Call” my.prefix.input=“MyPayload” my.prefix.method=“run” my.prefix.result="MyResult"
my.prefix.do=“run(my.prefix.input)” />

Follow this by a JOG Gateway call to return the result to the active payload…



Sorry about the bad news regarding the bug, but the problem will be gone in short order.

Regards,

- Matthew G.

I think I found the problem.
When I tried the code sent by Jason, then I got an error saying that my component does not exists.
Is this the bug you mentionned ?

Is there a work around for this ?
What’s about XPath expresssion ?
I tried them but my component receive a String where I expect a DOM or like object (I used scort.mediator.inputObject={/}

The problem you saw is a symptom of the bug I mentioned and there is no known workaround. As I mentioned, this is one of the major reasons we are planning on a patch in July.
When you set properties to XPath expressions then the returned values are always string.
The method for supplying your component with the payload is as I described it in the last message. The process I described creates a ByteArray which you can read into your class using the class java.io.ByteArrayInputStream. It is important that you return a ByteArray as well because this is the method the ComponentFactory uses to pass message objects between components.

- Matthew G.

I found a workaround for this problem !!!

The workaround simply consist in using my own extension for Message getContent and addContent instead of using SAGJavaObjectGateway

I think the limitation is that you can use a single Java extension in a sequence (or in the Factory)

commons-logging questions:

I have the following question: I want to add common-logging feature in my Java component extension. If I use the xbd category, this work fine and I am able to see my traces in factory.xbd.log.
But if I want to use my own category, how do I specify the threshlod level for this category ?

I found nothing in the general tab of my factory configuration

Where there is a will there is a way.
Altering the logging configuration is not currently supported. There are of course ways to do this but you are then creating an installation where migration to future patch levels or versions would no longer be possible. Not without breaking your logging implementation anyway.
Because of this I would not suggest it. You should instead concentrate on defining your own logging environment.
Regards,

- Matthew G.