public abstract class AbstractProxyConnection extends Object implements Connection
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractProxyConnection.ProxiedChangeListener
ProxiedChangeListener provides a change listener to modify the source of
the event to the outer connection from the (inner) proxied connection.
|
COMMAND_COLLECTION, OPEN_PROP_NAME
Constructor and Description |
---|
AbstractProxyConnection(Connection proxiedConnection)
Creates a AbstractProxyConnection.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to this connection. |
void |
close()
Closes the underlying connection.
|
void |
flush() |
int |
getPendingCount()
Returns the number of messages that are pending responses from the
server.
|
protected Connection |
getProxiedConnection()
Returns the proxiedConnection value.
|
String |
getServerName()
Returns the name of a server the connection is currently connected to.
|
boolean |
isAvailable()
Returns true if the connection is open and not shutting down, false
otherwise.
|
boolean |
isIdle()
Determines if the connection is idle.
|
boolean |
isOpen()
Determines if the connection is open.
|
boolean |
isShuttingDown()
Returns true if the connection is being gracefully closed, false
otherwise.
|
protected void |
onExceptin(MongoDbException exception)
Provides the ability for derived classes to intercept any exceptions from
the underlying proxied connection.
|
void |
raiseErrors(MongoDbException exception)
Notifies the call backs for the pending and optionally the to be sent
messages that there has been an external, unrecoverable error.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChangeListener from this connection. |
void |
send(Message message1,
Message message2,
ReplyCallback replyCallback)
Sends a message on the connection.
|
void |
send(Message message,
ReplyCallback replyCallback)
Sends a message on the connection.
|
void |
shutdown(boolean force)
Notifies the connection that once all outstanding requests have been sent
and all replies received the Connection should be closed.
|
void |
waitForClosed(int timeout,
TimeUnit timeoutUnits)
Waits for the connection to become idle.
|
public AbstractProxyConnection(Connection proxiedConnection)
proxiedConnection
- The connection to forward to.public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to this connection. Events are
fired as the state of the connection changes.
Overridden to create a proxy connection if not already created and add the listener to that connection.
addPropertyChangeListener
in interface Connection
listener
- The listener for the change events.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Closeable.close()
public void flush() throws IOException
Forwards the call to the proxied Connection
.
flush
in interface Flushable
IOException
Flushable.flush()
public int getPendingCount()
Forwards the call to the proxied Connection
.
getPendingCount
in interface Connection
public String getServerName()
Overridden to forward the call to the proxied connection.
getServerName
in interface Connection
public boolean isAvailable()
Forwards the call to the proxied Connection
.
isAvailable
in interface Connection
public boolean isIdle()
Forwards the call to the proxied Connection
.
isIdle
in interface Connection
public boolean isOpen()
Forwards the call to the proxied Connection
.
isOpen
in interface Connection
public boolean isShuttingDown()
Forwards the call to the proxied Connection
.
isShuttingDown
in interface Connection
public void raiseErrors(MongoDbException exception)
Forwards the call to the proxied Connection
.
raiseErrors
in interface Connection
exception
- The error condition.public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from this connection.
Overridden to create a proxy connection if not already created and add the listener to that connection.
removePropertyChangeListener
in interface Connection
listener
- The listener for the change events.public void send(Message message1, Message message2, ReplyCallback replyCallback) throws MongoDbException
Forwards the call to the proxied Connection
.
send
in interface Connection
message1
- The first message to send on the connection.message2
- The second message to send on the connection.replyCallback
- The callback to notify of responses to the message2
.
May be null
.MongoDbException
- On an error sending the message.public void send(Message message, ReplyCallback replyCallback) throws MongoDbException
Forwards the call to the proxied Connection
.
send
in interface Connection
message
- The message to send on the connection.replyCallback
- The callback to notify of responses to the messages. May be
null
.MongoDbException
- On an error sending the message.public void shutdown(boolean force)
Forwards the call to the proxied Connection
.
shutdown
in interface Connection
force
- If true then the connection can be immediately closed as the
caller knows there are no outstanding requests to the server.public void waitForClosed(int timeout, TimeUnit timeoutUnits)
Forwards the call to the proxied Connection
.
waitForClosed
in interface Connection
timeout
- The amount of time to wait for the connection to become idle.timeoutUnits
- The units for the amount of time to wait for the connection to
become idle.protected Connection getProxiedConnection()
protected void onExceptin(MongoDbException exception)
Closes the underlying connection.
exception
- The thrown exception.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.