6-14 Developing Custom Management Utilities With JMX for Oracle WebLogic Server
logger.debuge; return mapping.findForwardcreate.new.admin;
} }
try { mBeanServerConnection.invoke
userEditor, addMemberToGroup, new Object[] {Administrators, user.getUsername},
new String [] {java.lang.String, java.lang.String} ;
mBeanServerConnection.invoke userEditor, addMemberToGroup,
new Object[] {MedRecAdmins, user.getUsername}, new String [] {java.lang.String, java.lang.String}
; } catch MBeanException ex {
Exception e = ex.getTargetException; if e instanceof NameNotFoundException {
logger.infoInvalid Group Name.; ex.printStackTrace;
return mapping.findForwardcreate.new.admin; } else {
logger.debuge; return mapping.findForwardcreate.new.admin;
} }
logger.infoMedRec Administrator successfully created.; return mapping.findForwardcreate.new.admin.successful;
}
6.4 Modifying the Realm Configuration
While security provider MBeans handle specific aspects of security, such as authentication and authorization, two other MBeans handle general, realm-wide and
domain-wide aspects of security:
■
RealmMBean represents a security realm. JMX clients can use it to add or remove
security providers and to specify such behaviors as whether Web and EJB containers call the security framework on every access or only when security is set
in the deployment descriptors.
■
SecurityConfigurationMBean specifies domain-wide security settings such
as connection filters and URL-pattern matching behavior for security constraints, servlets, filters, and virtual-hosts in the WebApp container and external security
policies.
These two MBeans persist their data in WebLogic Server configuration files. Therefore, to modify attribute values in RealmMBean or SecurityConfigurationMBean, you
must use the Edit MBean Server and ConfigurationManagerMBean as described in Chapter 5, Managing a Domain’s Configuration with JMX.
7
Using Notifications and Monitor MBeans 7-1
7
Using Notifications and Monitor MBeans
JMX provides two ways to monitor MBeans: MBeans can emit notifications when specific events occur such as a change in an attribute value, or a special type of
MBean called a monitor MBean can poll another MBean and periodically emit notifications to describe an attribute value. You create Java classes called listeners that
listen for these notifications and respond appropriately. For example, your management utility can include a listener that receives notifications when applications
are deployed, undeployed, or redeployed.
All WebLogic Server configuration MBeans emit notifications when attribute values change, and some run-time MBeans do.
The following sections describe working with notifications and listeners:
■
Section 7.1, Best Practices: Listening Directly Compared to Monitoring
■
Section 7.2, Best Practices: Listening for WebLogic Server Events
■
Section 7.3, Best Practices: Listening or Monitoring WebLogic Server Runtime Statistics
■
Section 7.4, Listening for Notifications from WebLogic Server MBeans: Main Steps
■
Section 7.5, Using Monitor MBeans to Observe Changes: Main Steps
7.1 Best Practices: Listening Directly Compared to Monitoring
If the MBean that you want to monitor emits notifications, you can choose whether to create a listener object that listens for changes in the MBean or a monitor MBean that
periodically polls the MBean and emits notifications only when its attributes change in specific ways. The technique that you choose depends mostly on the complexity of the
situations in which you want to receive notifications.
If your requirements are simple, registering a listener directly with an MBean is the preferred technique because the MBean pushes its notifications to your listener and
you are notified of a change almost immediately. However, the base classes that you implement for a listener and optional filter
javax.management.NotificationListener and NotificationFilter provide few facilities for comparing values with thresholds and other values. See the
javax.management
package in the J2SE 6.0 API Specification at http:download.oracle.comjavase6docsapijavaxmanagementpa
ckage-summary.html .
If your notification requirements are sufficiently complex, or if you want to monitor a group of changes that are not directly associated with a single change in the value of
an MBean attribute, use a monitor MBean. See the javax.management.monitor
7-2 Developing Custom Management Utilities With JMX for Oracle WebLogic Server
package in the J2SE 6.0 API Specification at http:download.oracle.comjavase6docsapijavaxmanagementmo
nitorpackage-summary.html . The monitor MBeans provide a rich set of tools
for comparing data and sending notifications only under specific circumstances. However, the monitor periodically polls the observed MBean for changes in attribute
value and you are notified of a change only as frequently as the polling interval that you specify.
7.2 Best Practices: Listening for WebLogic Server Events