|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.xmlBlaster.client.protocol.AbstractCallbackExtended
org.xmlBlaster.client.XmlBlasterAccess
This is the default implementation of the java client side remote access to xmlBlaster.
It hides a client side queue, the client side dispatcher framework for polling or pinging the server and some more features.
The interface I_CallbackRaw/I_Callback/I_CallbackExtenden are enforced by AbstractCallbackExtended.
| Field Summary | |
private I_CallbackServer |
cbServer
The callback server |
private I_Queue |
clientQueue
Client side queue during connection failure |
private boolean |
connectInProgress
|
private I_ConnectionStateListener |
connectionListener
Is not null if the client wishes to be notified about connection state changes in fail safe operation |
private ConnectQos |
connectQos
|
private ConnectReturnQos |
connectReturnQos
The return from connect() |
private ContextNode |
contextNode
|
private boolean |
disconnectInProgress
|
private DispatchManager |
dispatchManager
The dispatcher framework |
private FileDumper |
fileDumper
|
private boolean |
firstWarn
|
private boolean |
isValid
this I_XmlBlasterAccess is valid until a 'leaveServer' invocation is done. |
private long |
jmxPublicSessionId
|
private static java.util.logging.Logger |
log
|
private JmxMBeanHandle |
mbeanHandle
My JMX registration |
private java.lang.String |
ME
|
private I_MsgErrorHandler |
msgErrorHandler
The object handling message delivery problems |
private I_PostSendListener |
postSendListener
|
private I_ClientPlugin |
secPlgn
Client side helper classes to load the authentication xml string |
private java.lang.String |
serverNodeId
The cluster node id (name) to which we want to connect, needed for nicer logging, typically null Can be set manually from outside before connect |
private Timestamp |
sessionRefreshTimeoutHandle
|
private boolean |
shutdown
|
private long |
startupTime
First call to connect() in millis |
private DispatchStatistic |
statistic
Statistic about send/received messages, can be null if there is a DispatchManager around |
private java.lang.String |
storageIdPrefix
|
(package private) StreamingCallback |
streamingCb
|
private SynchronousCache |
synchronousCache
Allow to cache updated messages for simulated synchronous access with get(). |
private UpdateDispatcher |
updateDispatcher
Handles the registered callback interfaces for given subscriptions. |
private I_Callback |
updateListener
Used to callback the clients default update() method (as given on connect()) |
| Fields inherited from class org.xmlBlaster.client.protocol.AbstractCallbackExtended |
glob, updateBulkAck |
| Constructor Summary | |
XmlBlasterAccess(Global glob)
Create an xmlBlaster accessor. |
|
XmlBlasterAccess(java.lang.String[] args)
Create an xmlBlaster accessor. |
|
| Method Summary | |
private java.lang.String |
checkQueryKeyQos(java.lang.String url,
java.lang.String qos)
|
private void |
cleanupForNewServer()
If we have reconnected to xmlBlaster and the xmlBlaster server instance is another one which does not know our session state and subscribes we need to clear all cached subscribes etc. |
ConnectReturnQos |
connect(ConnectQos qos,
I_Callback updateListener)
Login to xmlBlaster. |
ConnectReturnQos |
connect(ConnectQos qos,
I_StreamingCallback streamingUpdateListener,
boolean withQueue)
|
private void |
createDefaultCbServer()
Extracts address data from ConnectQos (or adds default if missing) and instantiate a callback server as specified in ConnectQos |
SynchronousCache |
createSynchronousCache(int size)
Setup the cache mode. |
PublishReturnQos |
createTemporaryTopic(long destroyDelay,
int historyMaxMsg)
|
PublishReturnQos |
createTemporaryTopic(TopicProperty topicProperty)
Create a temporay topic. |
boolean |
disconnect(DisconnectQos disconnectQos)
Logout from the server. |
java.lang.String |
disconnect(java.lang.String disconnectQos)
|
EraseReturnQos[] |
erase(EraseKey eraseKey,
EraseQos eraseQos)
|
EraseReturnQos[] |
erase(java.lang.String xmlKey,
java.lang.String qos)
|
MsgUnit[] |
get(GetKey getKey,
GetQos getQos)
Get synchronous messages. |
MsgUnit[] |
get(java.lang.String xmlKey,
java.lang.String qos)
|
java.lang.String |
getBuildJavaVendor()
The java vendor of the compiler. |
java.lang.String |
getBuildJavaVersion()
The compiler java version. |
java.lang.String |
getBuildTimestamp()
Returns the date when xmlBlaster client library was compiled. |
MsgUnit[] |
getCached(GetKey getKey,
GetQos getQos)
Access synchronously messages. |
I_CallbackServer |
getCbServer()
Access the callback server. |
java.lang.String |
getConnectionQueueId()
Access the unique id of my client side queue. |
long |
getConnectionQueueMaxMsgs()
How many messages are max. |
long |
getConnectionQueueNumMsgs()
How many messages are in this client side queue |
java.lang.String |
getConnectionState()
Get the connection state. |
ConnectQos |
getConnectQos()
Access the current ConnectQos |
ConnectReturnQos |
getConnectReturnQos()
Access the returned QoS of a connect() call. |
ContextNode |
getContextNode()
The unique name of this session instance. |
boolean |
getDispatcherActive()
Access the dispatcher state. |
DispatchStatistic |
getDispatchStatistic()
Access the statistic holder. |
FileDumper |
getFileDumper()
|
Global |
getGlobal()
Access the environment settings of this connection. |
java.lang.String |
getId()
Create a descriptive ME, for logging only |
java.lang.String |
getLogId()
Useful as a logging prefix. |
java.lang.String |
getLoginDate()
Get date when client logged in. |
java.lang.String |
getLoginName()
Access the login name. |
long |
getNumErase()
How many subscribe requests where send by this clients login session |
long |
getNumGet()
How many get requests where send by this clients login session |
long |
getNumPublish()
How many messages where send by this clients login session |
long |
getNumSubscribe()
How many subscribe requests where send by this clients login session |
long |
getNumUnSubscribe()
How many unsubscribe requests where send by this clients login session |
long |
getNumUpdate()
How many messages where received by this clients login session |
long |
getNumUpdateOneway()
How many oneway messages where received by this clients login session |
long |
getPingRoundTripDelay()
Measures the round trip for the last ping() invocation in milli seconds. |
static java.lang.String |
getPluginUsage(java.lang.String clazzName)
Access plugin specific usage() |
long |
getPublicSessionId()
Get the sessions public session id. |
I_Queue |
getQueue()
Enforced by interface I_ConnectionHandler |
java.lang.String |
getRevisionNumber()
Returns the xmlBlaster client library SVN version control revision number. |
long |
getRoundTripDelay()
Measures the round trip for the last remote method invocation in milli seconds. |
I_ClientPlugin |
getSecurityPlugin()
Access the client side security plugin. |
java.lang.String |
getServerNodeId()
The cluster node id (name) to which we want to connect. |
SessionName |
getSessionName()
The public session ID of this login session. |
ConnectionStateEnum |
getState()
Enforced by interface I_ConnectionHandler |
java.lang.String |
getStorageIdStr()
|
I_Callback |
getUpdateListener()
The implementation which receives the callback messages. |
long |
getUptime()
Uptime in seconds |
java.lang.String |
getVersion()
Get the xmlBlaster client library version number. |
I_CallbackServer |
initCbServer(java.lang.String loginName,
CallbackAddress callbackAddress)
Create a new instance of the desired protocol driver like CORBA or RMI driver using the plugin loader. |
private void |
initSecuritySettings(java.lang.String secMechanism,
java.lang.String secVersion)
Initializes the little client helper framework for authentication. |
java.lang.String[] |
invokeErase(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String[] |
invokeGet(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String |
invokePublish(java.lang.String key,
java.lang.String content,
java.lang.String qos)
JMX |
java.lang.String |
invokeSubscribe(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String[] |
invokeUnSubscribe(java.lang.String url,
java.lang.String qos)
JMX |
boolean |
isAlive()
Enforced by interface I_ConnectionHandler |
boolean |
isCallbackConfigured()
Check if a callback was configured, if client has passed a callback address on connect. |
boolean |
isCallbackDispatcherActive()
|
boolean |
isConnected()
Has the connect() method successfully passed? |
boolean |
isDead()
Enforced by interface I_ConnectionHandler |
boolean |
isPolling()
Enforced by interface I_ConnectionHandler |
boolean |
isShutdown()
|
java.lang.String |
leaveServer()
|
void |
leaveServer(java.util.Map map)
Leaves the connection to the server and cleans up the client side resources without making a server side disconnect. |
void |
lostConnection(XmlBlasterException xmlBlasterException)
For example called by SOCKET layer (SocketCallbackImpl.java) on EOF. |
static void |
main(java.lang.String[] args)
For testing invoke: java org.xmlBlaster.client.XmlBlasterAccess |
java.lang.String[] |
peekClientMessages(int numOfEntries)
Peek messages from client queue, they are not removed |
java.lang.String[] |
peekClientMessagesToFile(int numOfEntries,
java.lang.String path)
Peek messages from client queue and dump them to a file, they are not removed. |
void |
postSend(MsgQueueEntry[] entries)
Called after a messages is send from the client side queue, but not for oneway messages. |
PublishReturnQos |
publish(MsgUnit msgUnit)
|
PublishReturnQos[] |
publishArr(MsgUnit[] msgUnitArr)
|
void |
publishOneway(MsgUnit[] msgUnitArr)
Publish messages. |
private PublishReturnQos |
publishSingleChunk(MsgKeyData keyData,
MsgQosData chunkQosData,
byte[] buf,
int length,
boolean isLastChunk,
long count,
java.lang.Exception ex)
|
PublishReturnQos[] |
publishStream(java.io.InputStream is,
MsgKeyData keyData,
MsgQosData qosData,
int maxBufSize,
I_ReplaceContent contentReplacer)
Publishes one message in streaming manner, if the message content is too big to fit in one single chunk, the message is split in several smaller messages (called chunks) and these are published. |
private java.lang.Object |
queueMessage(MsgQueueEntry entry)
Put the given message entry into the queue |
MsgUnit[] |
receive(java.lang.String oid,
int maxEntries,
long timeout,
boolean consumable)
This method synchronously accesses maxEntries messages from any xmlBlaster server side queue. |
void |
refreshSession()
Send an event to xmlBlaster to refresh the login session life time. |
void |
registerConnectionListener(I_ConnectionStateListener connectionListener)
Register a listener to get events about connection status changes. |
I_PostSendListener |
registerPostSendListener(I_PostSendListener postSendListener)
Register a listener to get notifications when a messages is successfully send from the client side tail back queue. |
MsgUnit[] |
request(MsgUnit msgUnit,
long timeout,
int maxEntries)
Implements the blocking request/reply pattern. |
java.lang.String |
sendAdministrativeCommand(java.lang.String command)
Convenience method to send an administrative command to xmlBlaster. |
private void |
sendConnectQos()
Sends the current connectQos to xmlBlaster and stores the connectReturnQos. |
boolean |
sendingFailed(MsgQueueEntry[] entries,
XmlBlasterException exception)
Called if an asynchronous message is rejected by the server. |
void |
setCallbackDispatcherActive(boolean activate)
Switch callback dispatcher on/off. |
void |
setClientErrorHandler(I_MsgErrorHandler msgErrorHandler)
Use a specific error handler instead of the default one. |
private void |
setContextNodeId(java.lang.String nodeId)
Set my identity. |
void |
setDispatcherActive(boolean dispatcherActive)
Sets the DispachManager belonging to this session to active or inactive. |
void |
setServerNodeId(java.lang.String nodeId)
Allows to set the node name for nicer logging. |
void |
setStorageIdStr(java.lang.String prefix)
Allows to set a unique client side queue name (connection queue). |
void |
setUpdateListener(I_Callback updateListener)
Register a listener to receive the callback messages. |
private boolean |
shutdown(DisconnectQos disconnectQos)
|
private void |
startSessionRefresher()
|
SubscribeReturnQos |
subscribe(java.lang.String xmlKey,
java.lang.String qos)
|
SubscribeReturnQos |
subscribe(java.lang.String xmlKey,
java.lang.String qos,
I_Callback cb)
Subscribe to messages. |
SubscribeReturnQos |
subscribe(SubscribeKey subscribeKey,
SubscribeQos subscribeQos)
Subscribe to messages. |
SubscribeReturnQos |
subscribe(SubscribeKey subscribeKey,
SubscribeQos subscribeQos,
I_Callback cb)
This subscribe variant allows to specify a specialized callback for updated messages. |
void |
toAlive(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchManager on connection state transition. |
void |
toDead(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
java.lang.String errorText)
Call by DispatchManager on connection state transition. |
void |
toPolling(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchManager on connection state transition. |
java.lang.String |
toXml()
Dump state of this object into a XML ASCII string. |
java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
UnSubscribeReturnQos[] |
unSubscribe(java.lang.String xmlKey,
java.lang.String qos)
|
UnSubscribeReturnQos[] |
unSubscribe(UnSubscribeKey unSubscribeKey,
UnSubscribeQos unSubscribeQos)
Cancel subscription. |
java.lang.String |
update(java.lang.String cbSessionId,
UpdateKey updateKey,
byte[] content,
UpdateQos updateQos)
This is the callback method invoked from xmlBlaster delivering us a new asynchronous message. |
static java.lang.String |
usage(Global glob)
Command line usage. |
| Methods inherited from class org.xmlBlaster.client.protocol.AbstractCallbackExtended |
update, update, updateOneway, updateOneway |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static java.util.logging.Logger log
private java.lang.String ME
private ContextNode contextNode
private java.lang.String serverNodeId
private ConnectQos connectQos
private ConnectReturnQos connectReturnQos
private long jmxPublicSessionId
private I_Queue clientQueue
private DispatchManager dispatchManager
private volatile DispatchStatistic statistic
private I_MsgErrorHandler msgErrorHandler
private I_ClientPlugin secPlgn
private I_CallbackServer cbServer
private final UpdateDispatcher updateDispatcher
private I_Callback updateListener
private I_ConnectionStateListener connectionListener
private I_PostSendListener postSendListener
private SynchronousCache synchronousCache
private boolean disconnectInProgress
private boolean connectInProgress
private boolean isValid
private boolean firstWarn
private Timestamp sessionRefreshTimeoutHandle
private JmxMBeanHandle mbeanHandle
private long startupTime
StreamingCallback streamingCb
private java.lang.String storageIdPrefix
private FileDumper fileDumper
private boolean shutdown
| Constructor Detail |
public XmlBlasterAccess(Global glob)
import org.xmlBlaster.util.Global; ... final Global glob = new Global(args); final I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
glob - Your environment handle or null to use the default Global.instance()
You must use a cloned Global for each XmlBlasterAccess created.
engine.Global is not allowed here, only util.Global is supported
java.lang.IllegalArgumentException - If engine.Global is used as parameterpublic XmlBlasterAccess(java.lang.String[] args)
final Global glob = new Global(args); final I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
args - Your command line arguments| Method Detail |
public void registerConnectionListener(I_ConnectionStateListener connectionListener)
I_XmlBlasterAccess
registerConnectionListener in interface I_XmlBlasterAccessconnectionListener - null or your listener implementation on connection state changes (ALIVE | POLLING | DEAD)I_XmlBlasterAccess.registerConnectionListener(I_ConnectionStateListener)public final I_PostSendListener registerPostSendListener(I_PostSendListener postSendListener)
registerPostSendListener in interface I_XmlBlasterAccesspostSendListener - The postSendListener to set.
public final void postSend(MsgQueueEntry[] entries)
postSend in interface I_PostSendListener
public boolean sendingFailed(MsgQueueEntry[] entries,
XmlBlasterException exception)
I_PostSendListenerIf the server e.g. throws an IllegalArgument back to the client the message will most probably never succeed and retrying to send the message makes no sense. You can intercept this case here and eliminate the message.
ErrorCodes of type "communication.*" are not reported here as the dispatcher framework automatically handles reconnect and retry.
NOTE: For ErrorCodes of type "authentication.*" the connection will go to DEAD and the connection queue entries remain for pubSessionId>0. For pubSessionId<0 (none fail safe) the queue entries are removed (to be implemented TODO).
sendingFailed in interface I_PostSendListenerentries - Each MsgQueueEntry includes the returned QoSexception - The cause
public FileDumper getFileDumper()
throws XmlBlasterException
XmlBlasterExceptionpublic SynchronousCache createSynchronousCache(int size)
I_XmlBlasterAccess
createSynchronousCache in interface I_XmlBlasterAccesssize - Size of the cache. This number specifies the count of subscriptions the cache
can hold. It specifies NOT the number of messages.
I_XmlBlasterAccess.getCached(GetKey, GetQos),
client.cache requirementpublic void setClientErrorHandler(I_MsgErrorHandler msgErrorHandler)
I_XmlBlasterAccess
setClientErrorHandler in interface I_XmlBlasterAccessmsgErrorHandler - Your implementation of the error handler.ClientErrorHandlerpublic java.lang.String getConnectionQueueId()
XmlBlasterAccessMBean
getConnectionQueueId in interface XmlBlasterAccessMBeanpublic final ContextNode getContextNode()
public ConnectReturnQos connect(ConnectQos qos,
I_StreamingCallback streamingUpdateListener,
boolean withQueue)
throws XmlBlasterException
XmlBlasterException
public ConnectReturnQos connect(ConnectQos qos,
I_Callback updateListener)
throws XmlBlasterException
I_XmlBlasterAccessConnecting with the default configuration (which checks xmlBlaster.properties and your command line arguments):
import org.xmlBlaster.util.Global; ... I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess(); xmlBlasterAccess.connect(null, null);
The default behavior is to poll automatically for the server if it is not found. As we have not specified a listener for returned messages from the server there is no callback server created.
This example shows how to configure different behavior:
// Example how to configure fail safe settings
ConnectQos connectQos = new ConnectQos(glob);
Address address = new Address(glob);
address.setDelay(4000L); // retry connecting every 4 sec
address.setRetries(-1); // -1 == forever
address.setPingInterval(0L); // switched off
addr.setType("SOCKET"); // don't use CORBA protocol, but use SOCKET instead
connectQos.setAddress(address);
CallbackAddress cbAddress = new CallbackAddress(glob);
cbAddress.setDelay(4000L); // retry connecting every 4 sec
cbAddress.setRetries(-1); // -1 == forever
cbAddress.setPingInterval(4000L); // ping every 4 seconds
connectQos.addCallbackAddress(cbAddress);
xmlBlasterAccess.connect(connectQos, new I_Callback() {
public String update(String cbSessionId, UpdateKey updateKey, byte[] content,
UpdateQos updateQos) {
if (updateKey.isInternal()) {
return "";
}
if (updateQos.isErased()) {
return "";
}
log.info(ME, "Receiving asynchronous message '" + updateKey.getOid() +
"' state=" + updateQos.getState() + " in default handler");
return "";
}
}); // Login to xmlBlaster, default handler for updates;
connect in interface I_XmlBlasterAccessqos - Your configuration desireupdateListener - If not null a callback server will be created and
callback messages will be routed to your updateListener.update() method.
XmlBlasterException - only if connection state is DEAD, typically thrown on wrong configurations.
You must call connect again with different settings.I_XmlBlasterAccess.connect(ConnectQos, I_Callback)
private void sendConnectQos()
throws XmlBlasterException
XmlBlasterExceptionpublic boolean isConnected()
I_XmlBlasterAccessNote that this contains no information about the current connection state of the protocol layer.
isConnected in interface I_XmlBlasterAccessI_ConnectionHandler.isAlive(),
I_ConnectionHandler.isPolling(),
I_ConnectionHandler.isDead()private void startSessionRefresher()
public void refreshSession()
throws XmlBlasterException
I_XmlBlasterAccess
refreshSession in interface I_XmlBlasterAccessXmlBlasterException - like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.refreshSession()
private void createDefaultCbServer()
throws XmlBlasterException
XmlBlasterException
public I_CallbackServer initCbServer(java.lang.String loginName,
CallbackAddress callbackAddress)
throws XmlBlasterException
I_XmlBlasterAccessNote that the returned instance is of your control only, we don't cache it in any way, this method is only a helper hiding the plugin loading.
initCbServer in interface I_XmlBlasterAccessloginName - A nice name for logging purposescallbackAddress - The callback address configuration, contains for example
type like "IOR" or "RMI" and version of the driver, e.g. "1.0"
XmlBlasterExceptionI_XmlBlasterAccess.initCbServer(String, CallbackAddress)
private void initSecuritySettings(java.lang.String secMechanism,
java.lang.String secVersion)
Security.Client.DefaultPlugin=gui,1.0 Security.Client.Plugin[gui][1.0]=org.xmlBlaster.authentication.plugins.gui.ClientSecurityHelper
public I_ClientPlugin getSecurityPlugin()
I_XmlBlasterAccess
getSecurityPlugin in interface I_XmlBlasterAccessgetSecurityPlugin in class AbstractCallbackExtendedpublic java.lang.String disconnect(java.lang.String disconnectQos)
disconnect in interface XmlBlasterAccessMBeanXmlBlasterAccessMBean.disconnect(String)public boolean disconnect(DisconnectQos disconnectQos)
I_XmlBlasterAccessleaveServer(null)
and throw the xmlBlasterAccess instance away.
This is often the case if the client disappears and at a later point wants
to reconnect. On server side the queue for this session remains alive and
collects messages.
If '-dispatch/connection/doSendConnect false' was set call disconnect() nevertheless
to cleanup client side resources.
disconnect in interface I_XmlBlasterAccessdisconnectQos - Describe the desired behavior on disconnect
I_XmlBlasterAccess.disconnect(DisconnectQos),
interface.disconnect requirementpublic java.lang.String leaveServer()
leaveServer in interface XmlBlasterAccessMBeanXmlBlasterAccessMBean.leaveServer()public void leaveServer(java.util.Map map)
I_XmlBlasterAccessAs the login session on server side stays alive, all subscriptions stay valid and callback messages are queued by the server. If you connect at a later time the server sends us all queued messages.
Once you have called this method the I_XmlBlasterAccess becomes invalid and any further invocation results in an XmlBlasterException to be thrown.
leaveServer in interface I_XmlBlasterAccessmap - The properties to pass while leaving server.
Currently this argument has no effect. You can
pass null as a parameter.I_XmlBlasterAccess.leaveServer(Map)private boolean shutdown(DisconnectQos disconnectQos)
public boolean isShutdown()
public I_CallbackServer getCbServer()
getCbServer in interface I_XmlBlasterAccessI_XmlBlasterAccess.connect(ConnectQos, I_Callback)public java.lang.String getId()
getId in interface I_XmlBlasterAccesspublic java.lang.String getLogId()
public SessionName getSessionName()
getSessionName in interface I_XmlBlasterAccesspublic java.lang.String getStorageIdStr()
getStorageIdStr in interface I_XmlBlasterAccessI_XmlBlasterAccess.getStorageIdStr()public void setStorageIdStr(java.lang.String prefix)
I_XmlBlasterAccess
setStorageIdStr in interface I_XmlBlasterAccessprefix - For example "toserver1"+sessionName.getRelativeName()I_XmlBlasterAccess.setStorageIdStr(String)public void setServerNodeId(java.lang.String nodeId)
setServerNodeId in interface I_XmlBlasterAccessnodeId - For example "/xmlBlaster/node/heron"public java.lang.String getServerNodeId()
getServerNodeId in interface I_XmlBlasterAccessprivate void setContextNodeId(java.lang.String nodeId)
private java.lang.Object queueMessage(MsgQueueEntry entry)
throws XmlBlasterException