My application needs to create different ConfigurationContext objects to
pass into the ServiceClient to invoke different Web Services. It seems that
every time this is done Axis2 creates a lot of *.mar files in a temp folder.
This reduces performance and also takes up a lot of disk space. I’ve read
several other related posts that indicate that it does this to try to
resolve other *.jar files that may be located inside the *.mar files, but
couldn’t this all be done in memory rather then constantly writing to and
then reading from the file system?



To fix this I’ve extended the URLBasedAxisConfigurator and have overridden
the loadRepositoryFromURL(URL repoURL) method from the DeploymentEngine
class to change the way that the ‘deploymentClassLoader’ variable is created
like this:



Old code:



URL moduleurl = new URL(moduleDir, fileUrl);

ClassLoader deploymentClassLoader = Utils.createClassLoader(new
URL[]{moduleurl},



axisConfig.getModuleClassLoader(),


                                                            true,


(File)axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));



New Code:



URL moduleurl = new URL(moduleDir, fileUrl);

ArrayList<String> embeddedJars =
(ArrayList<String>)Utils.findLibJars(moduleurl);

ClassLoader deploymentClassLoader = new DeploymentClassLoader(new URL[]
{moduleurl}, embeddedJars, axisConfig.getModuleClassLoader());



By changing the code to look like this, we can do everything in memory
rather then writing temporary files to the file system. I wanted to see what
people think about this solution and if the DeploymentEngine might be able
to be fixed in the next release?



Thanks,

Ben

Reply via email to