org.jasig.portal.jmx
Class JavaManagementServerBean

java.lang.Object
  extended by org.jasig.portal.jmx.JavaManagementServerBean

public class JavaManagementServerBean
extends Object

A bean to make starting and stopping a JMX server easier.

The only required property is setPortOne(int), if portTwo is not set is will be calculated as portOne + 1. faileOnException is set to false buy default.

The bean heeds the following system properties:

Property Function
com.sun.management.jmxremote Having this property set (value doesn't matter) enables starting of the JMX Server
com.sun.management.jmxremote.ssl Enables SSL based connections
com.sun.management.jmxremote.password.file The password file that contains usernames and passwords for connecting to the server
com.sun.management.jmxremote.access.file The password file that contains ACLs for users connecting to the server

IMPORTNANT NOTE Using this bean starts an RMI server. If this bean is used in a JVM that is long running and has any sort of generational garbage collector configured the system properties sun.rmi.dgc.client.gcInterval and sun.rmi.dgc.server.gcInterval need to be set to some high value. They configure how often the RMI server requests a full GC. To disable the RMI induced GCs set the properties to '0x7ffffffffffffffe' Only do this if you can rely on the generational GC to reguarly clean up RMI objects.

Version:
$Revision: 19776 $
Author:
Eric Dalquist eric.dalquist@doit.wisc.edu

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
JavaManagementServerBean()
           
 
Method Summary
protected  int calculatePortTwo(int portOne)
          Get the second rmi port from the init parameters or calculate it
 String getHost()
           
protected  Map<String,Object> getJmxServerEnvironment()
          Generates the environment Map for the JMX server based on system properties
 int getPortOne()
           
 int getPortTwo()
           
protected  JMXServiceURL getServiceUrl(int portOne, int portTwo)
          Generates the JMXServiceURL for the two specified ports.
 boolean isFailOnException()
           
 void setFailOnException(boolean failOnException)
          If an exception should be thrown if setting up the JMX server fails
 void setHost(String host)
          The host to listen on
 void setPortOne(int portOne)
          First port in the JMX connection string
 void setPortTwo(int portTwo)
          Second port in the JMX connection string
 void startServer()
          Starts the RMI server and JMX connector server
 void stopServer()
          Stops the JMX connector server and RMI server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

JavaManagementServerBean

public JavaManagementServerBean()
Method Detail

isFailOnException

public boolean isFailOnException()

setFailOnException

public void setFailOnException(boolean failOnException)
If an exception should be thrown if setting up the JMX server fails


getPortTwo

public int getPortTwo()

setPortTwo

public void setPortTwo(int portTwo)
Second port in the JMX connection string


getPortOne

public int getPortOne()

setPortOne

public void setPortOne(int portOne)
First port in the JMX connection string


getHost

public String getHost()

setHost

public void setHost(String host)
The host to listen on


startServer

public void startServer()
Starts the RMI server and JMX connector server


stopServer

public void stopServer()
Stops the JMX connector server and RMI server


calculatePortTwo

protected int calculatePortTwo(int portOne)
Get the second rmi port from the init parameters or calculate it

Parameters:
portOne - Base port to calculate the second port from if needed.
Returns:
The second port

getServiceUrl

protected JMXServiceURL getServiceUrl(int portOne,
                                      int portTwo)
Generates the JMXServiceURL for the two specified ports.

Returns:
A JMXServiceURL for this host using the two specified ports.
Throws:
IllegalStateException - If localhost cannot be resolved or if the JMXServiceURL is malformed.

getJmxServerEnvironment

protected Map<String,Object> getJmxServerEnvironment()
Generates the environment Map for the JMX server based on system properties

Returns:
A non-null Map of environment settings for the JMX server.


Copyright © 2010 Jasig. All Rights Reserved.