org.ow2.jonas.commands.admin.util
Class JMXConnectionHelper

java.lang.Object
  extended by org.ow2.jonas.commands.admin.util.JMXConnectionHelper

public class JMXConnectionHelper
extends Object

Wrap a JMXConnector.

Author:
Guillaume Sauthier, S. Ali Tokmen

Constructor Summary
JMXConnectionHelper(JMXServiceURL url, String username, String password)
          Construct a new JMXConnectionHelper using the provided URL and credentials.
JMXConnectionHelper(JMXServiceURL url, Subject subject)
          Construct a new JMXConnectionHelper using the provided URL and Subject.
 
Method Summary
 boolean close()
          Close the underlying JMXConnector.
 boolean connect()
          Try to connect to the remote MBeanServer.
 MBeanServerConnection getConnection()
           
 Exception getLastException()
           
 JMXServiceURL getURL()
           
 void setSubject(Subject subject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXConnectionHelper

public JMXConnectionHelper(JMXServiceURL url,
                           Subject subject)
Construct a new JMXConnectionHelper using the provided URL and Subject.

Parameters:
url - MBeanServer URL
subject - Security subject

JMXConnectionHelper

public JMXConnectionHelper(JMXServiceURL url,
                           String username,
                           String password)
Construct a new JMXConnectionHelper using the provided URL and credentials.

Parameters:
url - MBeanServer URL
username - User name to use when connecting
password - Password to use when connecting
Method Detail

connect

public boolean connect()
Try to connect to the remote MBeanServer.

Returns:
true if connection was successful, false otherwise.

getLastException

public Exception getLastException()
Returns:
the last thrown Exception.

getConnection

public MBeanServerConnection getConnection()
                                    throws IOException
Returns:
an MBeanServerConnection (authenticatd with subject if not null).
Throws:
IOException - If connection fails

close

public boolean close()
Close the underlying JMXConnector.

Returns:
true if connection was successful

setSubject

public void setSubject(Subject subject)
Parameters:
subject - the subject to set

getURL

public JMXServiceURL getURL()
Returns:
the JMXServiceURL connection URL


Copyright © 2010 OW2 Consortium. All Rights Reserved.