Portlet and PortletApplication MBeans

 

+

Search Tips   |   Advanced Search

 

Overview

The MBeans of type portlet and portletapplication provide information about a given portlet application and its portlets. Through the MBean of type portletapplication, you can retrieve a list of names of all portlets that belong to a portlet application. By querying the MBean of type portlet with a given portlet name, you can retrieve portlet specific information from the MBean of type portlet.

Each MBean that corresponds to a portlet or portlet application is uniquely identifiable by its name. Portlet applications are not required to have a name set within the portlet.xml. Thus for MBeans of type portletapplication, the Web module name concatenated with the string "_portletapplication" has been chosen as the MBean name. The name chosen for the MBean of type portlet is the name of the MBean of type portletapplication the portlet belongs to, concatenated with the porlet name. A full stop separates the preceding Web module name from the portlet name.

The generated API documentation is available in the information center table of contents from the path,...

Reference | Administrator | API documentation | MBean interfaces

 

Example

The following code is an example of how to invoke the MBean of type portletapplication for an application with the name "Bookmark".

String myPortletApplicationName = "Bookmark_war_portletapplication";
 com.ibm.websphere.management.AdminService adminService 
    = com.ibm.websphere.management.AdminServiceFactory.getAdminService();
 javax.management.ObjectName on 
    = new ObjectName("WebSphere:type=PortletApplication,name=" 
                     + myPortletApplicationName 
                     + ",*");


Iterator onIter = adminService.queryNames(on, null).iterator(); while(onIter.hasNext()) 
{
  on = (ObjectName)onIter.next();
}
    
String ctxRoot = (java.lang.String)adminService.getAttribute(on, "webApplicationContextRoot");

In the previous example, the MBeanServer is first queried for an MBean of type portletapplication. If this query is successful, the attribute...

webApplicationContextRoot

...is retrieved on that MBean or the first MBean that is found and the result is stored in the variable ctxRoot. This variable now contains the context root of the Web application that contains the portlet application that was searched. For example...

/bookmark

To invoke the MBean of type portlet for a portlet with the name "BookmarkPortlet"...

String myPortletName = "Bookmark_war_portletapplication.BookmarkPortlet";
       com.ibm.websphere.management.AdminService adminService 
    = com.ibm.websphere.management.AdminServiceFactory.getAdminService();
 javax.management.ObjectName on 
    = new ObjectName("WebSphere:type=Portlet,name=" 
                     + myPortletName 
                     + ",*");

Iterator iter = adminService.queryNames(on, null).iterator();
 while(iter.hasNext())
{ 
  on = (ObjectName)iter.next;
}
         java.util.Locale locale = (java.util.Locale) adminService.getAttribute(on, "defaultLocale");

The locale returned by the method getAttribute method for the MBean is the default locale defined for this portlet.


 

Related concepts

Portlets

 

Related tasks

Task overview: Managing portlets

 

Related information

Portlet container