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.
<EarFileName>#<WarFileName>_portletThe name chosen for the MBean of type portlet is the name of the MBean of type portletapplication that the portlet belongs to, concatenated with the portlet name:
<EarFileName>#<WarFileName>_portlet.<portletname>
EarName SampleEar WebModule SampleWar.war PortletApplication MBean name: SampleEar#SampleWar_portlet Portlet: SampleEar#SampleWar_portlet.BookmarkPortletThe MBean names have been changed compared to version 6.1, because the old naming patterns are not unique and can lead to problems under certain circumstances. If you rely on the old naming pattern, you can set the portlet container custom property, useShortMBeanNames, to true to activate the previous known MBean names. Because this is a performance impact, you might not want to activate the old naming pattern if it is not necessary.
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 > Administrator > API documentation > MBean interfaces.
String myPortletApplicationName = "SampleEar#SampleWar_portlet";
This name is composed by the Ear file name followed by "#" and
the Web module name concatenated with the substring "_portlet"
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 = "SampleEar#SampleWar_portlet.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. You can enable the short MBean names by setting the useShortMBeanNames portlet container custom property to true.