Results 1 to 3 of 3
Thread: Plugin discovery
- 01-10-2011, 04:57 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
Plugin discovery
Hi all,
I've been looking around on the net for a tutorial on how to create a plugin discovery system for a java program.
I am trying to follow the example found at What is Java Reflection? | JAVA Developer's Journal
I have a simple class which implements my plugin interface.
I then want to load that plugin and be able to call those methods having dynamically loaded that class in another program.Java Code:public class Main implements IXactPlugin { String name = "Plugin1"; public static void main(String[] args) { System.out.println("Here"); Main moo = new Main(); } public Main() { process(); System.out.println(getName()); System.out.println(methods()[0].getName()); } public void process() { System.out.println("Process"); } public String getName() { return name; } public Method[] methods() { Method m[] = null; try { Class c = Class.forName(this.getClass().getName()); m = c.getDeclaredMethods(); } catch (Throwable e) { System.err.println(e); } return m; } }
Here is the code I have for the plugin loader
Problem I am having is the lineJava Code:File folder = new File("C:/Users/Ash/Documents/NetBeansProjects/PluginFramework/plugins"); File[] listOfFiles = folder.listFiles(); for ( int i = 0; i < plugInNames.length; i++ ) { MyApplicationPlugIn plugIn = (MyApplicationPlugIn)Class.classFor( plugInNames[i] ); }
It cant find the classFor method.Java Code:MyApplicationPlugIn plugIn = (MyApplicationPlugIn)Class.classFor( plugInNames[i] );
Any help would be greatly appreciated.
Kind Regards
Ash
- 01-10-2011, 05:17 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-10-2011, 05:28 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 3
- Rep Power
- 0
Thanks for the reply Jos.
I thought this might be the case.
I've changed the line as follows
But now get the compilation errorJava Code:IXactPlugin plugIn = (IXactPlugin)Class.forName( "Main" );
inconvertible types
required: pluginframework.IXactPlugin
found: java.lang.Class<capture#2 of ?>
Kind Regards
Ash
Similar Threads
-
how can one eclipse plugin access the native lib loaded by another plugin?
By xiajun_80 in forum New To JavaReplies: 0Last Post: 12-16-2010, 10:14 AM -
Discovery of peer in p2p network
By dogukan in forum NetworkingReplies: 1Last Post: 04-19-2010, 03:55 PM -
Trying to send UDP discovery packet
By JohnST in forum New To JavaReplies: 1Last Post: 12-26-2009, 07:32 PM -
Bible-Discovery 2.1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-25-2007, 04:19 PM -
AnyEdit Plugin For Eclipse Plugin
By JavaForums in forum EclipseReplies: 0Last Post: 05-18-2007, 12:28 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks