Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make Class.forName("") flexible?

Tags:

java

class

before asking, please understand that my english is not good.

I'm using Class.forName(...) class in a servlet programming. when I access the servlet, I get a row of detailed controller information from Database indicating which controller to use.

This is Class.forName(...) I coded:

Class c = Class.forName(row.getControllerInfo);
c.newInstance();

This works fine, but there's a problem, i'm using Eclipse. The problem is that when I modified the Controller file, the changed contents were not applied to the server.,,.

like image 869
user1065108 Avatar asked Nov 04 '22 10:11

user1065108


1 Answers

Probably the easiest way is not to support dynamic loading. Much better to achieve something like dynamic update by supporting multiple servers. For development, you could get around redeploy delays by using JRebel (there might be others).

If you really do want dynamic loading of classes then the answer is "class loaders". I suggest having a look at those, and come back with any specific questions.

like image 194
Tom Hawtin - tackline Avatar answered Nov 15 '22 01:11

Tom Hawtin - tackline