java - Disable Cache in URLClassLoader -


so making server, lot irc, learn more, , here's problem.

i have commands each person can call depending on rights, , each "command" has it's own class located in 1 directory. load classes hashmap, , works great if add new commands, if change old one, nothing changes in it.

so how can use urlclassloader load classes without caching them?

thanks help.

this code i'm using

classloader loader = new urlclassloader(scripturls);         try {             for(url u : scripturls) {                 if(u == null) continue;                 string filename = u.getfile();                 int beginindex = filename.indexof("commands/") + 9;                 int endindex = filename.indexof(".c");                 filename = filename.substring(beginindex, endindex);                 string name = filename.tolowercase();         class<command> c = (class<command>) loader.loadclass("chat.commands."+filename); 

i realize it's not cleanest or efficient code out there, works.

you should careful creating own classloaders run out of permgen space result of circular references in memory prevent garbage collector reclaiming space taken previous loaders (that careful of if decide dump classloader , create new 1 every time need reload commands). more information on how occurs here:

http://www.zeroturnaround.com/blog/rjc201/

if have not already, should take @ jrebel. there license fee, think may solve problem:

http://www.zeroturnaround.com/jrebel/

also, java hotswap (used java debugging api) may have hooks facilitate hot-redeploy behavior you're looking (usually available in ide environments).

i don't understand use case honest (why have load command classes @ runtime, , why need hot-deploy behavior).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -