• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically loading a class  RSS feed

 
siva mail
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anybody tell me when we will load a class dynamically(by useing Class.forname) in a application?

why can't we prefer always by creating a instance to a class instead of dynamically loading?

Thanks in advance
Siva
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used dynamic loading to add new functions to a service without:
1. stop service
2. recompile source
3. copy to server
4. start service

Instead the steps are:
1. copy new class to server
2. notify application that new class exists

Bill
Note there is a substantial learning curve to dynamic loading and calling methods in the new class.
 
siva mail
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you explain bit more clear with example

your help is highly appreciated

thanks
siva
 
Marky Vasconcellos
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a static block in the class who you want to load.

When you don't know what class will implement. And load it from a String and cast it to something useful.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any example would be a bit bulky for this forum, and would not really help a beginner.

Instead, take a look at this Wikipedia entry for a brief survey.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!