plugin base application

Discussion in 'Java' started by sebek, Jul 26, 2005.

  1. sebek

    sebek Guest

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

    Thanks
     
    sebek, Jul 26, 2005
    #1
    1. Advertising

  2. Hi,

    sebek wrote:
    > 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
     
    Ingo R. Homann, Jul 26, 2005
    #2
    1. Advertising

  3. sebek

    sebek Guest

    thanks, and do you know how it is in eclipse? there are xml files
     
    sebek, Jul 26, 2005
    #3
  4. Hi,

    sebek wrote:
    > 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
     
    Ingo R. Homann, Jul 26, 2005
    #4
  5. sebek

    Guest

    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
     
    , Jul 27, 2005
    #5
  6. Hi,

    wrote:
    > 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
     
    Ingo R. Homann, Jul 27, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page