Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

dynamical class reload

dumbQuestionsAsker _

2005-10-11


hi everybody,
I got a problem loading an interface dynamycally.
Im working under Tomcat.
com.myApp.DefinitionServiceRemote and com.myApp.DefinitionService have to be
dynamically (re)loaded because they are uploaded.
com.myApp.DefinitionServiceRemote extends com.myApp.DefinitionService.
By default(when I launch my webapp) I have 2 wrong interfaces to be able to
launch my webapp and the cast doesn't work this way.
When I replace (before launching my webapp)the default interfaces, by these
which has to be dynamically loaded, I have no problem.

Any idea?

File file = new File (WEB_INF.substring (0, WEB_INF.length
()-7)+"/upload/"+typeDep+"/"+nomService+"/");
    try {

       URL url = file.toURL ();
       URL[] urls = new URL[]{url};


       Class cls;
       Class cls2;
       ClassLoader cl = new URLClassLoader (urls);

       cls2 = cl.loadClass ("com.myApp.DefinitionService");
       cls = cl.loadClass ("com.myApp.DefinitionServiceRemote");


       ServiceClient sc=new ServiceClient (null, nomService,
null);

       com.myApp.DefinitionServiceRemote dsr =
(com.myApp.DefinitionServiceRemote) sc.getObject ();

    } catch (MalformedURLException e) {
    } catch (ClassNotFoundException e) {
    } catch(ClassCastException e){

    }



Thank you in advance.

_________________________________________________________________
MSN Hotmail : antivirus et antispam gratuits !
http://www.imagine-msn.com/hotmail/default.aspx?locale=fr-FR


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.