xmlBlaster 2.2.0 client API

org.xmlBlaster.client.qos
Class ConnectQos

java.lang.Object
  extended by org.xmlBlaster.client.qos.ConnectQos

public final class ConnectQos
extends java.lang.Object

This class encapsulates the qos of a connect() invocation.

See Also:
ConnectQosSaxFactory, connect interface

Constructor Summary
ConnectQos(Global glob)
          Default constructor.
ConnectQos(Global glob, ConnectQosData connectQosData)
          Constructor for special use in cluster environment only.
ConnectQos(Global glob, java.lang.String userId, java.lang.String passwd)
          Login with the default security plugin as given by -Security.Client.DefaultPlugin htpasswd,1.0
 
Method Summary
 void addCallbackAddress(CallbackAddress callback)
          Add a callback address where to send the message (for PtP or subscribes).
 void addClientProperty(java.lang.String key, java.lang.Object value)
          Sets a client property (an application specific property) to the given value
 void addClientQueueProperty(ClientQueueProperty clientQueueProperty)
          The configuration of the local client side queue.
 boolean clearSessions()
          If clearSessions is true, all old sessions of this user are discarded.
 void clearSessions(boolean clear)
          If clearSessions is true, all old sessions of this user are discarded.
 boolean doSendConnect()
           
 void doSendConnect(boolean doSendConnect)
          If set to false the connect() is not send to the server.
 boolean duplicateUpdates()
          Deprecated. Please use multiSubscribe=false from SubscribeQos
 Address getAddress()
          The connection address and properties of the xmlBlaster server we want connect to.
 AddressBase[] getAddresses(boolean forceCbAddressCreation)
          The connection address and properties of the xmlBlaster server we want connect to.
 org.xmlBlaster.authentication.plugins.I_ClientPlugin getClientPlugin()
          Access the default plugin or the previously added by load loadClientPlugin()
 ClientProperty getClientProperty(java.lang.String key)
          Read back a property.
 ClientQueueProperty getClientQueueProperty()
          The configuration of the local client side queue.
 ConnectQosData getData()
           
 boolean getPersistent()
          Gets the persistent flag.
 boolean getRefreshSession()
           
 org.xmlBlaster.authentication.plugins.I_SecurityQos getSecurityQos()
          This is a convenience method for getClientPlugin().getSecurityQos().
 CbQueueProperty getSessionCbQueueProperty()
          Returns never null.
 SessionName getSessionName()
           
 SessionQos getSessionQos()
           
 CbQueueProperty getSubjectQueueProperty()
          Gets the subject queue properties as set on this connection.
 java.lang.String getUserId()
           
 boolean isPtpAllowed()
           
 org.xmlBlaster.authentication.plugins.I_ClientPlugin loadClientPlugin(java.lang.String type, java.lang.String version, java.lang.String userId, java.lang.String credential)
          Allows to set or overwrite the client side security plugin.
static void main(java.lang.String[] args)
          For testing invoke: java org.xmlBlaster.client.qos.ConnectQos
 void setAddress(Address address)
          Set the address to which we want to connect, with all the configured parameters.
 void setDuplicateUpdates(boolean duplicateUpdates)
          Deprecated. Please use multiSubscribe=false from SubscribeQos
 void setMaxSessions(int max)
          If maxSession == 1, only a single login is possible
 void setPersistent(boolean persistent)
          sets the persistent flag for this subscription.
 void setPtpAllowed(boolean ptpAllowed)
           
 void setRefreshSession(boolean refreshSession)
           
 void setSecretCbSessionId(java.lang.String id)
          Set the secret cbSessionId.
 void setSecretSessionId(java.lang.String id)
          Set the secret sessionId.
 void setSessionCbQueueProperty(CbQueueProperty prop)
          Adds a queue description.
 void setSessionName(SessionName sessionName)
          Set the login session name.
 void setSessionTimeout(long timeout)
          Timeout until session expires if no communication happens
 void setSubjectQueueProperty(CbQueueProperty subjectQueueProperty)
          Sets the queue properties for the subject queue of this subject
 void setUserId(java.lang.String loginName)
          Allows to set or overwrite the login name for I_SecurityQos.
 int size()
          The number of bytes of stringified qos
 java.lang.String toString()
          Converts the data into a valid XML ASCII string.
 java.lang.String toXml()
          Converts the data into a valid XML ASCII string.
 java.lang.String usage()
          Get a usage string for the connection parameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectQos

