public class ConnectionImpl extends Object implements RhinoConnection, MBeanServerConnection
Implementation class for connections to Rhino.
Use the RhinoConnectionFactory to obtain instances of this class.
| Modifier | Constructor and Description |
|---|---|
protected |
ConnectionImpl(String[] hosts,
String username,
String password) |
protected |
ConnectionImpl(String[] hosts,
String username,
String password,
boolean attemptRhinoSsl) |
| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback) |
void |
addNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback) |
void |
connect()
Try to connect this connection.
|
ObjectInstance |
createMBean(String className,
ObjectName name) |
ObjectInstance |
createMBean(String className,
ObjectName name,
Object[] params,
String[] signature) |
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName) |
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName,
Object[] params,
String[] signature) |
protected void |
createMBeanServerConnection(String host,
int port,
String username,
String password) |
void |
disconnect()
Disconnect this connection.
|
Object |
getAttribute(ObjectName name,
String attribute) |
AttributeList |
getAttributes(ObjectName name,
String[] attributes) |
boolean |
getConnectedState()
Whether or not this connection is connected.
|
String |
getDefaultDomain() |
String[] |
getDomains() |
JMXConnector |
getJmxConnector()
Get the JMXConnector associated with this MBeanServer connection.
|
Integer |
getMBeanCount() |
MBeanInfo |
getMBeanInfo(ObjectName name) |
ObjectInstance |
getObjectInstance(ObjectName name) |
String |
getServerHost()
The host name of the current connection.
|
int |
getServerNodeId()
The node ID of the server the current connection is to.
|
int |
getServerPort()
The port of the current connection.
|
RhinoVersion |
getServerRhinoVersion()
The version of Rhino this connection is to.
|
Object |
invoke(ObjectName name,
String operationName,
Object[] params,
String[] signature) |
boolean |
isInstanceOf(ObjectName name,
String className) |
boolean |
isRegistered(ObjectName name) |
Set |
queryMBeans(ObjectName name,
QueryExp query) |
Set |
queryNames(ObjectName name,
QueryExp query) |
void |
reconnect()
Disconnect then connect this connection.
|
void |
removeNotificationListener(ObjectName name,
NotificationListener listener) |
void |
removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback) |
void |
removeNotificationListener(ObjectName name,
ObjectName listener) |
void |
removeNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback) |
void |
setAllowedExecutionContext(ExecutionContext ctx)
Tell this connection to only allow particular connection contexts.
|
void |
setAttribute(ObjectName name,
Attribute attribute) |
AttributeList |
setAttributes(ObjectName name,
AttributeList attributes) |
void |
setNamespace(String namespace)
Set the current Rhino namespace associated with this connection.
|
void |
testConnection()
Test this connection by invoking a basic MBean operation.
|
String |
toString() |
void |
unregisterMBean(ObjectName name) |
protected ConnectionImpl(String[] hosts, String username, String password) throws ConnectionException
ConnectionExceptionprotected ConnectionImpl(String[] hosts, String username, String password, boolean attemptRhinoSsl) throws ConnectionException
ConnectionExceptionpublic void setNamespace(String namespace)
RhinoConnectionSet the current Rhino namespace associated with this connection. This namespace will be set as the active namespace if/when the connection needs to be re-established. Note that this method only affects local state, it does not invoke the NamespaceManagementMBean in Rhino to set the current active namespace.
setNamespace in interface RhinoConnectionnamespace - the namespace.
May be null to indicate the default namespace.public void connect()
throws ConnectionException
RhinoConnectionTry to connect this connection.
connect in interface RhinoConnectionConnectionException - if the connection attempt failedpublic void disconnect()
RhinoConnectionDisconnect this connection.
disconnect in interface RhinoConnectionpublic void testConnection()
throws ConnectionException
RhinoConnectionTest this connection by invoking a basic MBean operation. If the test fails, an reconnect attempt will be triggered automatically.
testConnection in interface RhinoConnectionConnectionException - if the test failed and the attempt to automatically reconnect failed.public void reconnect()
throws ConnectionException
RhinoConnectionDisconnect then connect this connection.
reconnect in interface RhinoConnectionConnectionException - if the connection attempt failedpublic JMXConnector getJmxConnector()
RhinoConnectionGet the JMXConnector associated with this MBeanServer connection.
getJmxConnector in interface RhinoConnectionpublic boolean getConnectedState()
RhinoConnectionWhether or not this connection is connected.
getConnectedState in interface RhinoConnectionpublic String getServerHost()
RhinoConnectionThe host name of the current connection. Useful if this connection is configured to try multiple hosts.
getServerHost in interface RhinoConnectionpublic int getServerPort()
RhinoConnectionThe port of the current connection. Useful if this connection is configured to try multiple hosts.
getServerPort in interface RhinoConnectionpublic int getServerNodeId()
RhinoConnectionThe node ID of the server the current connection is to. Useful if this connection is configured to try multiple hosts.
getServerNodeId in interface RhinoConnectionpublic RhinoVersion getServerRhinoVersion()
RhinoConnectionThe version of Rhino this connection is to. Only available for Rhino versions 2.2 and above. This method returns null for versions of Rhino prior to 2.2.
getServerRhinoVersion in interface RhinoConnectionpublic void setAllowedExecutionContext(ExecutionContext ctx)
RhinoConnectionTell this connection to only allow particular connection contexts.
See ExecutionContext for more details.
setAllowedExecutionContext in interface RhinoConnectionctx - the context to allowprotected void createMBeanServerConnection(String host, int port, String username, String password) throws ConnectionException, IOException
ConnectionExceptionIOExceptionpublic ObjectInstance createMBean(String className, ObjectName name) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
createMBean in interface MBeanServerConnectionIOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionpublic ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
createMBean in interface MBeanServerConnectionIOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundExceptionpublic ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
createMBean in interface MBeanServerConnectionIOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionpublic ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
createMBean in interface MBeanServerConnectionIOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundExceptionpublic void unregisterMBean(ObjectName name) throws IOException, InstanceNotFoundException, MBeanRegistrationException
unregisterMBean in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionMBeanRegistrationExceptionpublic ObjectInstance getObjectInstance(ObjectName name) throws IOException, InstanceNotFoundException
getObjectInstance in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionpublic Set queryMBeans(ObjectName name, QueryExp query) throws IOException
queryMBeans in interface MBeanServerConnectionIOExceptionpublic Set queryNames(ObjectName name, QueryExp query) throws IOException
queryNames in interface MBeanServerConnectionIOExceptionpublic boolean isRegistered(ObjectName name) throws IOException
isRegistered in interface MBeanServerConnectionIOExceptionpublic Integer getMBeanCount() throws IOException
getMBeanCount in interface MBeanServerConnectionIOExceptionpublic Object getAttribute(ObjectName name, String attribute) throws IOException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
getAttribute in interface MBeanServerConnectionIOExceptionMBeanExceptionAttributeNotFoundExceptionInstanceNotFoundExceptionReflectionExceptionpublic AttributeList getAttributes(ObjectName name, String[] attributes) throws IOException, InstanceNotFoundException, ReflectionException
getAttributes in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionReflectionExceptionpublic void setAttribute(ObjectName name, Attribute attribute) throws IOException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
setAttribute in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionAttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionExceptionpublic AttributeList setAttributes(ObjectName name, AttributeList attributes) throws IOException, InstanceNotFoundException, ReflectionException
setAttributes in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionReflectionExceptionpublic Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws IOException, InstanceNotFoundException, MBeanException, ReflectionException
invoke in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionMBeanExceptionReflectionExceptionpublic String getDefaultDomain() throws IOException
getDefaultDomain in interface MBeanServerConnectionIOExceptionpublic String[] getDomains() throws IOException
getDomains in interface MBeanServerConnectionIOExceptionpublic void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
addNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionpublic void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
addNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionpublic void removeNotificationListener(ObjectName name, NotificationListener listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, ObjectName listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionListenerNotFoundExceptionpublic MBeanInfo getMBeanInfo(ObjectName name) throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException
getMBeanInfo in interface MBeanServerConnectionIOExceptionInstanceNotFoundExceptionIntrospectionExceptionReflectionExceptionpublic boolean isInstanceOf(ObjectName name, String className) throws IOException, InstanceNotFoundException
isInstanceOf in interface MBeanServerConnectionIOExceptionInstanceNotFoundException