포틀릿 및 PortletApplication MBean
유형 포틀릿과 portletapplication의 MBean은 지정된 포틀릿 애플리케이션 및 해당 포틀릿에 대한 정보를 제공합니다. 유형 portletapplication의 MBean을 통해 포틀릿 애플리케이션에 속한 모든 포틀릿의 이름 목록을 검색할 수 있습니다. 지정된 포틀릿 이름을 가진 유형 포틀릿의 MBean을 조회하여 포틀릿의 MBean에서 포틀릿 특정 정보를 검색할 수 있습니다.
포틀릿 또는 포틀릿 애플리케이션에 해당하는 각 MBean은 그 이름으로 고유하게 식별 가능합니다. 포틀릿 애플리케이션은
portlet.xml에 이름 세트가 없어도 됩니다.
portletapplication 유형의 MBean에 대한 MBean 이름은 뒤에 "#"과 문자열 "_portlet"과 연결된 웹 모듈 이름이 붙는
엔터프라이즈 아카이브(EAR) 파일 이름입니다. 예를 들어, portletapplication 유형 MBean의 형식은
다음과 같습니다.
<EarFileName>#<WarFileName>_portlet유형 포틀릿의 MBean에 선택된 이름은 이 포틀릿이 속한 유형 portletapplication의 MBean 이름이며 다음과 같이 포틀릿 이름과 연결됩니다.
<EarFileName>#<WarFileName>_portlet.<portletname>
다음은
그에 따른 PortletApplication MBean 이름 및 포틀릿 이름의 예제입니다.
EarName SampleEar
WebModule SampleWar.war
PortletApplication MBean name: SampleEar#SampleWar_portlet
Portlet: SampleEar#SampleWar_portlet.BookmarkPortlet
MBean 이름이 버전 6.1과 비교할 때 변경되었습니다.
이전 이름 지정 패턴은 고유하지 않고 특정 상황에서는 문제점을 초래할 수 있기 때문입니다. 이전 이름 지정 패턴을 따르는 경우
포틀릿 컨테이너 사용자 정의 특성 useShortMBeanNames를 true로 설정하여
이전에 알려진 MBean 이름을 활성화할 수 있습니다. 이는 성능상의 영향이기 때문에
필요하지 않은 경우 이전 이름 지정 패턴을 활성화시키지 않으려고 할 수 있습니다. 전체 중지는 포틀릿 이름에서 선행 웹 모듈 이름을 분리합니다. 추가 정보는 포틀릿 및 PortletApplication MBean 유형 API 문서를 검토하십시오. 생성된 API 문서는 다음 경로에서 목차의 Information Cneter 테이블에서 사용 가능합니다.
.다음 코드는 이름이 SampleWar인 애플리케이션에서
유형 portletapplication의 MBean을 호출하는 방법의 예제입니다.
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");
이전 예제에서
유형 portletapplication의 MBean에 대해 MBeanServer가 먼저 조회되었습니다. 이 조회에 성공하는 경우 webApplicationContextRoot
속성은 해당 MBean 또는 발견되는 첫 번째 MBean에서 검색됩니다.
결과는 ctxRoot 변수에 저장됩니다. 이제 이 변수는 검색된 포틀릿 애플리케이션을 포함하는
웹 애플리케이션의 컨텍스트 루트를 포함합니다. 이 변수는 "/bookmark"와 비슷합니다. 다음 코드 예제는
이름이 BookmarkPortlet인 포틀릿에 대한 유형 포틀릿의 MBean을 호출하는 방법을 보여줍니다.
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");
MBean에 대한
getAttribute 메소드에서 리턴되는 로케일은 이 포틀릿에 대해 정의된 기본 로케일입니다. 포틀릿 및 PortletApplication MBean의 전체 이름
MBean도
식별 가능한 전체 이름으로 등록됩니다.
<ApplicationName>#<WARfilename.war>_portlet.<portlet_name> for the Portlet MBean
<ApplicationName>#<WARfilename.war>_portlet for the PortletApplication MBean
여기서, <..>는 해당 애플리케이션 데이터로 대체됩니다. 예를 들면, 다음과 같습니다. SampleApplication#SamplePortlet.war_portlet.SamplePortlet.
useShortMBeanNames 포틀릿 컨테이너 사용자 정의 특성을 true로 설정하여 축약 MBean 이름을 사용으로 설정할 수 있습니다.