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.