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 theRhinoConnectionFactory
to obtain instances of this class.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectionImpl(String[] hosts, String username, String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
void
addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
void
close()
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)
-
-
-
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:RhinoConnection
Set 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:
setNamespace
in interfaceRhinoConnection
- Parameters:
namespace
- the namespace. May benull
to indicate the default namespace.
-
connect
public void connect() throws ConnectionException
Description copied from interface:RhinoConnection
Try to connect this connection.- Specified by:
connect
in interfaceRhinoConnection
- Throws:
ConnectionException
- if the connection attempt failed
-
disconnect
public void disconnect()
Description copied from interface:RhinoConnection
Disconnect this connection.- Specified by:
disconnect
in interfaceRhinoConnection
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
testConnection
public void testConnection() throws ConnectionException
Description copied from interface:RhinoConnection
Test this connection by invoking a basic MBean operation. If the test fails, an reconnect attempt will be triggered automatically.- Specified by:
testConnection
in interfaceRhinoConnection
- Throws:
ConnectionException
- if the test failed and the attempt to automatically reconnect failed.
-
reconnect
public void reconnect() throws ConnectionException
Description copied from interface:RhinoConnection
Disconnect then connect this connection.- Specified by:
reconnect
in interfaceRhinoConnection
- Throws:
ConnectionException
- if the connection attempt failed
-
getJmxConnector
public JMXConnector getJmxConnector()
Description copied from interface:RhinoConnection
Get the JMXConnector associated with this MBeanServer connection.- Specified by:
getJmxConnector
in interfaceRhinoConnection
- Returns:
- a JMXConnector instance
-
getConnectedState
public boolean getConnectedState()
Description copied from interface:RhinoConnection
Whether or not this connection is connected.- Specified by:
getConnectedState
in interfaceRhinoConnection
- Returns:
- state of the connection
-
getServerHost
public String getServerHost()
Description copied from interface:RhinoConnection
The host name of the current connection. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerHost
in interfaceRhinoConnection
- Returns:
- host where this connection object is currently connected to Rhino
-
getServerPort
public int getServerPort()
Description copied from interface:RhinoConnection
The port of the current connection. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerPort
in interfaceRhinoConnection
- Returns:
- port where this connection object is currently connected to Rhino
-
getServerNodeId
public int getServerNodeId()
Description copied from interface:RhinoConnection
The node ID of the server the current connection is to. Useful if this connection is configured to try multiple hosts.- Specified by:
getServerNodeId
in interfaceRhinoConnection
- Returns:
- node id of Rhino where this connection object is currently connected to
-
getServerRhinoVersion
public RhinoVersion getServerRhinoVersion()
Description copied from interface:RhinoConnection
The 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:
getServerRhinoVersion
in interfaceRhinoConnection
- Returns:
- Rhino version
-
setAllowedExecutionContext
public void setAllowedExecutionContext(ExecutionContext ctx)
Description copied from interface:RhinoConnection
Tell this connection to only allow particular connection contexts. SeeExecutionContext
for more details.- Specified by:
setAllowedExecutionContext
in interfaceRhinoConnection
- Parameters:
ctx
- the context to allow
-
createMBeanServerConnection
protected void createMBeanServerConnection(String host, int port, String username, String password) throws ConnectionException, IOException
- Throws:
ConnectionException
IOException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
- Specified by:
createMBean
in interfaceMBeanServerConnection
- Throws:
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
- Specified by:
createMBean
in interfaceMBeanServerConnection
- Throws:
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
- Specified by:
createMBean
in interfaceMBeanServerConnection
- Throws:
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
-
createMBean
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
- Specified by:
createMBean
in interfaceMBeanServerConnection
- Throws:
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException
-
unregisterMBean
public void unregisterMBean(ObjectName name) throws IOException, InstanceNotFoundException, MBeanRegistrationException
- Specified by:
unregisterMBean
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
MBeanRegistrationException
-
getObjectInstance
public ObjectInstance getObjectInstance(ObjectName name) throws IOException, InstanceNotFoundException
- Specified by:
getObjectInstance
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
-
queryMBeans
public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
- Specified by:
queryMBeans
in interfaceMBeanServerConnection
- Throws:
IOException
-
queryNames
public Set queryNames(ObjectName name, QueryExp query) throws IOException
- Specified by:
queryNames
in interfaceMBeanServerConnection
- Throws:
IOException
-
isRegistered
public boolean isRegistered(ObjectName name) throws IOException
- Specified by:
isRegistered
in interfaceMBeanServerConnection
- Throws:
IOException
-
getMBeanCount
public Integer getMBeanCount() throws IOException
- Specified by:
getMBeanCount
in interfaceMBeanServerConnection
- Throws:
IOException
-
getAttribute
public Object getAttribute(ObjectName name, String attribute) throws IOException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
- Specified by:
getAttribute
in interfaceMBeanServerConnection
- Throws:
IOException
MBeanException
AttributeNotFoundException
InstanceNotFoundException
ReflectionException
-
getAttributes
public AttributeList getAttributes(ObjectName name, String[] attributes) throws IOException, InstanceNotFoundException, ReflectionException
- Specified by:
getAttributes
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ReflectionException
-
setAttribute
public void setAttribute(ObjectName name, Attribute attribute) throws IOException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
- Specified by:
setAttribute
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
-
setAttributes
public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws IOException, InstanceNotFoundException, ReflectionException
- Specified by:
setAttributes
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ReflectionException
-
invoke
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws IOException, InstanceNotFoundException, MBeanException, ReflectionException
- Specified by:
invoke
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
MBeanException
ReflectionException
-
getDefaultDomain
public String getDefaultDomain() throws IOException
- Specified by:
getDefaultDomain
in interfaceMBeanServerConnection
- Throws:
IOException
-
getDomains
public String[] getDomains() throws IOException
- Specified by:
getDomains
in interfaceMBeanServerConnection
- Throws:
IOException
-
addNotificationListener
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
- Specified by:
addNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
-
addNotificationListener
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
- Specified by:
addNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, NotificationListener listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, ObjectName listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ListenerNotFoundException
-
removeNotificationListener
public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
- Specified by:
removeNotificationListener
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
ListenerNotFoundException
-
getMBeanInfo
public MBeanInfo getMBeanInfo(ObjectName name) throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException
- Specified by:
getMBeanInfo
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
IntrospectionException
ReflectionException
-
isInstanceOf
public boolean isInstanceOf(ObjectName name, String className) throws IOException, InstanceNotFoundException
- Specified by:
isInstanceOf
in interfaceMBeanServerConnection
- Throws:
IOException
InstanceNotFoundException
-
-