org.openanzo.services.impl
Class JMSNotificationService

java.lang.Object
  extended by org.openanzo.services.impl.JMSNotificationService
All Implemented Interfaces:
javax.jms.MessageListener, INotificationService, IService

public class JMSNotificationService
extends java.lang.Object
implements javax.jms.MessageListener, INotificationService

Implementation of INotificationService that uses JMS to talk to a notification server. General design is client creates a temporary topic and connects to a JMS ControlQueue and sends a login message that includes a TemporaryTopic for that user. The server authenticates the user, and registers the Temporary Topic as a destination. When messages go threw the JMS server, if the user is authorized to see the message, it is sent to the user's TemporaryTopic. Any message selectors are applied to the TemporaryTopic, which filters the messages the user actually sees. Class also handles the jms message received over the TemporaryTopic, and processes them.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
JMSNotificationService(java.util.Properties properties)
          Create new JMSNotificationService with given configuration properties
 
Method Summary
 void connect()
          Connect to the Notification Server
 void disconnect()
          Disconnect from the Notification Server
 java.lang.String getServicePassword()
          Get the Password for the current thread
 java.lang.String getServiceUser()
          Get the UserId for the current thread
 boolean isConnected()
          Determine if the service is connected
 boolean isNotificationEnabled()
          Determine if if notification is enabled
 void onMessage(javax.jms.Message message)
           
 void registerNotificationListener(INotificationListener listener)
          Register an INotificationListener with service
 void registerSelector(java.lang.String selector)
          Register a message selector with NotificationServer
 void setServicePassword(java.lang.String password)
          Set the password for the current thread's operations
 void setServiceUser(java.lang.String userName)
          Set the UserID for the current thread's operations
 void setUsingNotification(boolean enableNotification)
          Enable or disable notification
 void unregisterNotificationListener(INotificationListener listener)
          Unregister an INotificationListener with service
 void unregisterSelector(java.lang.String selector)
          Unregister a message selector from NotificationServer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSNotificationService

public JMSNotificationService(java.util.Properties properties)
Create new JMSNotificationService with given configuration properties

Parameters:
properties - Configuration properties
Method Detail

connect

public void connect()
             throws NotificationException
Description copied from interface: INotificationService
Connect to the Notification Server

Specified by:
connect in interface INotificationService
Throws:
NotificationException - if there was an error connecting to the Notification Server

disconnect

public void disconnect()
                throws NotificationException
Description copied from interface: INotificationService
Disconnect from the Notification Server

Specified by:
disconnect in interface INotificationService
Throws:
NotificationException - if there was an error disconnecting to the Notification Server

onMessage

public void onMessage(javax.jms.Message message)
Specified by:
onMessage in interface javax.jms.MessageListener

setUsingNotification

public void setUsingNotification(boolean enableNotification)
                          throws NotificationException
Description copied from interface: INotificationService
Enable or disable notification

Specified by:
setUsingNotification in interface INotificationService
Parameters:
enableNotification - state to set notification service
Throws:
NotificationException - if enabling or disabling notification fails

registerSelector

public void registerSelector(java.lang.String selector)
                      throws NotificationException
Description copied from interface: INotificationService
Register a message selector with NotificationServer

Specified by:
registerSelector in interface INotificationService
Parameters:
selector - Message selector to register
Throws:
NotificationException - if there was an error registering selector with the server

unregisterSelector

public void unregisterSelector(java.lang.String selector)
                        throws NotificationException
Description copied from interface: INotificationService
Unregister a message selector from NotificationServer

Specified by:
unregisterSelector in interface INotificationService
Parameters:
selector - Message selector to unregister
Throws:
NotificationException - if there was an error unregistering selector from the server

registerNotificationListener

public void registerNotificationListener(INotificationListener listener)
Description copied from interface: INotificationService
Register an INotificationListener with service

Specified by:
registerNotificationListener in interface INotificationService
Parameters:
listener - to register

unregisterNotificationListener

public void unregisterNotificationListener(INotificationListener listener)
Description copied from interface: INotificationService
Unregister an INotificationListener with service

Specified by:
unregisterNotificationListener in interface INotificationService
Parameters:
listener - to unregister

isConnected

public boolean isConnected()
Determine if the service is connected

Specified by:
isConnected in interface INotificationService
Returns:
true if the service is connected.

isNotificationEnabled

public boolean isNotificationEnabled()
Description copied from interface: INotificationService
Determine if if notification is enabled

Specified by:
isNotificationEnabled in interface INotificationService
Returns:
true if notification is enabled

getServicePassword

public java.lang.String getServicePassword()
Description copied from interface: IService
Get the Password for the current thread

Specified by:
getServicePassword in interface IService
Returns:
the Password for the current thread

setServicePassword

public void setServicePassword(java.lang.String password)
Description copied from interface: IService
Set the password for the current thread's operations

Specified by:
setServicePassword in interface IService
Parameters:
password - Password to use in current thread's operations

getServiceUser

public java.lang.String getServiceUser()
Description copied from interface: IService
Get the UserId for the current thread

Specified by:
getServiceUser in interface IService
Returns:
the UserId for the current thread

setServiceUser

public void setServiceUser(java.lang.String userName)
Description copied from interface: IService
Set the UserID for the current thread's operations

Specified by:
setServiceUser in interface IService
Parameters:
userName - UserId to use in current thread's operations


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.