Hi,
On Sun, 16 Feb 2003 18:04, Korosh Afshar wrote:
> |--SAR/lib/myclasses.jar
> |--SAR/lib/thirdparty.jar
> |--SAR/lib/someotherstuff.jar
> |--SAR/assembly.xml
> |--SAR/environment.xml
> |--SAR/config.xml
The first thing you need to do is place the classes you want to load in a
custom loader in a new location in the .sar file. I would recomend that you
layout your jar like;
|--SAR-INF/lib/someotherstuff.jar
|--SAR-INF/assembly.xml
|--SAR-INF/environment.xml
|--SAR-INF/config.xml
|--lib/myclasses.jar
|--lib/thirdparty.jar
(Note that myclasses.jar and thirdparty.jar are in separate lib directory).
And then in your code you do something like;
final File base = getBlockContext().getBaseDirectory();
final URL url1 = new File( base, "lib/myclasses.jar" ).toURL();
final URL url2 = new File( base, "lib/thirdparty.jar" ).toURL();
ClassLoader loader = new URLClassLoader( new URL[] {url1, url2} );
Class launcher = loader.loadClass( "com.biz.ThirdPartyClassLauncher" );
Method method = launcher.getMethod( "main", new Class[] { String.class } );
method.invoke( null, "mypackage.MyClassB" );
So the above will create a new ClassLoader that does not have any parent
classloaders (which may fix the problems you are experiencing). It then loads
the launcher class and uses reflection to call appropriate method.
Without knowing more details about your specifics it is difficult to guess
what else to do. Feel free to ask more here or directly if there is something
else I can help with.
--
Cheers,
Peter Donald
---------------------------------------------------------
Clarke's Third Law: "Any technology distinguishable from
magic is insufficiently advanced".
---------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]