JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 

Pluggable views

From JPPF 6.2 Documentation

Jump to: navigation, search

Contents

Main Page > Customizing JPPF > Pluggable views


1 Implementing a custom view

It is now possible to add user-defined, pluggable views views to the JPPF administration and monitoring console. A pluggable view is a class which extends the abstract class PluggableView and overrides its getUIComponent() method. PluggableView is defined as follows:

public abstract class PluggableView {
  // Get the GUI component which contains the view
  public abstract JComponent getUIComponent();
  // Get the TopologyManager associated with the administration console
  public final TopologyManager getTopologyManager()
}

The getUIComponent() method returns a JComponent, which will be added as a tab to one of the tabbed panes of the admin console. It can be any subclass of JComponent.

As an example, here is a very simple implementation that displays a single label:

public class SimpleView extends PluggableView {
  @Override
  public JComponent getUIComponent() {
    JLabel label = new JLabel("I am a JPPF pluggable view!");
    label.setFont(new Font("Arial", Font.BOLD, 36));
    JPanel panel = new JPanel();
    panel.add(label, BorderLayout.NORTH);
    return panel;
  }
}

When added to the console's main tabbed pane, it will look like this:

SimpleView.gif

The getTopologyManager() method of PluggableView allows you to have access to the JPPF grid topology, and register one or more listeners to receive notifications of changes in the topology, as seen in Development guide > Grid topology monitoring. For example, expanding from the code sample above:

public class SimpleView extends PluggableView {
  @Override
  public JComponent getUIComponent() {
    JPanel panel = new JPanel();
    JLabel label = new JLabel("I am a JPPF pluggable view!");
    label.setFont(new Font("Arial", Font.BOLD, 36));
    panel.add(label, BorderLayout.NORTH);
    getTopologyManager().addTopologyListener(new TopologyListenerAdapter() {
      @Override
      public void driverAdded(TopologyEvent e) {
        System.out.println("added driver " + e.getDriver().getDisplayName());
      }

      @Override
      public void driverRemoved(TopologyEvent e) {
        System.out.println("removed driver " + e.getDriver().getDisplayName());
      }
    });
    return panel;
  }
}

Please note that you will need the jppf-admin.jar library in your build path / class path at compile time and runtime.

2 Console integration

Integrating a pluggable view into the administration console is done with a number of configuration properties of the form:

jppf.admin.console.view.<view_name>.<atribute> = <value>

Where view_name is an arbitrary name given to the pluggable view. The possible attributes and their values are defined as follows:

# enable / disable the custom view. defaults to true (enabled)
jppf.admin.console.view.SimpleView.enabled = false
# name of a class extending org.jppf.ui.plugin.PluggableView
jppf.admin.console.view.SimpleView.class = org.jppf.example.pluggableview.SimpleView
# the title for the view
jppf.admin.console.view.SimpleView.title = simple view
# path to the icon for the view
jppf.admin.console.view.SimpleView.icon = 
# the tabbed pane the view is attached to
jppf.admin.console.view.SimpleView.addto = Main
# the position at which the custom view is inserted withing the enclosing tabbed pane
# a negative value means insert at the end; defaults to -1 (insert at the end)
jppf.admin.console.view.SimpleView.position = -1
# whether to automatically select the view; defaults to false
jppf.admin.console.view.SimpleView.autoselect = true

Since the view can only be attached to a tabbed pane, the possible values for the "addto" attribute are:

  • Main: the main tabbed pane which contains all administration and monitoring views
  • Topology: the tabbed pane containing all topology views
  • Charts: the tabbed pane which contains the user-defined charts and the charts configuration view

3 Related sample

The events log view demo provides a complete and nice looking example of a pluggable view.

Main Page > Customizing JPPF > Pluggable views



JPPF Copyright © 2005-2020 JPPF.org Powered by MediaWiki