Reload package problem two diffrent adapter instances

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 (shutDown & startUp services are called) 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 files and values stores into internal java objects so now there are diffrent values in MA1 and MA2!!!

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 question is:
Is there any standard way how to solve this problem?
Some standard way how to ‘synchronize package classloaders’?

I tryied to use following code in classes that are derived from WmART classes, for example in MyAdapterConnection which extends WmManagedConnection, but it didn’t help:
<code>
// 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 return reference to old instance
MyAdapter.getInstance();
</code>

I’m sure that there are no references from objects in WmART classloader to MyAdapter instance in MyAdapterClassloader.

Many thanks for your help!

P.S.: sorry for my english ;o)