views:

235

answers:

1

I am interested to learn about Eclipse RCP, I have got some basic knowledge, but I wanted to know more what it is capable of. So I encouraged my self to create a set of requirements, analyze them, and come up with design decisions about how they can be met using Eclipse RCP as the base framework, and eventually implement them with Eclipse RCP. Now, maybe the requirements are too hard or I just do not understand about Eclipse RCP much yet, I am struggling to come up with proper solutions to meet the requirements!

The following is the summary of the requirements (please excuse the probable lack of details, this is really just some example to encourage myself):

I wanted to have an Eclipse RCP application to monitor some servers. These servers will initially be programs that the application knows about (meaning it knows exactly about their ins and outs). In the future, however, the application should be able to allow users to specify arbitrary programs with different charateristics for the application to monitor as well (so not just known servers, but also some other servers that it did not know about before). The application will also require an XML configuration file that contains all of the details of the servers that need to be monitored (e.g. host, port, username, and password). This XML configuration file will be encoded and decoded using JAXB.

So based on the above requirements, I have come up with the following details:

The XML will look something like this:

<configuration>
    <components>
        <serverA>
          <host></host>
          <port></port>
          <username></username>
          <password></password>
        </serverA>
        <serverB>
          <host></host>
          <port></port>
          <username></username>
          <password></password>
        </serverB>
        <!--- this will be the place for other components specified by user -->
    </components>
</configuration>

Where and are servers that the application knows about.

In the source code, there is the following hierarchy of classes:

Component <--- Server <--- ServerA, ServerB

ServerA and ServerB descend from Server and map to and element respectively.

The point entry for the configuration is in the class called Configuration that contains a list of ServerA and a list of ServerB. Now, because the application should be able to monitor other programs that it did not know about, the XML configuration file should be extensible as well, so the Configuration class also contains a list of Object which maps to any other component specified by user in the configuration file.

Configuration.java

public class Configuration
{
   @XmlElement
    private List<ServerA> serveras;

   @XmlElement
    private List<ServerB> serverbs;

   @XmlAnyElement
    private List<Object> otherServers;
}

Now, is this something that you guys will do as well to approach the problems? I guess, I do not know, I am just confused about the requirement for the application to be able to monitor other programs specified by user. I know I set it up in the first place, but I did it having in mind saying that "this looks like something that can utilize Eclipse RCP's extension points", but now having jumped into the configuration file, I am not clear about how should the configuration file relate to the plugin.xml?

In the back of my mind, I wanted configuration file to specify the details (host, port, username, and password) of the programs that the application needs to monitor. The plugin.xml is used to specify the extension points and extensions for user-defined programs that the application also needs to monitor. So does this mean, that in the end, for the user-defined programs, users need to configure them as extensions in plugin.xml, and then specify their other details in configuration file?

Does anyone have any better idea how to approach this? Thanks. I know this is a long post.

+1  A: 

There is several ways to approach this issue. But let me give a shot to it.

You have a bunch of different servers, with different monitoring characteristics. But for your eclipse application they all must look similar.

Let's say you have an Eclipse RCP application that contains some UI to monitor a server. For this application, it shouldn't matter what the servers actually are, but there should be a common interface to connect to them.

One possibility is that you have an interface that represents the server communication protocol and then, you define an extension point in your main plugin that allows contributing implementations of the protocol. So you would then be able to create a collection of instances of some interface (Lets call it IMonitoringProtocol). This interface would contain the methods you need to display the status on the UI.

Additionally you would have an XML configuration file that lists all of the servers. One of the elements on this configuration file is the protocol to use for monitoring.

So, when you launch your application, you would instantiate all the contributed protocols, and read the configuration file. You can then find the right protocol to communicate to a server by matching the configuration entries.

This allows you to add new protocols in the future, for servers that are not known yet.

Mario Ortegón