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.
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".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.<ApplicationName>#<WARfilename.war>_portlet.<portlet_name> for the Portlet MBean <ApplicationName>#<WARfilename.war>_portlet for the PortletApplication MBeanwhere <..> 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.