plugin base application

I

Ingo R. Homann

Hi,
Hi,
can someone write me, how write plugin base application like eclipse

Pouh, that question is not very specific! And it may be a very complex
thing to do.

In short (and easy):

Define an interface (or abstract class) that declares all methods you
will need:

interface Plugin {
void doSomething();
}

Now, the spcific plugin is an implementation of that interface:

class MyPlugin implements Plugin {
void doSomthing() {
System.out.println("Hello World!");
}
}

Put all plugins/classes in a certain directory (or another resource you
can "list") and which is included in your classpath.

Let your application scan the specific plugin-directory and instantiate
the classes as follows:

String[] files=pluginDir.list();
for(String file:files) {
Plugin p=(Plugin)Class.forName(file).newInstance();
// do whatever you want with the plugin, e.g.:
p.doSomething();
}

That's the basics. The difficult thing is the definition of the
interface and how to interact between the application and the plugin.
(keywords: event listener, callback, visitor-pattern, ...)

Hth,
Ingo
 
I

Ingo R. Homann

Hi,
thanks, and do you know how it is in eclipse? there are xml files

Well, you can use XML files as well if you want so! ;-)

Sorry, but your question is very vague!

Although I do not know *exactly* how eclipse does this (whatever you
mean with "this"), but of course the plugins can be implemented in the
way that they can be configured using XML files. They may also have an
interface that defines more specifics of this configuration.

Ciao,
Ingo
 
J

joel1di1

Hy, why don't you use eclipse RCP projet to make your own application ?
Eclipse team has work a lot and nicely, so "don't re-invent the
wheel...".
++
Joe
 
I

Ingo R. Homann

Hi,

Hy, why don't you use eclipse RCP projet to make your own application ?
Eclipse team has work a lot and nicely, so "don't re-invent the
wheel...".
++
Joe

Because for some very simple solutions, the existing frameworks are
often completely oversized.

Ciao,
Ingo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top