Administrative programs for multiple Java EE application servers
We can develop an admin client to manage multiple vendor appservers through existing MBean support in the WAS.
Existence of MBeans for stopped components
Best practice: The WAS completely implements the Java EE (Java EE) Management specification. However, some differences in details between the Java EE specification and the WAS implementation are important for you to understand when you access WAS components. These differences are important to you when you access application MBeans because we can use either the WAS programming model or the Java EE model
In the WAS model, if an MBean exists, we can assume that it is running. If an MBean does not exist, we can assume that it is stopped. Transient states between the started state and the stopped state are the same as the stopped state, which means that no MBean exists.
In the Java EE model, the MBean always exists regardless of the state of the component.
We can determine the state of a component by querying the state attribute. However, the state attribute only exists for MBeans that are state manageable, meaning that they implement the StateManageable interface. State manageable MBeans have start(), startRecursive(), and stop() operations whether these MBeans are Java EE MBeans or WAS MBeans. Additionally, the WAS defines the stateful interface. The stateful interface means that the component has a state and emits the Java EE.state.notifications method, but that the component cannot directly manage the state. For example, a Web module cannot stop itself. However, the application that contains the Web module can stop it.
Not all MBeans that have a state are state-manageable. Servlets, Java EE modules and enterprise beans, for example, are all stateful, but are not state manageable. The Java EE server is not state-manageable because no start() operation is available on a server.
The J2EEApplication MBean is an example of a state manageable MBean. When the WAS starts, each application activates a J2EEApplication MBean for itself. A J2EEApplication MBean has a Java EE type of J2EEApplication (for example, ObjectName *:*,j2eeType=J2EEApplication). If the application starts, it also activates an Application MBean with a type of Application (for example, *:*,type=Application). When the application changes state, the Application MBean is activated or deactivated. However, the J2EEApplication MBean is always activated. We can retrieve the application state changes by getting the state attribute.
The modules attribute on the J2EEApplication component returns an array of object names, one for every module in the application. The Application Server activates an MBean for each of these modules only after the appserver starts the application. The managed enterprise bean isRegistered(ObjectName) method returns false if the application, and therefore the module, is not running.
All of the attributes defined in the Java EE management spec return valid values when the managed object stops. Other attributes and operations, for example those that are specifically defined for the appserver, use the com.ibm.websphere.management.exception.ObjectNotRunningException exception if they are accessed when the object is stopped.
If we install the application while the server runs, the application installs the J2EEApplication MBean when the installation completes. Conversely, when the application uninstalls the J2EEApplication MBean, the application deactivates the MBean.
Mapping type properties
We can determine which MBeans have a j2eeType property and a WAS type property in their ObjectName property sets by going to the additional APIs documentation. Select the MBean interfaces subtopic, and then specific MBeans in the list. Look for type= and j2eeType=. You can use the type property to query for any MBeans. MBeans derived from the Java EE specification have an additional j2eeType property as part of their ObjectName property sets. We can also use the j2eeType property to query for MBeans.
Optional WAS interfaces
The EventProvider, StateManageable, and StatisticsProvider interfaces are optional interfaces that the Java EE Management spec defines. Which of the interfaces WAS implements varies from MBean to MBean. Go to the additional APIs documentation to see which interfaces WAS implements for a particular MBean. Select the MBean interfaces subtopic, and then a specific MBean in the list. Find All Parent MBeans. The interfaces that are implemented for the MBean follow All Parent MBeans. For example, the J2EEDomain MBean does not implement any of the interfaces, while the JVM MBean implements the StatisticsProvider interface.
Related tasks
Deploy and managing a custom Java admin client program with multiple Java EE appservers
Related
Additional Application Programming Interfaces (APIs)