Managing a Domain’s Configuration with JMX 5-9
2.
Get the value of the ConfigurationManagerMBean UnactivatedChanges attribute and assign the output to a variable of type Object[].
3.
For each object in the array, invoke Object.toString to output a description of the change.
Because Change is a javax.management.openmbean.CompositeType, you can also cast each item in the array as a CompositeType and invoke
CompositeType methods on the change. See CompositeType in the J2SE 6.0
API Specification at http:download.oracle.comjavase6docsapijavaxmanagement
openmbeanCompositeType.html .
The code in Example 5–3
creates a method that lists unactivated changes. It assumes that the calling method has already established a connection to the Edit MBean Server.
Example 5–3 Example Method that Lists Unactivated Changes
public void listUnactivated throws Exception { ObjectName cfgMgr = ObjectName connection.getAttributeservice,
ConfigurationManager; Object[] list = Object[]connection.getAttributecfgMgr,
UnactivatedChanges; int length = int list.length;
for int i = 0; i length; i++ { System.out.printlnUnactivated changes: + list[i].toString;
} }
5.2.3 List Changes in the Current Activation Task
When you activate changes, WebLogic Server creates an instance of ActivationTaskMBean
, which contains one Change object for each change that is being activated. You can access these ActivationTaskMBeans from either of the
following:
■
The ConfigurationManagerMBean activate method returns an object name for the ActivationTaskMBean that describes the current activation task.
■
The ConfigurationManagerMBean CompletedActivationTasks attribute can potentially contain a list of all ActivationTaskMBean instances that have
been created during the current Administration Server instantiation. See Section 5.3.2, Listing All Activation Tasks Stored in Memory.
To list changes in the current activation task only:
1.
Start an edit session.
2.
Assign the output of the activate operation to an instance variable of type javax.management.ObjectName
.
3.
Get the value of the ActivationTaskMBean Changes attribute. and assign the output to a variable of type Object[].
4.
For each object in the array, invoke Object.toString to output a description of the change.
Because Change is a javax.management.openmbean.CompositeType, you can also cast each item in the array as a CompositeType and invoke
CompositeType methods on the change. See CompositeType in the J2SE 6.0
API Specification at
5-10 Developing Custom Management Utilities With JMX for Oracle WebLogic Server
http:download.oracle.comjavase6docsapijavaxmanagement openmbeanCompositeType.html
. The code in
Example 5–4 creates a method that lists all changes activated in the current
editing session. It assumes that the calling method has already established a connection to the Edit MBean Server.
Example 5–4 Example Method that Lists Changes in the Current Activation Task
public void activateAndList throws Exception {
ObjectName cfgMgr = ObjectName connection.getAttributeservice, ConfigurationManager;
ObjectName task = ObjectName connection.invokecfgMgr, activate, new Object[] { new Long120000 }, new String[] { java.lang.Long };
Object[] changes = Object[]connection.getAttributetask, Changes; int i = int changes.length;
for int i = 0; i i; i++ { System.out.printlnChanges activated: + changes[i].toString;
} }
5.2.4 Undoing Changes