List Unsaved Changes List Unactivated Changes

5-8 Developing Custom Management Utilities With JMX for Oracle WebLogic Server

5.2.1 List Unsaved Changes

For each change that you make to an MBean attribute, WebLogic Server creates a Change object which contains information about the change. You can access these objects from the ConfigurationManagerMBean Changes attribute until you save the changes. See ConfigurationManagerMBean in Oracle WebLogic Server MBean Reference. Any unsaved changes are discarded when your edit session ends. To list unsaved changes: 1. Start an edit session and change at least one MBean attribute. 2. Get the value of the ConfigurationManagerMBean Changes 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–2 creates a method that lists unsaved changes. It assumes that the calling method has already established a connection to the Edit MBean Server. Example 5–2 Example Method that Lists Unsaved Changes public void listUnsaved throws Exception { ObjectName cfgMgr = ObjectName connection.getAttributeservice, ConfigurationManager; Object[] list = Object[]connection.getAttributecfgMgr, Changes; int length = int list.length; for int i = 0; i length; i++ { System.out.printlnUnsaved change: + list[i].toString; } }

5.2.2 List Unactivated Changes

When anyone saves changes, WebLogic Server persists the changes in the pending configuration files. The changes remain in these files, even across multiple editing sessions, unless a user who has started an edit session invokes the ConfigurationManagerMBean undoUnactivatedChanges operation, which reverts all unactivated changes from the pending files. The ConfigurationManagerMBean UnactivatedChanges attribute contains Change objects for both unsaved changes and changes that have been saved but not activated. There is no attribute that contains only saved but unactivated changes. See ConfigurationManagerMBean Unactivated Changes in Oracle WebLogic Server MBean Reference. To list changes that you have saved in the current editing session but not activated, or changes that your or others have saved in previous editing sessions but not activated: 1. Start an edit session and change at least one MBean attribute. 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