org.figure8.join.services.notification.im
Class XMPPNotifier

java.lang.Object
  extended by org.figure8.join.services.notification.im.XMPPNotifier
All Implemented Interfaces:
Configurable, Notifier, SubscribersNotifier
Direct Known Subclasses:
GoogleTalkNotifier

public class XMPPNotifier
extends java.lang.Object
implements SubscribersNotifier

This is an implementation of SubscribersNotifier using the Instant Messenger as notification media. This implementation uses the Jabber/XMPP protocol for message sending. It uses the Smack libray for that (see http://www.jivesoftware.org/smack for details)

Version:
$Revision: 1.1 $
Author:
Laurent Broudoux

Field Summary
protected static java.util.List parameters
          List of ParameterDefinitions supported by this notifier
static java.lang.String PASSWORD_PARAM
          Name of configurable parameter denoting the password for connecting to IM.
protected static ParameterDefinition passwordParam
          ParameterDefinition representation of parameter denoting the password for connecting to IM.
static java.lang.String PORT_PARAM
          Name of configurable parameter denoting the port of IM server.
protected static ParameterDefinition portParam
          ParameterDefinition representation of parameter denoting the port of the IM server.
static java.lang.String PSEUDO_PARAM
          Name of configurable parameter denoting the nick name for joining chat room.
protected static ParameterDefinition pseudoParam
          ParameterDefintion representation of parameter denoting the nick name for joining chat room.
static java.lang.String ROOM_PARAM
          Name of configurable parameter denoting the chat room where to send message.
protected static ParameterDefinition roomParam
          ParameterDefintion representation of parameter denoting the chat room where to send messages.
static java.lang.String SERVER_PARAM
          Name of configurable parameter denoting the name of IM server.
protected static ParameterDefinition serverParam
          ParameterDefinition representation of parameter denoting the name of the IM server.
static java.lang.String USER_PARAM
          Name of configurable parameter denoting the user name for connecting to IM.
protected static ParameterDefinition userParam
          ParameterDefinition representation of parameter denoting the user name for connecting to IM.
 
Constructor Summary
XMPPNotifier()
          Creates a new instance of XMPPNotifier
XMPPNotifier(java.lang.String server, int port, java.lang.String username, java.lang.String password)
          Creates a new instance of XMPPNotifier with mandatory attributes for connecting to IM
 
Method Summary
protected  XMPPConnection connect()
          Create a new connection and log in.
 java.lang.String[] extractRecipients(RemoteSubscriber[] subscribers)
          Extract mail addresses for subscribers to provide recipients.
 java.lang.String getChatRoom()
           
 ParameterDefinition[] getParameterDefinitions()
          Get this object parameters definitions as an array
 java.util.List getParameterDefinitionsAsList()
          Get this object parameters definitions as a list
 java.lang.String getPassword()
           
 int getPort()
           
 java.lang.String getPseudo()
           
 java.lang.String getServer()
           
 java.lang.String getUsername()
           
 void notify(RemoteSubscriber[] subscribers, java.lang.String title, java.lang.String content)
          Notify subscribers of mailing list defined into Join application
 void notify(java.lang.String[] recipients, java.lang.String title, java.lang.String content)
          Notifier are able to notify recipients and use a title and a content within their notification messages.
 void setChatRoom(java.lang.String chatRoom)
           
 void setParameter(ParameterDefinition parameter, java.lang.String parameterValue)
          Set the value of a parameter using its definitions
 void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
          Set the value of a parameter using its nama
 void setParameters(java.util.Properties parameters)
          Convenient methods for setting all attributes values using a single method.
 void setPassword(java.lang.String password)
           
 void setPort(int port)
           
 void setPseudo(java.lang.String pseudo)
           
 void setServer(java.lang.String server)
           
 void setUsername(java.lang.String username)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_PARAM

public static final java.lang.String PORT_PARAM
Name of configurable parameter denoting the port of IM server.

See Also:
Constant Field Values

SERVER_PARAM

public static final java.lang.String SERVER_PARAM
Name of configurable parameter denoting the name of IM server.

See Also:
Constant Field Values

USER_PARAM

public static final java.lang.String USER_PARAM
Name of configurable parameter denoting the user name for connecting to IM.

See Also:
Constant Field Values

PASSWORD_PARAM

public static final java.lang.String PASSWORD_PARAM
Name of configurable parameter denoting the password for connecting to IM.

See Also:
Constant Field Values

ROOM_PARAM

public static final java.lang.String ROOM_PARAM
Name of configurable parameter denoting the chat room where to send message.

See Also:
Constant Field Values

PSEUDO_PARAM

public static final java.lang.String PSEUDO_PARAM
Name of configurable parameter denoting the nick name for joining chat room.

See Also:
Constant Field Values

parameters

protected static java.util.List parameters
List of ParameterDefinitions supported by this notifier


portParam

protected static final ParameterDefinition portParam
ParameterDefinition representation of parameter denoting the port of the IM server.


serverParam

protected static final ParameterDefinition serverParam
ParameterDefinition representation of parameter denoting the name of the IM server.


userParam

protected static final ParameterDefinition userParam
ParameterDefinition representation of parameter denoting the user name for connecting to IM.


passwordParam

protected static final ParameterDefinition passwordParam
ParameterDefinition representation of parameter denoting the password for connecting to IM.


roomParam

protected static final ParameterDefinition roomParam
ParameterDefintion representation of parameter denoting the chat room where to send messages.


pseudoParam

protected static final ParameterDefinition pseudoParam
ParameterDefintion representation of parameter denoting the nick name for joining chat room.

Constructor Detail

XMPPNotifier

public XMPPNotifier()
Creates a new instance of XMPPNotifier


XMPPNotifier

public XMPPNotifier(java.lang.String server,
                    int port,
                    java.lang.String username,
                    java.lang.String password)
Creates a new instance of XMPPNotifier with mandatory attributes for connecting to IM

Parameters:
server - The name of IM server to connect to
port - The port of IM server to connect to
username - The username for connecting to IM server
password - The password for connecting to IM server
Method Detail

getPort

public int getPort()
Returns:
The port of IM server to connect to

setPort

public void setPort(int port)
Parameters:
port - The port of IM server to connect to

getServer

public java.lang.String getServer()
Returns:
The name of IM server to connect to

setServer

public void setServer(java.lang.String server)
Parameters:
server - The name of IM server to connect to

getUsername

public java.lang.String getUsername()
Returns:
The username for connecting to IM server

setUsername

public void setUsername(java.lang.String username)

getPassword

public java.lang.String getPassword()
Returns:
The password for connecting to IM server

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - The password for connecting to IM server

getChatRoom

public java.lang.String getChatRoom()
Returns:
The name of chat room to send messages to (if group publishing)

setChatRoom

public void setChatRoom(java.lang.String chatRoom)
Parameters:
chatRoom - The name of chat room to send messages to (if group publishing)

getPseudo

public java.lang.String getPseudo()
Returns:
The pseudo to use for joining chat room (if group publishing)

setPseudo

public void setPseudo(java.lang.String pseudo)
Parameters:
pseudo - The pseudo to use for joining chat room (if group publishing)

extractRecipients

public java.lang.String[] extractRecipients(RemoteSubscriber[] subscribers)
Extract mail addresses for subscribers to provide recipients. Use mail address for the moment : RemoteSubscriber do not have an IM identifier

Specified by:
extractRecipients in interface SubscribersNotifier
Parameters:
subscribers - The subscribers to get recipients for
Returns:
The list of corresponding recipients.

notify

public void notify(RemoteSubscriber[] subscribers,
                   java.lang.String title,
                   java.lang.String content)
            throws NotificationException
Notify subscribers of mailing list defined into Join application

Specified by:
notify in interface SubscribersNotifier
Parameters:
subscribers - The subscriber of mailing list to notify
title - The title of notification message to send
content - The content of notification message to send
Throws:
NotificationException - if an exception occurs during the notification operation (usually they are network related exceptions)

notify

public void notify(java.lang.String[] recipients,
                   java.lang.String title,
                   java.lang.String content)
            throws NotificationException
Notifier are able to notify recipients and use a title and a content within their notification messages. The definition of a recipients is voluntary abstract letting implementations or sub-interfaces defining what they consider as valid recipients (ex: mail addresses, IM identifies, etc...)

Specified by:
notify in interface Notifier
Parameters:
recipients - An array of recipients to notify. Recipient is described with a String
title - The title of notification message to send
content - The content of notification message to send
Throws:
NotificationException - if an exception occurs during the notification operation (usually they are network related exceptions)

getParameterDefinitionsAsList

public java.util.List getParameterDefinitionsAsList()
Get this object parameters definitions as a list

Specified by:
getParameterDefinitionsAsList in interface Configurable
Returns:
A list of ParameterDefinition objects

getParameterDefinitions

public ParameterDefinition[] getParameterDefinitions()
Get this object parameters definitions as an array

Specified by:
getParameterDefinitions in interface Configurable
Returns:
An array of ParameterDefinition objects

setParameter

public void setParameter(java.lang.String parameterName,
                         java.lang.String parameterValue)
                  throws InvalidParameterException
Set the value of a parameter using its nama

Specified by:
setParameter in interface Configurable
Parameters:
parameterName - The name of parameter so set value for
parameterValue - The value of the paramater
Throws:
InvalidParameterException - if this parameter is not supported by this object

setParameter

public void setParameter(ParameterDefinition parameter,
                         java.lang.String parameterValue)
                  throws InvalidParameterException
Set the value of a parameter using its definitions

Specified by:
setParameter in interface Configurable
Parameters:
parameter - The definitino of the paramater to set
parameterValue - The value of the parameter
Throws:
InvalidParameterException - if this parameter is not supported by this object

setParameters

public void setParameters(java.util.Properties parameters)
                   throws InvalidParameterException
Convenient methods for setting all attributes values using a single method.

Specified by:
setParameters in interface Configurable
Parameters:
parameters - Properties where keys are parameter names
Throws:
InvalidParameterException - if one of these parameters is not supported by this object

connect

protected XMPPConnection connect()
                          throws NotificationException
Create a new connection and log in.

Returns:
A new XMPPConnection with user logged in
Throws:
NotificationException - if an exception occurs while creating exception.


Copyright © 2005-2008 Join. All Rights Reserved.