public ConnectQos(Global glob)
           throws XmlBlasterException
Default constructor.

Initializes login credentials from environment e.g. -session.name guest and -passwd secret with the default security plugin as given by -Security.Client.DefaultPlugin htpasswd,1.0

To use another security authentication plugin use setSecurity()

Throws:
XmlBlasterException - on problems loading the client security plugin

ConnectQos

public ConnectQos(Global glob,
                  java.lang.String userId,
                  java.lang.String passwd)
           throws XmlBlasterException
Login with the default security plugin as given by -Security.Client.DefaultPlugin htpasswd,1.0

Parameters:
userId - e.g. "joe" or "joe/7" if you want to connect to joe's seventh session
passwd - The password if you use a password based authentication
Throws:
XmlBlasterException - if the default security plugin couldn't be loaded

ConnectQos

public ConnectQos(Global glob,
                  ConnectQosData connectQosData)
Constructor for special use in cluster environment only.

Method Detail

getData

public ConnectQosData getData()

getSessionQos

public SessionQos getSessionQos()
Returns:
The session QoS which contains all session specific configuration, never null

setSessionName

public void setSessionName(SessionName sessionName)
Set the login session name.

This will NOT set the security loginName (see setUserId()).

Parameters:
sessionName - e.g. "joe" which is the loginName (subjectId) only
e.g. "joe/2" which forces a connect on the public session ID 2 of user joe

getSessionName

public SessionName getSessionName()

setSessionTimeout

public void setSessionTimeout(long timeout)
Timeout until session expires if no communication happens

Parameters:
timeout - The login session will be destroyed after given milliseconds.
Session lasts forever if set to 0L

setSecretSessionId

public void setSecretSessionId(java.lang.String id)
Set the secret sessionId. Usually never used, the secret sessionId is generated by the server


setSecretCbSessionId

public void setSecretCbSessionId(java.lang.String id)
Set the secret cbSessionId. This is bounced back in the update(cbSessionId, ...)


setMaxSessions

public void setMaxSessions(int max)
If maxSession == 1, only a single login is possible

Parameters:
max - How often the same client may login

clearSessions

public void clearSessions(boolean clear)
If clearSessions is true, all old sessions of this user are discarded.

Parameters:
clear - Defaults to false

clearSessions

public final boolean clearSessions()
If clearSessions is true, all old sessions of this user are discarded.


getRefreshSession

public final boolean getRefreshSession()
Returns:
refreshSession is true if the client automatically notifies xmlBlaster that it is alive and the login session is extended

setRefreshSession

public final void setRefreshSession(boolean refreshSession)
Parameters:
refreshSession - true: The client automatically notifies xmlBlaster that it is alive and the login session is extended

setUserId

public void setUserId(java.lang.String loginName)
               throws XmlBlasterException
Allows to set or overwrite the login name for I_SecurityQos.

This will call setSessionName() as well if sessionName is not set yet.

This is a convenience method to set the securityQos userId

Parameters:
loginName - The unique user id
Throws:
XmlBlasterException

getUserId

public java.lang.String getUserId()
Returns:
The user ID or "NoLoginName" if not known

loadClientPlugin

public org.xmlBlaster.authentication.plugins.I_ClientPlugin loadClientPlugin(java.lang.String type,
                                                                             java.lang.String version,
                                                                             java.lang.String userId,
                                                                             java.lang.String credential)
                                                                      throws XmlBlasterException
Allows to set or overwrite the client side security plugin.

Parameters:
type - The client side security plugin to use
credential - For 'htpasswd' the password, if null the environment -passwd is checked (default plugin)
Throws:
XmlBlasterException
See Also:
ConnectQosData.loadClientPlugin(String, String, String, String)

getClientPlugin

public org.xmlBlaster.authentication.plugins.I_ClientPlugin getClientPlugin()
Access the default plugin or the previously added by load loadClientPlugin()


getSecurityQos

public org.xmlBlaster.authentication.plugins.I_SecurityQos getSecurityQos()
This is a convenience method for getClientPlugin().getSecurityQos().

Returns:
Access the login credentials or null if not set

setPtpAllowed

public void setPtpAllowed(boolean ptpAllowed)
Parameters:
Set - if we accept point to point messages

isPtpAllowed

