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
ConnectionException
protected ConnectionImpl(String[] hosts, String username, String password, boolean attemptRhinoSsl) throws ConnectionException
ConnectionException
public void setNamespace(String namespace)
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.
setNamespace
in interface RhinoConnection
namespace
- the namespace.
May be null
to indicate the default namespace.public void connect() throws ConnectionException
RhinoConnection
Try to connect this connection.
connect
in interface RhinoConnection
ConnectionException
- if the connection attempt failedpublic void disconnect()
RhinoConnection
Disconnect this connection.
disconnect
in interface RhinoConnection
public void testConnection() throws ConnectionException
RhinoConnection
Test this connection by invoking a basic MBean operation. If the test fails, an reconnect attempt will be triggered automatically.
testConnection
in interface RhinoConnection
ConnectionException
- if the test failed and the attempt to automatically reconnect failed.public void reconnect() throws ConnectionException
RhinoConnection
Disconnect then connect this connection.
reconnect
in interface RhinoConnection
ConnectionException
- if the connection attempt failedpublic JMXConnector getJmxConnector()
RhinoConnection
Get the JMXConnector associated with this MBeanServer connection.
getJmxConnector
in interface RhinoConnection
public boolean getConnectedState()
RhinoConnection
Whether or not this connection is connected.
getConnectedState
in interface RhinoConnection
public String getServerHost()
RhinoConnection
The host name of the current connection. Useful if this connection is configured to try multiple hosts.
getServerHost
in interface RhinoConnection
public int getServerPort()
RhinoConnection
The port of the current connection. Useful if this connection is configured to try multiple hosts.
getServerPort
in interface RhinoConnection
public int getServerNodeId()
RhinoConnection
The node ID of the server the current connection is to. Useful if this connection is configured to try multiple hosts.
getServerNodeId
in interface RhinoConnection
public RhinoVersion getServerRhinoVersion()
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.
getServerRhinoVersion
in interface RhinoConnection
public void setAllowedExecutionContext(ExecutionContext ctx)
RhinoConnection
Tell this connection to only allow particular connection contexts.
See ExecutionContext
for more details.
setAllowedExecutionContext
in interface RhinoConnection
ctx
- the context to allowprotected void createMBeanServerConnection(String host, int port, String username, String password) throws ConnectionException, IOException
ConnectionException
IOException
public ObjectInstance createMBean(String className, ObjectName name) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
createMBean
in interface MBeanServerConnection
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
createMBean
in interface MBeanServerConnection
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException
public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException
createMBean
in interface MBeanServerConnection
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws IOException, ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
createMBean
in interface MBeanServerConnection
IOException
ReflectionException
InstanceAlreadyExistsException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException
public void unregisterMBean(ObjectName name) throws IOException, InstanceNotFoundException, MBeanRegistrationException
unregisterMBean
in interface MBeanServerConnection
IOException
InstanceNotFoundException
MBeanRegistrationException
public ObjectInstance getObjectInstance(ObjectName name) throws IOException, InstanceNotFoundException
getObjectInstance
in interface MBeanServerConnection
IOException
InstanceNotFoundException
public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
queryMBeans
in interface MBeanServerConnection
IOException
public Set queryNames(ObjectName name, QueryExp query) throws IOException
queryNames
in interface MBeanServerConnection
IOException
public boolean isRegistered(ObjectName name) throws IOException
isRegistered
in interface MBeanServerConnection
IOException
public Integer getMBeanCount() throws IOException
getMBeanCount
in interface MBeanServerConnection
IOException
public Object getAttribute(ObjectName name, String attribute) throws IOException, MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
getAttribute
in interface MBeanServerConnection
IOException
MBeanException
AttributeNotFoundException
InstanceNotFoundException
ReflectionException
public AttributeList getAttributes(ObjectName name, String[] attributes) throws IOException, InstanceNotFoundException, ReflectionException
getAttributes
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ReflectionException
public void setAttribute(ObjectName name, Attribute attribute) throws IOException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
setAttribute
in interface MBeanServerConnection
IOException
InstanceNotFoundException
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws IOException, InstanceNotFoundException, ReflectionException
setAttributes
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ReflectionException
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws IOException, InstanceNotFoundException, MBeanException, ReflectionException
invoke
in interface MBeanServerConnection
IOException
InstanceNotFoundException
MBeanException
ReflectionException
public String getDefaultDomain() throws IOException
getDefaultDomain
in interface MBeanServerConnection
IOException
public String[] getDomains() throws IOException
getDomains
in interface MBeanServerConnection
IOException
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
addNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException
addNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
public void removeNotificationListener(ObjectName name, NotificationListener listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ListenerNotFoundException
public void removeNotificationListener(ObjectName name, ObjectName listener) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ListenerNotFoundException
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ListenerNotFoundException
public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws IOException, InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServerConnection
IOException
InstanceNotFoundException
ListenerNotFoundException
public MBeanInfo getMBeanInfo(ObjectName name) throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException
getMBeanInfo
in interface MBeanServerConnection
IOException
InstanceNotFoundException
IntrospectionException
ReflectionException
public boolean isInstanceOf(ObjectName name, String className) throws IOException, InstanceNotFoundException
isInstanceOf
in interface MBeanServerConnection
IOException
InstanceNotFoundException