cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent java mapping from reloading before each message?

Andrzej_Filusz
Contributor
0 Kudos

Hi!!!

I've written a simple java mapping (XI 2.0): "Content Enricher" transformation

(source system doesn't send some key information required by target system).

It works fine.

Then I wanted to put some parametrization data into the database.

I added some code to load this data only once into my data structures in the memory.

I also works fine.

But the problem is that SAP XI uses MappingLoader/MappingResolver

to load jar file during transformation of every message.

In a such situation I lose all data and my code has to connect

to the database again (what is not good because of performance).

The question is:

how to configure SAP XI/where to put my code

to achieve a such behaviour: only once my code would load

parametrization from db and then "normal" java mapping could

use it during messages transformation without impact

on the performance?

Regards,

Andrzej Filusz

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Andrzej,

From a Java point of view you could implement the "Singleton" pattern in your Java mapping class. Which will prevent the any JVM (java Virtual Machine) from instanciate more than one instance of your Java mapping class. So in your environment you will lways have only one instance of your mapping class.

Cheers,

Rob.

Andrzej_Filusz
Contributor
0 Kudos

Hi!!!

Thanks for your answer, but I'm afraid that your solution: singleton pattern doesn't solve my problem.

When XI reload my java mapping classes, all loaded and kept data are lost. Singleton pattern can't prevent it.

I asked SAP about this problem: in XI 3.0 the classes will only be reloaded when a cache refresh has really taken place. But they won't implement this improved behaviour in XI 2.0.

Regards,

Andrzej Filusz

Former Member
0 Kudos

HI Andrzej,

I'm probably wrong with my opinion but I still think that with the use of the Singleton pattern in your class (where you have implemented the DB connection) OR making your DBconnection instance an static one, could be one of the possible solutions.

But again that's only theoretically seen.

Cheers,

Rob.

Andrzej_Filusz
Contributor
0 Kudos

Hi!

I was pretty sure that singleton pattern won't solve my problem, but just to be sure I did a test.

As I expected my private static map (hashtable) variable was refilled with data during tranformation of every message.

Regards,

Andrzej Filusz