public boolean isPtpAllowed()
Returns:
true if we are accepting PtP messages

setDuplicateUpdates

public void setDuplicateUpdates(boolean duplicateUpdates)
Deprecated. Please use multiSubscribe=false from SubscribeQos

Parameters:
Set - if we allow multiple updates for the same message if we have subscribed multiple times to it.

duplicateUpdates

public boolean duplicateUpdates()
Deprecated. Please use multiSubscribe=false from SubscribeQos

Returns:
true if we allow multiple updates for the same message if we have subscribed multiple times to it.

getClientQueueProperty

public ClientQueueProperty getClientQueueProperty()
The configuration of the local client side queue.

Returns:
never null

addClientQueueProperty

public void addClientQueueProperty(ClientQueueProperty clientQueueProperty)
The configuration of the local client side queue.

Parameters:
Your - hardcoded configuration

setAddress

public void setAddress(Address address)
Set the address to which we want to connect, with all the configured parameters.

Parameters:
address - An object containing the protocol (e.g. EMAIL) the address (e.g. hugo@welfare.org) and the connection properties

getAddress

public Address getAddress()
The connection address and properties of the xmlBlaster server we want connect to.

Returns:
never null

getAddresses

public AddressBase[] getAddresses(boolean forceCbAddressCreation)
The connection address and properties of the xmlBlaster server we want connect to.

Returns:
never null

addCallbackAddress

public void addCallbackAddress(CallbackAddress callback)
Add a callback address where to send the message (for PtP or subscribes).

Creates a default CbQueueProperty object to hold the callback address argument.
Note you can invoke this multiple times to allow multiple callbacks.

Parameters:
callback - An object containing the protocol (e.g. EMAIL) and the address (e.g. hugo@welfare.org)

setSessionCbQueueProperty

public void setSessionCbQueueProperty(CbQueueProperty prop)
Adds a queue description. This allows to set all supported attributes of a callback queue and a callback address

Parameters:
prop - The property object of the callback queue which shall be established in the server for calling us back.
See Also:
CallbackAddress

getSessionCbQueueProperty

public CbQueueProperty getSessionCbQueueProperty()
Returns never null.

If no CbQueueProperty exists, a RELATING_CALLBACK queue property object is created on the fly.


size

public int size()
The number of bytes of stringified qos


toString

public java.lang.String toString()
Converts the data into a valid XML ASCII string.

Overrides:
toString in class java.lang.Object
Returns:
An XML ASCII string

toXml

public java.lang.String toXml()
Converts the data into a valid XML ASCII string.

Returns:
An XML ASCII string

addClientProperty

public void addClientProperty(java.lang.String key,
                              java.lang.Object value)
Sets a client property (an application specific property) to the given value

Parameters:
key -
value -

getClientProperty

public ClientProperty getClientProperty(java.lang.String key)
Read back a property.

Returns:
The client property or null if not found

setPersistent

public void setPersistent(boolean persistent)
sets the persistent flag for this subscription. If this flag is set, the subscription will persit a server crash.

Parameters:
persistent -

getPersistent

public boolean getPersistent()
Gets the persistent flag. If this flag is set, the session will persist a server crash.

Returns:
true if persistent false otherwise.

usage

public java.lang.String usage()
Get a usage string for the connection parameters


setSubjectQueueProperty

public void setSubjectQueueProperty(CbQueueProperty subjectQueueProperty)
Sets the queue properties for the subject queue of this subject

Parameters:
subjectQueueProperty -

getSubjectQueueProperty

public CbQueueProperty getSubjectQueueProperty()
Gets the subject queue properties as set on this connection.

Returns:
the properties

doSendConnect

public boolean doSendConnect()
Returns:
Returns the doSendConnect.

doSendConnect

public void doSendConnect(boolean doSendConnect)
If set to false the connect() is not send to the server. In this case the client library is completely initialized and you can receive for example callback messages over 'email' or 'XMLRPC' protocols.
This is useful for clients which can't connect themselves (for example because of a firewall) and have a delegate client which does the real connect and possible subscribes.
Can be changed on command line with '-dispatch/connection/doSendConnect false' or in a property file.

Parameters:
doSendConnect - Overwrites default or value from environment

main

public static void main(java.lang.String[] args)
                 throws XmlBlasterException
For testing invoke: java org.xmlBlaster.client.qos.ConnectQos

Throws:
XmlBlasterException

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.