|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.rad.remote.AbstractSerializedConnection
public abstract class AbstractSerializedConnection
This is the default IConnection
implementation. It's independent
of the communication protocol.
Field Summary | |
---|---|
static java.lang.String |
PROP_SERIALIZER
the property name for the serializer. |
Constructor Summary | |
---|---|
AbstractSerializedConnection(ISerializer pSerializer)
Creates a new instance of AbstractSerializedConnection . |
|
AbstractSerializedConnection(java.util.Properties pProperties)
Creates a new instance of AbstractSerializedConnection with
properties containing relevant information. |
Method Summary | |
---|---|
void |
addCallBackResultListener(ICallBackResultListener pListener)
Adds an ICallBackResultListener to the list of registered listeners. |
void |
addPropertyChangedListener(IConnectionPropertyChangedListener pListener)
Adds an IConnectionPropertyChangedListener to the list of registered listeners. |
java.lang.Object[] |
call(ConnectionInfo pConnectionInfo,
java.lang.String[] pObjectName,
java.lang.String[] pMethod,
java.lang.Object[][] pParams,
ICallBackListener[] pCallBack)
Calls desired methods from a remote server object. |
void |
close(ConnectionInfo pConnectionInfo)
Close the connection to the server. |
protected static ISerializer |
createSerializer(java.lang.String pClassName)
Creates the serializer from a given class name. |
protected java.lang.Throwable |
fillInStackTrace(java.lang.Throwable pThrowable)
Fills in the current call-stack in the given exception. |
protected void |
finalize()
|
abstract java.io.InputStream |
getInputStream(ConnectionInfo pConnectionInfo)
Gets the InputStream for reading the response from the
server. |
abstract java.io.OutputStream |
getOutputStream(ConnectionInfo pConnectionInfo)
Gets the OutputStream for submitting requests to the
server. |
java.util.Hashtable<java.lang.String,java.lang.Object> |
getProperties(ConnectionInfo pConnectionInfo)
Gets a clone of all connection properties. |
java.lang.Object |
getProperty(ConnectionInfo pConnectionInfo,
java.lang.String pName)
Gets a connection property. |
int |
getRetryCount()
Gets the number of retries if a communication error occurs. |
int |
getRetryInterval()
Gets the retry interval. |
protected ISerializer |
getSerializer()
Gets the current serializer. |
protected java.lang.Object |
initCall(ConnectionInfo pConnectionInfo)
Will be invoked before a call starts. |
protected boolean |
isAutoEOFEnabled()
Gets whether automatic EOF should be detected for response stream. |
boolean |
isCalling()
Gets whether a call is active. |
boolean |
isOpen(ConnectionInfo pConnectionInfo)
Checks if the connection to the server is opened. |
protected boolean |
isReadingMagicByteEnabled()
Whether this connection should read the magic byte sequence. |
boolean |
isRetryDuringAliveCheck()
Gets whether alive check should retry if a communication error occurs. |
boolean |
isRetryDuringClose()
Gets whether close should retry if a communication error occurs. |
boolean |
isRetryDuringOpen()
Gets whether open should retry if a communication error occurs. |
protected boolean |
isWritingMagicByteEnabled()
Whether this connection should write the magic byte sequence. |
void |
open(ConnectionInfo pConnectionInfo)
Opens the connection to the server. |
void |
openSub(ConnectionInfo pConnectionInfo,
ConnectionInfo pConnectionInfoSub)
Opens a new sub connection. |
protected java.lang.Throwable |
prepareAfterRetryException(java.lang.Throwable pThrowable)
Prepares the final exception after last retry. |
protected java.lang.Throwable |
prepareException(java.lang.Throwable pThrowable)
Prepares the given exception if needed. |
protected void |
releaseCall(ConnectionInfo pConnectionInfo,
java.lang.Object pInit)
Will be invoked after a call was executed, if initCall(ConnectionInfo) was successfully invoked. |
void |
removeCallBackResultListener(ICallBackResultListener pListener)
Removes an ICallBackResultListener from the list of registered listeners. |
void |
removePropertyChangedListener(IConnectionPropertyChangedListener pListener)
Removes an IConnectionPropertyChangedListener from the list of registered listeners. |
ConnectionInfo[] |
setAndCheckAlive(ConnectionInfo pConnectionInfo,
ConnectionInfo[] pSubConnections)
Sets the alive state for a connection, on the server, and validates the alive state of subconnections. |
void |
setNewPassword(ConnectionInfo pConnectionInfo,
java.lang.String pOldPassword,
java.lang.String pNewPassword)
Sets a new password for the connected user. |
void |
setProperty(ConnectionInfo pConnectionInfo,
java.lang.String pName,
java.lang.Object pValue)
Sets a connection property. |
void |
setRetryCount(int pRetryCount)
The number of retries before the connection will be marked as broken. |
void |
setRetryDuringAliveCheck(boolean pRetryAlive)
Sets whether alive check should retry if a communication error occurs. |
void |
setRetryDuringClose(boolean pRetryClose)
Sets whether close should retry if a communication error occurs. |
void |
setRetryDuringOpen(boolean pRetryOpen)
Sets whether open should retry if a communication error occurs. |
void |
setRetryInterval(int pInterval)
Sets the retry interval in milliseconds. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROP_SERIALIZER
Constructor Detail |
---|
public AbstractSerializedConnection(java.util.Properties pProperties) throws java.lang.ClassNotFoundException
AbstractSerializedConnection
with
properties containing relevant information. The supported property
keys are:
pProperties
- the properties for the connection
java.lang.ClassNotFoundException
- if the serializer is defined and could not be createdpublic AbstractSerializedConnection(ISerializer pSerializer)
AbstractSerializedConnection
.
pSerializer
- the serializer for the communication between client and server or
null to use the default serializerISerializer
,
ByteSerializer
Method Detail |
---|
public void open(ConnectionInfo pConnectionInfo) throws java.lang.Throwable
open
in interface IConnection
pConnectionInfo
- the connection information
java.lang.Throwable
- if the connection can not be establishedpublic void openSub(ConnectionInfo pConnectionInfo, ConnectionInfo pConnectionInfoSub) throws java.lang.Throwable
openSub
in interface IConnection
pConnectionInfo
- the connection information of the master connectionpConnectionInfoSub
- the connection information of the sub connection
java.lang.Throwable
- communication error, security checks, invalid method, ...public boolean isOpen(ConnectionInfo pConnectionInfo)
isOpen
in interface IConnection
pConnectionInfo
- the connection information
public void close(ConnectionInfo pConnectionInfo) throws java.lang.Throwable
close
in interface IConnection
pConnectionInfo
- the connection information
java.lang.Throwable
- if the connection can not be establishedpublic java.lang.Object[] call(ConnectionInfo pConnectionInfo, java.lang.String[] pObjectName, java.lang.String[] pMethod, java.lang.Object[][] pParams, ICallBackListener[] pCallBack) throws java.lang.Throwable
call
in interface IConnection
pConnectionInfo
- the connection informationpObjectName
- list of server object names/aliasespMethod
- method names which should be calledpParams
- parameters for the method callspCallBack
- callback listeners for asynchronous or null for synchronous calls
java.lang.Throwable
- communication error, security checks, invalid method, ...public ConnectionInfo[] setAndCheckAlive(ConnectionInfo pConnectionInfo, ConnectionInfo[] pSubConnections) throws java.lang.Throwable
setAndCheckAlive
in interface IConnection
pConnectionInfo
- the connection informationpSubConnections
- the connection information of the sub connections, for the alive validation
java.lang.Throwable
- communication error, security checks, invalid method, ...public void setProperty(ConnectionInfo pConnectionInfo, java.lang.String pName, java.lang.Object pValue) throws java.lang.Throwable
setProperty
in interface IConnection
pConnectionInfo
- the connection informationpName
- the property namepValue
- the value of the property or null
to delete the property
java.lang.Throwable
- communication error, security checks, invalid method, ...
java.lang.SecurityException
- if it's not allowed to set the propertypublic java.lang.Object getProperty(ConnectionInfo pConnectionInfo, java.lang.String pName) throws java.lang.Throwable
getProperty
in interface IConnection
pConnectionInfo
- the connection informationpName
- the property name
null
if the property is not set
java.lang.Throwable
- communication error, security checks, invalid method, ...public java.util.Hashtable<java.lang.String,java.lang.Object> getProperties(ConnectionInfo pConnectionInfo) throws java.lang.Throwable
getProperties
in interface IConnection
pConnectionInfo
- the connection information
Hashtable
with property names and values
java.lang.Throwable
- communication error, security checks, invalid method, ...public void setNewPassword(ConnectionInfo pConnectionInfo, java.lang.String pOldPassword, java.lang.String pNewPassword) throws java.lang.Throwable
setNewPassword
in interface IConnection
pConnectionInfo
- the connection informationpOldPassword
- the old passwordpNewPassword
- the new password
java.lang.Throwable
- communication error, security checks, invalid method, ...public boolean isCalling()
isCalling
in interface IConnection
true
if a call is active, false
otherwisepublic void addPropertyChangedListener(IConnectionPropertyChangedListener pListener)
IConnectionPropertyChangedListener
to the list of registered listeners.
addPropertyChangedListener
in interface IConnection
pListener
- the new property changed listener.public void removePropertyChangedListener(IConnectionPropertyChangedListener pListener)
IConnectionPropertyChangedListener
from the list of registered listeners.
removePropertyChangedListener
in interface IConnection
pListener
- the property changed listener to removepublic void addCallBackResultListener(ICallBackResultListener pListener)
ICallBackResultListener
to the list of registered listeners.
addCallBackResultListener
in interface IConnection
pListener
- the new callback result listener.public void removeCallBackResultListener(ICallBackResultListener pListener)
ICallBackResultListener
from the list of registered listeners.
removeCallBackResultListener
in interface IConnection
pListener
- the callback result listener to removepublic abstract java.io.OutputStream getOutputStream(ConnectionInfo pConnectionInfo) throws java.lang.Throwable
OutputStream
for submitting requests to the
server.
pConnectionInfo
- the connection information
java.lang.Throwable
- if it's not possible to get the output streampublic abstract java.io.InputStream getInputStream(ConnectionInfo pConnectionInfo) throws java.lang.Throwable
InputStream
for reading the response from the
server.
pConnectionInfo
- the connection information
java.lang.Throwable
- if it's not possible to get the the input streamprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
protected static ISerializer createSerializer(java.lang.String pClassName) throws java.lang.ClassNotFoundException
pClassName
- the ISerializer
implementation class
java.lang.ClassNotFoundException
- if the serializer could not be createdprotected java.lang.Object initCall(ConnectionInfo pConnectionInfo)
pConnectionInfo
- the connection info
releaseCall(ConnectionInfo, Object)
protected void releaseCall(ConnectionInfo pConnectionInfo, java.lang.Object pInit)
initCall(ConnectionInfo)
was successfully invoked.
pConnectionInfo
- the connection infopInit
- the object whic was created in initCall(ConnectionInfo)
public void setRetryCount(int pRetryCount)
pRetryCount
- the number of retriespublic int getRetryCount()
setRetryCount(int)
public void setRetryDuringOpen(boolean pRetryOpen)
pRetryOpen
- true
to retry if open failed at first attemptpublic boolean isRetryDuringOpen()
true
if open will retry if failed at first attempt, false
to throw an Exception after first attempt (immediate)public void setRetryDuringClose(boolean pRetryClose)
pRetryClose
- true
to retry if close failed at first attemptpublic boolean isRetryDuringClose()
true
if close will retry if failed at first attempt, false
to throw an Exception after first attempt (immediate)public void setRetryDuringAliveCheck(boolean pRetryAlive)
pRetryAlive
- true
to retry if alive check failed at first attemptpublic boolean isRetryDuringAliveCheck()
true
if alive check will retry if failed at first attempt, false
to throw an Exception after first attempt (immediate)public void setRetryInterval(int pInterval)
pInterval
- the intervalpublic int getRetryInterval()
setRetryInterval(int)
protected ISerializer getSerializer()
protected boolean isReadingMagicByteEnabled()
true
protected boolean isWritingMagicByteEnabled()
true
protected boolean isAutoEOFEnabled()
isReadingMagicByteEnabled()
to be enabled. The default implementation doesn't use this option (returns false
).
true
if auto EOF detection is enabled, false
otherwise.isReadingMagicByteEnabled()
,
MagicByteInputStream.MagicByteInputStream(InputStream, byte[], boolean)
protected java.lang.Throwable prepareException(java.lang.Throwable pThrowable)
pThrowable
- the original exception
protected java.lang.Throwable prepareAfterRetryException(java.lang.Throwable pThrowable)
prepareException(Throwable)
.
pThrowable
- the original exception
protected java.lang.Throwable fillInStackTrace(java.lang.Throwable pThrowable)
pThrowable
- the exception from a call
null
if given exception is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |