Java Reference
In-Depth Information
public int getLogLevel()
{
return logLevel;
}
public String retrieveLog( int linesback )
{
//implementation here
return null;
}
public void writeLog( String message, int type )
{
try
{
if( type <= logLevel )
out.println( message );
}
catch( Exception e )
{
e.printStackTrace();
}
}
}//class
Breaking applications into components as Standard MBeans is a valuable develop-
ment advantage. In this manner, you can keep the interfaces between components
stable, and shield the application from the implementation of specific functionality.
Once the implementation is hidden, changing it will not impact the application.
For example, if an application was using a logging MBean like the previous exam-
ple, the logging implementation could persist messages to a file or a database. Nei-
ther method affects how an application would access its logging functionality.
4.4.3
MBeans using other MBeans
In the past two sections, we have discussed using Standard MBeans to compo-
nentize and configure your applications. We presented each of these concepts
with a single MBean: you used an MBean to manage a property set that an appli-
cation could use to access application settings, and you also used an MBean to
handle an application's logging functionality.
You have created an application that uses MBeans to handle its configura-
tion and certain components. However, as part of the application, the MBean
components should have access to the configuration of the application. In this
scenario, your MBean components need access to another MBean. Figure 4.9
illustrates this concept using the Logger MBean and PropertyManager MBean.
Search WWH ::




Custom Search