WebSphere Application Server Network Deployment, Version 6.1
             Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

             Personalize the table of contents and search results

Portlet and PortletApplication MBeans

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. The MBean name for MBeans of type portletapplication, is the Web module name concatenated with the string "_portletapplication". The name for a portlet type MBean is the name of the MBean of type portletapplication that the portlet belongs to, concatenated with the portlet name. A full stop separates the preceding Web module name from the portlet name. Review the Portlet and PortletApplication MBean type API documentation for additional information. The generated API documentation is available in the information center table of contents from the path, Reference > 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";
This name is composed by the Web module name concatenated with the substring "_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 webApplicationContextRoot attribute is retrieved on that MBean or the first MBean that is found. The result is stored in the ctxRoot variable. This variable now contains the context root of the Web application that contains the portlet application that was searched. The variable is similar to "/bookmark".
The next code example demonstrates how to invoke the MBean of type portlet for a portlet with the name, BookmarkPortlet.
String myPortletName = "Bookmark_war_portletapplication.BookmarkPortlet";
This name is composed by the name of the MBean of type portletapplication and 
the portlet name, separated by a full stop because the same portlet name may 
be used within different Web modules, but must be unique within the system.
    	
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.

Full names for Portlet and PortletApplication MBeans

MBeans are also registered by the full identifiable name:
<ApplicationName>#<WARfilename.war>_portlet.<portlet_name> for the Portlet MBean
<ApplicationName>#<WARfilename.war>_portlet for the PortletApplication MBean
where <..> is replaced by the corresponding application data. For example, SampleApplication#SamplePortlet.war_portlet.SamplePortlet. For performance reasons, you can disable the short MBean names by setting the useShortMBeanNames portlet container custom property to false.



Related concepts
Portlets
Related tasks
Task overview: Managing portlets
Related reference
Mbean Interfaces
Portlet container custom properties
Related information
Portlet container
Reference topic    

Terms of Use | Feedback

Last updated: Feb 25, 2009 9:32:38 AM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.multiplatform.doc/info/ae/ae/rport_mbeans.html