Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2006

Tip: Looking for answers? Try searching our database.

classloader ?

Thread view: 
ganjaman - 06 Feb 2006 10:59 GMT
hello.
sorry for my bad english... (i'm italian)
Problem
i've to build and application that uses plugin in the following way:
1.the core starts.
2.the core checks for the presences of plugin classe
3.the core call the plugin's constructor and methods.

how can i resolve this problem ?
thank in advance
Lothar Kimmeringer - 06 Feb 2006 11:04 GMT
> i've to build and application that uses plugin in the following way:
> 1.the core starts.
> 2.the core checks for the presences of plugin classe
> 3.the core call the plugin's constructor and methods.
>
> how can i resolve this problem ?

Using an URLClassLoader and Reflection.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

ganjaman - 06 Feb 2006 11:42 GMT
> Using an URLClassLoader and Reflection.

Reflection is the key
thanks a lot
Thomas Fritsch - 06 Feb 2006 11:58 GMT
> Problem
> i've to build and application that uses plugin in the following way:
You should make it a requirement that all the plug-in classes
(*) implement a common interface that you specify
(*) have a public no-arguments-constructor.

  public interface Plugin {
      ... method declarations
  }
The concrete plug-ins would be implementations of that interface
  public class MyPlugin implements Plugin {
      public MyPlugin() { }  // constructor
      ... method implementions
  }

> 1.the core starts.
> 2.the core checks for the presences of plugin classe
Get the class names of all plug-ins somehow.
For each className either do
  Class pluginClass = Class.forName(pluginClassName);
or
  Class pluginClass = yourClassLoader.loadClass(pluginClassName);

> 3.the core call the plugin's constructor and methods.
Plugin plugin = (Plugin) pluginClass.newInstance();
plugin.method(...);

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Roedy Green - 06 Feb 2006 14:18 GMT
>i've to build and application that uses plugin in the following way:
>1.the core starts.
>2.the core checks for the presences of plugin classe
>3.the core call the plugin's constructor and methods.

You might have a look at how Sun solves the problem with roll your own
CharSets, fonts, L&F and JCE, locale resource bundles

See http://mindprod.com/jgloss/encoding.html
http://mindprod.com/jgloss/font.html
http://mindprod.com/jgloss/laf.html
http://mindprod.com/jgloss/jce.html
http://mindprod.com/jgloss/internationalisation.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.