A Weblogic Admin Console with a dynamic look and feel

In my previous post i explained how to build your a custom look and feel for the Weblogic Administration Console, which is a result of research into a possibility to distinguish Weblogic Consoles in DTAP environments. My initial plan was to develop a separate look and feel for each specific environment, simply because i did not know what the possibilities were. I quickly abandoned this plan and developed one Weblogic Admin Console look and feel which adapts itself to the environment wherein it is deployed.

At most sites there is a way to determine if your host is running in a Development, Test, Acceptation or Production environment. The key data used to differentiate these environments depends on the infrastructure. It can be for example the IP-address, DNS name or Weblogic Domain name. A customer for example has standardized the weblogic domain names in such a way that the first position of the domain name corresponds with the environment. A Weblogic Development domain therefore always starts with a ‘D’, test with ‘T’, etc.  In this article i will show you how to make the Weblogic Console adapt its look and feel based on the Weblogic Domain name.

The Weblogic Admin Console login page is defined in /login/LoginForm.jsp which imports the MBeanUtils.class file. This class contains a lot of valuable methods. One of those methods, getDomainName() returns as it says the name of the Weblogic Domain. Simply by adding the following single line of Java as a JSP expression to LoginForm.jsp gives you the Weblogic domain name for which the Admin Console is opened.

With this and some additional Java code you can change the look and feel of the Weblogic. The example below shows how to set the value Java Strings envIndication and envCssColor.

Now the values of the Java String envIndication and envCssColor can be set as a session scoped variables so it can be accessed from any JSP during this session.

By adding the following lines of HTML on a self chosen location in LoginForm.jsp the environment name will be displayed on the Weblogic Console login page.

The same can be displayed in the header of the Weblogic Console by adding the following HTML in the div with id global-links of header.jsp

When putting this all in place the Weblogic Admin Console can look similar to the examples below.

A Netbeans project containing the sources of the customized look and feel as presented in the examples above can be downloaded here. A ready to deploy war-file can be found in the dist folder. Copy the war file to the console-ext directory of your weblogic domain and restart the Managed Server to execute the example look and feel. The Weblogic Admin Console look and feel can be reverted by removing the file from the console-ext directory and restarting the Managed Server.

In the example is some extra code to show more possibilities when extending the Weblogic Admin Console. The main part of the extra code is a few lines of Java in a JSP expression of LoginForm.jsp. Here a MBeanServerConnection is made using the available methods in MBeanUtils. An advantage of using the methods in MBeanUtils is that the username and password are stored (cached) a an attribute. Therefore the cached user credentials can be used for establishing the connection without having to access the credentials themselves. After a successful connection the ServerRuntimeMBeans are retrieved to get a list of all Managed Servers and their state. Because cached credentials are used this information can only be retrieved after the user is logged in.

The following few lines of JSTL and HTML will generate a list of the servers and their state. Again, due to the fact that cached credentials are used, this information is only shown when the user has logged on once and logged off again.

An example how this can be presented is shown below.

 

 

 

 

 

 

 

 

 

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: