Sun GlassFish Enterprise Server v3 Prelude Add-On Component Development Guide

Implementing a Console Provider

The org.glassfish.api.admingui.ConsoleProvider interface has one required method, getConfiguration. The getConfiguration method returns the location of the console-config.xml file as a java.net.URL. If getConfiguration returns null, the default location, META-INF/admingui/console-config.xml, is used. The console-config.xml file is described in About Integration Points.

To implement the console provider for your add-on component, write a Java class that is similar to the following example.


Example 3–1 Example ConsoleProvider Implementation

This example shows a simple implementation of the ConsoleProvider interface:

package org.glassfish.admingui.plugin;

import org.glassfish.api.admingui.ConsoleProvider;
import org.jvnet.hk2.annotations.Service;

import java.net.URL;

@Service
public class SamplePlugin implements ConsoleProvider {

    public URL getConfiguration() { return null; }
}

This implementation of getConfiguration returns null to specify that the configuration file is in the default location. If you place the file in a nonstandard location or give it a name other than console-config.xml, your implementation of getConfiguration must return the URL where the file can be found.

You can find this example code in the file project/src/main/java/org/glassfish/admingui/plugin/SamplePlugin.java.