Hi,
i’m developing custom adapter (let’s say MyAdapter) for WM. I’m using ADK 6.1, WM 6.5.
When I deploy the adapter package first time to Integration Server (IS) or restart the server, everything works fine. But the problems arise, when I reload the adapter package.
In WM, every package has its own classloader. My package has dependecy on WmART package - so there are two diffrent classloaders.
When the adapter package is first time deployed, new instance of MyAdapter (MA1) is created in MyAdapterClassloader and also in WmARTClassLoader, both instances are the same - it is OK and everything works fine.
But when I reload the MyAdapter package in MyPackageClassloader is created new instance MA2 (this is OK) but in WmARTClassloader last the old one MA1 - and that’s problem - because during initialization of adapter, the adapter reads some config xml files and values stores into internal java objects so now there are diffrent values in MA1 and MA2!!! and the changes don’t take effect in Developer tool.
I was inspired by WmSampleAdapter, but this problem is also there! After you reload WmSampleAdapter package, there are two diffrent instances of WmSampleAdapter class!
So my questions are:
Is there any standard way how to solve this problem?
Some standard way how to ‘synchronize package classloaders’?
I tried to use following code, but it didn’t help:
// obtain context cl
ServerClassLoader ctx = (ServerClassLoader) Thread.currentThread().getContextClassLoader();
// obtain MyAdapter cl
ServerClassLoader scl = ServerClassLoader.getPackageLoader(“MyAdapterPackage”);
// set MyAdapter cl
Thread.currentThread().setContextClassLoader(scl);
// getInstance still returns reference to old instance
MyAdapter.getInstance();
I’m sure that there are no references from objects in WmART classloader to MyAdapter instance in MyAdapterClassloader, so it’s not problem of my implementation.
Also this solutions solve my problem, but it’s not possible to do this in productional installation of WM:
1.) Restarting IS causes reload of all package classloaders.
2.) Reload WmART package, but then some Developer objects are lost.
Many thanks for your help!