xmlBlaster 2.1.0 API

org.xmlBlaster.test.util
Class Client

java.lang.Object
  extended by org.xmlBlaster.test.util.Client
All Implemented Interfaces:
I_Callback

public class Client
extends java.lang.Object
implements I_Callback


Nested Class Summary
static class Client.Shutdown
           
 
Field Summary
private  I_XmlBlasterAccess accessor
           
private  boolean consumable
           
private  Global global
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  java.lang.String name
           
private  java.lang.String publishOid
           
private  java.util.ArrayList responses
           
private  java.lang.String subscribeOid
           
private  XmlBlasterException updateException
           
 
Constructor Summary
Client(Global global, java.lang.String name, java.util.ArrayList responses)
          A helper client to be used when testing
 
Method Summary
 void init(java.lang.String publishOid, java.lang.String subscribeOid, boolean consumable, int session)
          Initializes this client which either can be a publisher, a subscriber or both depending on the parameters passed here.
static boolean isSeparateCallbackServer(Global glob)
           
static boolean isSocket(Global glob)
           
static boolean isSocket(I_XmlBlasterAccess conn)
           
 void publish(java.lang.String content)
          Publishes one entry on the oid specified by the init method.
 void setUpdateException(XmlBlasterException ex)
          Sets an exception to be thrown the next time an update event comes.
 void shutdown(boolean doEraseTopic)
          Disconnect the client from xmlBlaster with an optional previous deletion of the publishing topic.
static boolean shutdownCb(I_XmlBlasterAccess conn, Client.Shutdown whatToDo)
          Returns true if it shot down, false if it did a leave Server.
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          Enforced by I_Callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

global

private Global global

log

private static java.util.logging.Logger log

accessor

private I_XmlBlasterAccess accessor

name

private java.lang.String name

publishOid

private java.lang.String publishOid

subscribeOid

private java.lang.String subscribeOid

consumable

private boolean consumable

responses

private java.util.ArrayList responses

updateException

private XmlBlasterException updateException
Constructor Detail

Client

public Client(Global global,
              java.lang.String name,
              java.util.ArrayList responses)
A helper client to be used when testing

Parameters:
global -
name - the name to be given to this instance
responses - the ArrayList object to which to add an entry (the name) when an update happens. You can pass 'null' here and nobody will be notified.
Method Detail

init

public void init(java.lang.String publishOid,
                 java.lang.String subscribeOid,
                 boolean consumable,
                 int session)
          throws XmlBlasterException
Initializes this client which either can be a publisher, a subscriber or both depending on the parameters passed here.

Parameters:
publishOid - The oid to which to publish messages. If you pass 'null', then no message will be published by this instance.
subscribeOid - the oid to which to subscribe. If you pass null here no subscription will be node.
consumable - if this flag is set to true, then the publishing oid will be consumable, otherwise it is a normal (non consumable) topic.
session - the session of this instance as an integer (either positive or negative).
Throws:
XmlBlasterException

publish

public void publish(java.lang.String content)
             throws XmlBlasterException
Publishes one entry on the oid specified by the init method. If you passed null there, then you will get an exceptio here. This client just sends strings

Parameters:
content - the content of the message to send (a string).
Throws:
XmlBlasterException

shutdown

public void shutdown(boolean doEraseTopic)
              throws XmlBlasterException
Disconnect the client from xmlBlaster with an optional previous deletion of the publishing topic.

Parameters:
doEraseTopic - if true, the topic on which this client publishes is erased. If this client is not a publisher, then erase will not be done.
Throws:
XmlBlasterException

setUpdateException

public void setUpdateException(XmlBlasterException ex)
Sets an exception to be thrown the next time an update event comes. After that it is reset to null.

Parameters:
ex -

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Enforced by I_Callback. If you passed a responses array list, then it will notify the thread waiting for it (and will add an entry with this istance's name). If updateException is not null, then an exception is thrown here and updateException is reset to null.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId -
updateKey -
content -
updateQos -
Returns:
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

isSeparateCallbackServer

public static boolean isSeparateCallbackServer(Global glob)

isSocket

public static boolean isSocket(Global glob)

isSocket

public static boolean isSocket(I_XmlBlasterAccess conn)

shutdownCb

public static boolean shutdownCb(I_XmlBlasterAccess conn,
                                 Client.Shutdown whatToDo)
                          throws XmlBlasterException
Returns true if it shot down, false if it did a leave Server.

Parameters:
conn -
Returns:
Throws:
XmlBlasterException

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.