Package com.opencloud.slee.remote
Class ConnectionImpl
- java.lang.Object
-
- com.opencloud.slee.remote.ConnectionImpl
-
- All Implemented Interfaces:
RhinoConnection,Closeable,AutoCloseable,MBeanServerConnection
public class ConnectionImpl extends Object implements RhinoConnection, MBeanServerConnection, Closeable
Implementation class for connections to Rhino. Use theRhinoConnectionFactoryto obtain instances of this class.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedConnectionImpl(String[] hosts, String username, String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)voidaddNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)voidclose()voidconnect()Try to connect this connection.ObjectInstancecreateMBean(String className, ObjectName name)ObjectInstancecreateMBean(String className, ObjectName name, Object[] params, String[] signature)ObjectInstancecreateMBean(String className, ObjectName name, ObjectName loaderName)ObjectInstancecreateMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)protected voidcreateMBeanServerConnection(String host, int port, String username, String password)voiddisconnect()Disconnect this connection.ObjectgetAttribute(ObjectName name, String attribute)AttributeListgetAttributes(ObjectName name, String[] attributes)booleangetConnectedState()Whether or not this connection is connected.StringgetDefaultDomain()String[]getDomains()JMXConnectorgetJmxConnector()Get the JMXConnector associated with this MBeanServer connection.IntegergetMBeanCount()MBeanInfogetMBeanInfo(ObjectName name)ObjectInstancegetObjectInstance(ObjectName name)StringgetServerHost()The host name of the current connection.intgetServerNodeId()The node ID of the server the current connection is to.intgetServerPort()The port of the current connection.RhinoVersiongetServerRhinoVersion()The version of Rhino this connection is to.Objectinvoke(ObjectName name, String operationName, Object[] params, String[] signature)booleanisInstanceOf(ObjectName name, String className)booleanisRegistered(ObjectName name)SetqueryMBeans(ObjectName name, QueryExp query)SetqueryNames(ObjectName name, QueryExp query)voidreconnect()Disconnect then connect this connection.voidremoveNotificationListener(ObjectName name, NotificationListener listener)voidremoveNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)voidremoveNotificationListener(ObjectName name, ObjectName listener)voidremoveNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)voidsetAllowedExecutionContext(ExecutionContext ctx)Tell this connection to only allow particular connection contexts.voidsetAttribute(ObjectName name, Attribute attribute)AttributeListsetAttributes(ObjectName name, AttributeList attributes)voidsetNamespace(String namespace)Set the current Rhino namespace associated with this connection.voidtestConnection()Test this connection by invoking a basic MBean operation.StringtoString()voidunregisterMBean(ObjectName name)
-
-
-
Constructor Detail
-
ConnectionImpl
protected ConnectionImpl(String[] hosts, String username, String password) throws ConnectionException
- Throws:
ConnectionException
-
-
Method Detail
-
setNamespace
public void setNamespace(String namespace)
Description copied from interface: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.- Specified by:
setNamespacein interfaceRhinoConnection- Parameters:
namespace- the namespace. May benullto indicate the default namespace.
-
connect
public void connect() throws ConnectionExceptionDescription copied from interface:RhinoConnectionTry to connect this connection.- Specified by:
connectin interfaceRhinoConnection- Throws:
ConnectionException- if the connection attempt failed
-
disconnect
public void disconnect()
Description copied from interface:RhinoConnectionDisconnect this connection.- Specified by:
disconnectin interfaceRhinoConnection
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
testConnection
public void testConnection() throws ConnectionExceptionDescription copied from interface:RhinoConnectionTest this connection by invoking a basic MBean operation. If the test fails, an reconnect attempt will be triggered automatically.- Specified by:
testConnectionin interfaceRhinoConnection- Throws:
ConnectionException- if the test failed and the attempt to automatically reconnect failed.
-
reconnect
public void reconnect() throws ConnectionExceptionDescription copied from interface:RhinoConnectionDisconnect then connect this connection.- Specified by:
reconnectin interfaceRhinoConnection- Throws:
ConnectionException- if the connection attempt failed
-
getJmxConnector
public JMXConnector getJmxConnector()
Description copied from interface:RhinoConnectionGet the JMXConnector associated with this MBeanServer connection.- Specified by:
getJmxConnectorin interfaceRhinoConnection- Returns:
- a JMXConnector instance
-
getConnectedState
public boolean getConnectedState()
Description copied from interface:RhinoConnectionWhether or not this connection is connected.- Specified by:
getConnectedStatein interfaceRhinoConnection- Returns:
- state of the connection
-
getServerHost
public String getServerHost()
Description copied from interface:RhinoConnectionThe host name of the current connection. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerHostin interfaceRhinoConnection- Returns:
- host where this connection object is currently connected to Rhino
-
getServerPort
public int getServerPort()
Description copied from interface:RhinoConnectionThe port of the current connection. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerPortin interfaceRhinoConnection- Returns:
- port where this connection object is currently connected to Rhino
-
getServerNodeId
public int getServerNodeId()
Description copied from interface:RhinoConnectionThe node ID of the server the current connection is to. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerNodeIdin interfaceRhinoConnection- Returns:
- node id of Rhino where this connection object is currently connected to
-
getServerRhinoVersion
public RhinoVersion getServerRhinoVersion()
Description copied from interface: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.- Specified by:
getServerRhinoVersionin interfaceRhinoConnection- Returns:
- Rhino version
-
setAllowedExecutionContext
public void setAllowedExecutionContext(ExecutionContext ctx)
Description copied from interface:RhinoConnectionTell this connection to only allow particular connection contexts. SeeExecutionContextfor more details.- Specified by:
setAllowedExecutionContextin interfaceRhinoConnection- Parameters:
ctx- the context to allow
-
createMBeanServerConnection
protected void createMBeanServerConnection(String host, int port, String username, String password) throws ConnectionException, IOException
- Throws:
ConnectionExceptionIOException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
- Specified by:
createMBeanin interfaceMBeanServerConnection- Throws:
IOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
- Specified by:
createMBeanin interfaceMBeanServerConnection- Throws:
IOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
- Specified by:
createMBeanin interfaceMBeanServerConnection- Throws:
IOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
- Specified by:
createMBeanin interfaceMBeanServerConnection- Throws:
IOExceptionReflectionExceptionInstanceAlreadyExistsExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundException
-
unregisterMBean
public void unregisterMBean(ObjectName name) throws IOException, InstanceNotFoundException, MBeanRegistrationException
- Specified by:
unregisterMBeanin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionMBeanRegistrationException
-
getObjectInstance
public ObjectInstance getObjectInstance(ObjectName name) throws IOException, InstanceNotFoundException
- Specified by:
getObjectInstancein interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundException
-
queryMBeans
public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
- Specified by:
queryMBeansin interfaceMBeanServerConnection- Throws:
IOException
-
queryNames
public Set queryNames(ObjectName name, QueryExp query) throws IOException
- Specified by:
queryNamesin interfaceMBeanServerConnection- Throws:
IOException
-
isRegistered
public boolean isRegistered(ObjectName name) throws IOException
- Specified by:
isRegisteredin interfaceMBeanServerConnection- Throws:
IOException
-
getMBeanCount
public Integer getMBeanCount() throws IOException
- Specified by:
getMBeanCountin interfaceMBeanServerConnection- Throws:
IOException
-
getAttribute
public Object getAttribute(ObjectName name, String attribute) throws IOException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
- Specified by:
getAttributein interfaceMBeanServerConnection- Throws:
IOExceptionMBeanExceptionAttributeNotFoundExceptionInstanceNotFoundExceptionReflectionException
-
getAttributes
public AttributeList getAttributes(ObjectName name, String[] attributes) throws IOException, InstanceNotFoundException, ReflectionException
- Specified by:
getAttributesin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionReflectionException
-
setAttribute
public void setAttribute(ObjectName name, Attribute attribute) throws IOException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
- Specified by:
setAttributein interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionAttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionException
-
setAttributes
public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws IOException, InstanceNotFoundException, ReflectionException
- Specified by:
setAttributesin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionReflectionException
-
invoke
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws IOException, InstanceNotFoundException, MBeanException, ReflectionException
- Specified by:
invokein interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionMBeanExceptionReflectionException
-
getDefaultDomain
public String getDefaultDomain() throws IOException
- Specified by:
getDefaultDomainin interfaceMBeanServerConnection- Throws:
IOException
-
getDomains
public String[] getDomains() throws IOException
- Specified by:
getDomainsin interfaceMBeanServerConnection- Throws:
IOException
-
addNotificationListener
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
- Specified by:
addNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundException
-
addNotificationListener
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
- Specified by:
addNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, NotificationListener listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, ObjectName listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListenerin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionListenerNotFoundException
-
getMBeanInfo
public MBeanInfo getMBeanInfo(ObjectName name) throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException
- Specified by:
getMBeanInfoin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundExceptionIntrospectionExceptionReflectionException
-
isInstanceOf
public boolean isInstanceOf(ObjectName name, String className) throws IOException, InstanceNotFoundException
- Specified by:
isInstanceOfin interfaceMBeanServerConnection- Throws:
IOExceptionInstanceNotFoundException
-
-