![]() |
![]() |
e-docs > WebLogic Server > Extending the Administration Console > Extending the Administration Console |
Extending the Administration Console
|
Extending the Administration Console
This document describes how to extend the BEA WebLogic Server Administration Console. By extending the Administration Console, you can create your own console screens that appear along with the standard console pages. The following sections provide procedures for extending the console:
Overview of Extending the Administration Console
The BEA WebLogic Server Administration Console is a browser-based graphical user interface that you use to manage a WebLogic Server Domain. For more information about the Administration Console, see About the Administration Console in the Administration Console Online Help. You extend the Administration Console by adding screens and navigation elements that appear along with the supplied system Administration Console screens.
A console extension can provide functionality not included in the standard Administration console or an alternate interface for existing functionality. For example, you can use a console extension to:
Creating an Administration Console extension requires intermediate knowledge of Java programming, JavaServer Pages (JSP), HTML, and WebLogic Server Mbeans. Mbeans are Java objects used for system administration of WebLogic Server domains. For more information about WebLogic MBeans and WebLogic Server system administration infrastructure, see System Administration Infrastructure in the Administration Guide.
A complete code example of an Administration Console extension is available from the BEA dev2dev web site. Click on Sample Administration Console Extension (WLS 7.0) and then download the ConsoleExtensionExample.zip file. You will need files from this example to create your console extension.
Visual Elements of an Administration Console Extension
An Administration Console extension can contain the following visual elements, as shown in Figure 1-1:
Figure 1-1 Administration Console Visual Elements
Programmatic Elements of a Console Extension
To create a console extension, you create the following programmatic elements:
Main Steps to Create an Administration Console Extension
The following steps are required to create an Administration Console extension:
Implementing the NavTreeExtension Interface
To define your console extension, write a Java class that extends weblogic.management.console.extensibility.Extension and implements weblogic.management.console.extensibility.NavTreeExtension. For a sample of this Java class, see Sample Java Class for Implementing the NavTreeExtension Interface.
Note: If you are creating a console extension for a custom security provider, implement the weblogic.management.console.extensibility.SecurityExtension
interface instead of the weblogic.management.console.extensibility.NavTreeExtension interface. (For more information, see Writing Console Extensions for Custom Security Provider.)
Your choice of where to place the node(s) representing your console extension should be determined by the functionality of your console extension. For example, if your console extension is related to WebLogic Server instances in a domain, place your console extension node under the Servers node by associating your extension with the ServerMBean (weblogic.management.configuration.ServerMBean).
Your console extension will appear under each instance of a configured object that appears under a node. For instance, if you select the Servers node, (ServerMBean) your extension will appear under each configured server in your domain. (For a list of MBeans, see the Javadocs for the weblogic.management.congfiguration package.)
If you want your extension to appear at the top (domain) level of the navigation tree, associate your extension with the DomainMBean (weblogic.management.configuration.DomainMBean). Your extension will only appear once because only one instance of a domain is displayed in the console.
import weblogic.management.configuration.DomainMBean.
import weblogic.management.console.extensibility.
NavTreeExtension;
import weblogic.management.console.extensibility.Catalog;
import weblogic.management.console.extensibility.Extension;
import javax.servlet.jsp.PageContext;
final public class ExampleConsoleExtension extends Extension implements NavTreeExtension
public ExampleConsoleExtension() {}
In this method, test to see if the Object argument is an instance of the MBean associated with a node under which your console extension should appear. If the Object is an instance of this MBean, the method should return a URL to a JSP page that defines the behavior of the node in the navigation tree, otherwise the method should return null. For example:
public String getNavExtensionFor(Object key)
{
if (key instanceof DomainMBean) {
System.out.println(
"\nFound an instance of the DomainMbean\n");
return "domain_navlink.jsp";
}
return null;
}
In the above example, when the Administration Console constructs the node for the DomainMBean it runs this method, passing in the name of a Domain as the Object argument. Because the Object is an instance of the DomainMBean, the method returns the URL domain_navlink.jsp.
Note: If you are creating a console extension for a custom security provider, do not define the getNavExtensionFor() method. Instead, define one of the methods described under Replacing Custom Security Provider-Related Administration Console Dialog Screens Using the SecurityExtension Interface. For more information, see the Javadocs for the SecurityExtension interface.
The System.out.println statements are optional and serve only to display the message to standard out.
Setting Up the Navigation Tree
The getNavExtensionFor() method in the Java class that you wrote (as described in the Implementing the NavTreeExtension Interface) returns a URL for each console extension node that appears in the navigation tree. This URL points to a JSP that defines the behavior of this node. In this JSP, you can define:
To create a JSP that defines a navigation tree node:
<%@ taglib uri='console_extension_taglib.tld' prefix='wl' %>
<wl:extensibility-key
id='domainKey'
class='MyObjectClass' />
Where MyObjectClass is the Java class name of the object you want to access.
For more information, see <wl:extensibility-key> Tag.
The label attribute defines the displayed name of the tab. If you want to localize this name you can use the labelId attribute to look up the name in the localization catalog. For more information on localization, see Using Localization in a Console Extension.
The icon attribute points to an image file and displays the image as an icon for this node in the navigation tree. Image files for use as icons are available in the sample application, in the extension_files/images directory. (See step 1. in Packaging the Administration Console Extension.)
<wl:node
label='<%="My Console Extension"%>'
icon='/images/folder.gif'
expanded='true'>
<wl:node
label='Nested Tabs'
icon='/images/bullet.gif'
url='/dialog_domain_example.jsp'>
</wl:node>
<wl:node label='Localization Examples'
icon='/images/bullet.gif'>
</wl:node>
</wl:node>
The above code will result in the navigation tree nodes shown in Figure 1-2.
Figure 1-2 Navigation Tree Nodes
...
<wl:node
label='Localization Examples'
icon='/images/bullet.gif'>
<wl:menu
label='BEA Product Documentation'
url='http://www.oracle.com/technology/documentation/index.html'
target='_blank'/>
<wl:menu-separator/>1
<wl:menu
label='BEA home'
url='http://www.bea.com'
target='_blank'/>
</wl:node>
...
The above code creates the right-click menu shown in Figure 1-3.
Figure 1-3 Navigation Nodes with Right-Click Menu
Writing the Console Screen JSPs
The actual dialog screens generated by your console extension appear in the right pane of the Administration Console when a user clicks on your extension's node in the navigation tree. To create these screens, you write a JSP using the supplied JSP tag library. (For reference information on the tag library, see Using the Console Extension Tag Library.) The JSP that is displayed is determined by the url attribute of the <wl:node> tags in the JSP you created in the Setting Up the Navigation Tree section.
You create the dialog screens using one or more tabbed dialogs that you define using the <wl:tab> JSP tag. These tabs can also contain nested sub-tabs, but only one level of nesting is supported. Each tab has a text label that you can specify explicitly or, you can specify a label ID that you can use to look up a localized version of the tab's label in a localization catalog.
With in each tab (that is, within a pair of <wl:tab>...</wl:tab> tags) you can use JSP and HTML coding to create the functionality of your console extension. Any text that appears in these can also be localized by looking up text from a localization catalog. For more information on using localization (the ability to display your console extension in multiple languages), see Using Localization in a Console Extension.
Note: You can use a variety of programming techniques to create the user interface of your extension. These techniques are beyond the scope of this document. For more information, see:
The following procedure creates a basic JSP that displays the screen for your console extension:
<%@ taglib uri='console_extension_taglib.tld' prefix='wl' %>
<html>
<head>
<wl:stylesheet/>
</head>
<body>
<div class='content'>
<wl:dialog>
(Insert <wl:tab> statements here.)
</wl:dialog>
</div>
</body>
</html>
The <wl:stylesheet/> tag in the <head>...</head> block is optional. When included, this tag formats your text so that it is consistent with standard WebLogic Server Administration Console pages.
You can define the following attributes for each <wl:tab> tag: name, label, and labelId. Each <wl:tab> tag requires a closing (</wl:tab>) tag. For more information on using these attributes, see <wl:tab> Tag. You write the HTML and JSP code that displays the body of your console extension dialog screen within a <wl:tab> block. You can also localize the label displayed for the tab. For more information, see Localizing Tab Labels.
For example, the following code creates two top-level tabs, each containing two nested tabs (see Figure 1-4 to see how these tabs look in the console):
<wl:tab name='TopLevelTabA' label='Top Level Tab A'>
<wl:tab name='NestedTabA1' label='Nested Tab A-1'>
(Insert your JSP and/or HTML code
for displaying your console extension here.)
</wl:tab>
<wl:tab name='NestedTabA2' label='Nested Tab A-2'>
(Insert your JSP and/or HTML code
for displaying your console extension here.)
</wl:tab>
</wl:tab>
<wl:tab name='TopLevelTabB' label='Top Level Tab B'>
<wl:tab name='NestedTabB1' label='Nested Tab B-1'>
(Insert your JSP and/or HTML code
for displaying your console extension here.)
</wl:tab>
<wl:tab name='NestedTabB2' label='Nested Tab B-2'>
(Insert your JSP and/or HTML code
for displaying your console extension here.)
</wl:tab>
</wl:tab>
Note: This procedure creates a basic JSP defining a console extension. There are additional tags not shown here that supply other functionality such as localization. These tags are described in other sections.
Localizing the Administration Console Extension
The preceding main steps have omitted any discussion of localization procedures you can use to display your extension in multiple languages. The procedure to localize your console extension includes using special JSP tags, writing localization catalogs and writing the index.xml file that lists all your localization catalogs. You package the index.xml file and the catalog files in the Web Application that defines your console extension, as described in the next section, Packaging the Administration Console Extension.
For a complete discussion of localization, see Using Localization in a Console Extension.
Packaging the Administration Console Extension
You package the JSPs and Java classes for your console extension as a J2EE Web Application for deployment on the Administration Server in a WebLogic Server domain.
To package your console extension:
Copy the above files into the locations indicated as you follow these steps to package your console extension. Figure 1-5 describes the correct locations in the Web Application for these files.
Your web.xml deployment descriptor must contain the elements shown in the following example. (Substitute the name of the class you created in step 5. in Implementing the NavTreeExtension Interface for MyConsoleExtension. Be sure to include the full package name:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>
My Weblogic Console Example Extension
</display-name>
<context-param>
<param-name>weblogic.console.extension.class</param-name>
<param-value>MyConsoleExtension</param-value>
</context-param>
<taglib>
<taglib-uri>console_extension_taglib.jar</taglib-uri>
<taglib-location>
WEB-INF/console_extension_taglib.tld
</taglib-location>
</taglib>
</web-app>
You may also need to add other elements required by your console extension.
Your weblogic.xml deployment descriptor must contain the elements shown in the following example:
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA
Systems, Inc.//DTD Web Application 7.0//EN"
"http://www.bea.com/servers/wls700/dtd/weblogic700-web-jar.dtd">
<weblogic-web-app>
<session-descriptor>
<session-param>
<param-name>CookieName</param-name>
<param-value>ADMINCONSOLESESSION</param-value>
</session-param>
</session-descriptor>
</weblogic-web-app>
You may need also to add other elements required by your console extension.
Figure 1-5 Sample Directory Layout for Console Extension
+---MyConsoleExtensionWebApp
| | dialog_domain_example.jsp
| | dialog_example.jsp
| | domain_navlink.jsp
| | server_navlink.jsp
| | *.html, *.jsp
| |
| +---images
| | bullet.gif
| | smiley.gif
| | *.gif, *.jpg
| |
| \---WEB-INF
| | console_extension_taglib.tld
| | *.tld
| | web.xml
| |
| +---catalogs
| | english.xml
| | german.xml
| | index.xml;
| | japanese.xml
| |
| \---classes
| MyConsoleExtension.class
jar cvf MyConsoleExtension.war .
You can also deploy your Web Application in "exploded" format without making the .war archive file. Deploying in exploded format can be helpful while you are developing your console extension. See Deploying an Administration Console Extension.
Deploying an Administration Console Extension
After you create the Web Application containing your console extension, deploy it on the Administration Server of your WebLogic Server domain. For information on Deploying Web Applications, see WebLogic Server Deployment in Developing WebLogic Server Applications.
You must re-start the administration server after deploying the Web Application for your console extension to function. If you revised the JSPs that define the Navigation Tree nodes, you must re-start the Administration Server for the change to be reflected in the navigation tree.
After re-starting the Administration Console, if you modify any of the JSPs that define dialog screens, you can see the changes by re-deploying the Web Application. redeploy the Web Application, use the Administration Console:
Sample Java Class for Implementing the NavTreeExtension Interface
package weblogic.management.console.extensibility.example;
import javax.servlet.jsp.PageContext;
import weblogic.management.configuration.DomainMBean;
import weblogic.management.console.extensibility.Catalog;
import weblogic.management.console.extensibility.Extension;
import weblogic.management.console.extensibility.NavTreeExtension;
/**
* <p>Sample implementation for a console extension.</p>
*/
final public class ExampleConsoleExtension extends Extension implements NavTreeExtension {
// Constructor
/**
* A public constructor without arguments is required.
*/
public ExampleConsoleExtension() {}
// =============================================================
// NavTreeExtension implementation
public String getNavExtensionFor(Object key)
{
if (key instanceof DomainMBean) {
System.out.println("==\n== Found instance of DomainMbean\n==");
return "domain_navlink.jsp";
}
return null;
}
// =============================================================
// Optional Extension methods
/**
* <p>The example does not need to perform any special
* initialization work, so this method only sends out a message to
* let us know that the console found the extension.</p>
* <p>You can use this method to perform any initialization required
* by your console extension.</p>
*/
public void initialize()
{
System.out.println("==\n== Example Extension for Domain Initialized!\n==");
}
/**
* <p>Returns the name of the extension by looking it up in the
* localization catalog. it.</p>
*/
public String getName(PageContext context)
{
return Catalog.Factory.getCatalog(context).
getText("example.extension.name");
}
/**
* <p>Just provide a brief description of this extension.</p>
*/
public String getDescription(PageContext context)
{
return Catalog.Factory.getCatalog(context).
getText("example.extension.description");
}
}
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |