org.jboss.mq.sm.file
Class DynamicStateManager

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.mq.sm.AbstractStateManager (src) 
              extended byorg.jboss.mq.sm.file.DynamicStateManager
All Implemented Interfaces:
AbstractStateManagerMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src) , StateManager (src)

public class DynamicStateManager
extends AbstractStateManager (src)

A state manager that allowed durable subscriptions to be dynamically created if configured to support it. Otherwise backward compatible with the old StateManager.

Backed by an XML file.

Example file format:

<StateManager> <Users> <User> <Name>john</Name> <Password>needle</Password> <Id>DurableSubscriberExample</Id><!-- optional --> </User> </Users> <Roles> <Role name="guest"> <UserName>john</UserName> </Role> </Roles> <DurableSubscriptions> <DurableSubscription> <ClientID>needle</ClientID> <Name>myDurableSub</Name> <TopicName>TestTopic...</TopicName> </DurableSubscription> </DurableSubscriptions> </StateManager>


Nested Class Summary
 
Nested classes inherited from class org.jboss.mq.sm.AbstractStateManager (src)
AbstractStateManager.DurableSubscription (src)
 
Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DynamicStateManager()
           
 
Method Summary
 void addRole(java.lang.String name)
           
 void addUser(java.lang.String name, java.lang.String password, java.lang.String preconfID)
           
 void addUserToRole(java.lang.String roleName, java.lang.String user)
           
protected  void checkLoggedOnClientId(java.lang.String clientID)
          Check if the clientID belonges to a preconfigured user.
protected  void createService()
          Sub-classes should override this method to provide custum 'create' logic.
 java.lang.String displayStateConfig()
          Show the current configuration.
protected  XElement (src) findRole(java.lang.String role)
           
protected  XElement (src) findUser(java.lang.String user)
           
protected  XElement (src) findUserInRole(XElement (src)  role, java.lang.String user)
           
protected  AbstractStateManager.DurableSubscription (src) getDurableSubscription(DurableSubscriptionID (src)  sub)
          Search for a configurated durable subscription.
 java.util.Collection getDurableSubscriptionIdsForTopic(SpyTopic (src)  topic)
          Get all configured durable subscriptions for a particular topic.
 StateManager (src) getInstance()
          Get an instance if the StateManager (Singleton).
protected  java.lang.String getPreconfClientId(java.lang.String login, java.lang.String passwd)
          Return preconfigured client id.
 java.lang.String[] getRoles(java.lang.String user)
          We currently only support one Group type Roles.
 java.lang.String getStateFile()
          Get name of file.
 boolean hasSecurityManager()
           
 void loadConfig()
           
protected  void removeDurableSubscription(AbstractStateManager.DurableSubscription (src)  ds)
          Remove the subscription and save to persistent storage.
 void removeRole(java.lang.String name)
           
 void removeUser(java.lang.String name)
           
 void removeUserFromRole(java.lang.String roleName, java.lang.String user)
           
 void saveConfig()
           
protected  void saveDurableSubscription(AbstractStateManager.DurableSubscription (src)  ds)
          Add to durable subs and save the subsrcription to persistent storage.
 void setHasSecurityManager(boolean hasSecurityManager)
           
 void setStateFile(java.lang.String newStateFile)
          Set the name of the statefile.
 void startService()
          Sub-classes should override this method to provide custum 'start' logic.
 boolean validatePassword(java.lang.String user, java.lang.String inputPassword)
          Validate the user/password combination.
 
Methods inherited from class org.jboss.mq.sm.AbstractStateManager (src)
addLoggedOnClientId, checkUser, getDurableTopic, removeLoggedOnClientId, setDurableSubscription
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean (src)
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 

Constructor Detail

DynamicStateManager

public DynamicStateManager()
Method Detail

getInstance

public StateManager (src)  getInstance()
Description copied from interface: AbstractStateManagerMBean (src)
Get an instance if the StateManager (Singleton).


createService

protected void createService()
                      throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'create' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
createService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

startService

public void startService()
                  throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

displayStateConfig

public java.lang.String displayStateConfig()
                                    throws java.lang.Exception
Show the current configuration.

Throws:
java.lang.Exception

setStateFile

public void setStateFile(java.lang.String newStateFile)
Set the name of the statefile.

Parameters:
newStateFile - java.lang.String

getStateFile

public java.lang.String getStateFile()
Get name of file.

Returns:
java.lang.String

hasSecurityManager

public boolean hasSecurityManager()

setHasSecurityManager

public void setHasSecurityManager(boolean hasSecurityManager)

loadConfig

public void loadConfig()
                throws java.io.IOException,
                       XElementException (src) 
Throws:
java.io.IOException
XElementException (src)

saveConfig

public void saveConfig()
                throws java.io.IOException
Throws:
java.io.IOException

getPreconfClientId

protected java.lang.String getPreconfClientId(java.lang.String login,
                                              java.lang.String passwd)
                                       throws JMSException (src) 
Return preconfigured client id. Only if hasSecurityManager is false will a password be required to get the clientID and will the method throw a JMSSecurityException if the clientID was not found.

Specified by:
getPreconfClientId in class AbstractStateManager (src)
Parameters:
login - the user name
passwd - the password
Returns:
any preconfigured client id
Throws:
JMSException (src) - for any error

getDurableSubscription

protected AbstractStateManager.DurableSubscription (src)  getDurableSubscription(DurableSubscriptionID (src)  sub)
                                                                   throws JMSException (src) 
Search for a configurated durable subscription.

Specified by:
getDurableSubscription in class AbstractStateManager (src)
Parameters:
sub - the durable subscription id
Returns:
the durable subscription or null if not found
Throws:
JMSException (src) - for any error

checkLoggedOnClientId

protected void checkLoggedOnClientId(java.lang.String clientID)
                              throws JMSException (src) 
Check if the clientID belonges to a preconfigured user. If this is the case, a InvalidClientIDException will be raised.

Specified by:
checkLoggedOnClientId in class AbstractStateManager (src)
Parameters:
clientID - the client id to check
Throws:
JMSException (src) - for any error

saveDurableSubscription

protected void saveDurableSubscription(AbstractStateManager.DurableSubscription (src)  ds)
                                throws JMSException (src) 
Description copied from class: AbstractStateManager (src)
Add to durable subs and save the subsrcription to persistent storage.

Called by this class so the sublclass can save. This may be both a new subscription or a changed one. It is up to the sublcass to know how to find a changed on. (Only the topic will have changed, and it is the same DurableSubscription that is saved again that this class got through getDurableSubscription.

Specified by:
saveDurableSubscription in class AbstractStateManager (src)
Parameters:
ds - the durable subscription to save
Throws:
JMSException (src) - for any error

removeDurableSubscription

protected void removeDurableSubscription(AbstractStateManager.DurableSubscription (src)  ds)
                                  throws JMSException (src) 
Description copied from class: AbstractStateManager (src)
Remove the subscription and save to persistent storage.

Called by this class so the sublclass can remove.

Specified by:
removeDurableSubscription in class AbstractStateManager (src)
Parameters:
ds - the durable subscription to save
Throws:
JMSException (src) - for any error

getDurableSubscriptionIdsForTopic

public java.util.Collection getDurableSubscriptionIdsForTopic(SpyTopic (src)  topic)
                                                       throws JMSException (src) 
Description copied from interface: StateManager (src)
Get all configured durable subscriptions for a particular topic.

Specified by:
getDurableSubscriptionIdsForTopic in interface StateManager (src)
Specified by:
getDurableSubscriptionIdsForTopic in class AbstractStateManager (src)
Throws:
JMSException (src)

addUser

public void addUser(java.lang.String name,
                    java.lang.String password,
                    java.lang.String preconfID)
             throws java.lang.Exception
Throws:
java.lang.Exception

removeUser

public void removeUser(java.lang.String name)
                throws java.lang.Exception
Throws:
java.lang.Exception

addRole

public void addRole(java.lang.String name)
             throws java.lang.Exception
Throws:
java.lang.Exception

removeRole

public void removeRole(java.lang.String name)
                throws java.lang.Exception
Throws:
java.lang.Exception

addUserToRole

public void addUserToRole(java.lang.String roleName,
                          java.lang.String user)
                   throws java.lang.Exception
Throws:
java.lang.Exception

removeUserFromRole

public void removeUserFromRole(java.lang.String roleName,
                               java.lang.String user)
                        throws java.lang.Exception
Throws:
java.lang.Exception

findUser

protected XElement (src)  findUser(java.lang.String user)
                     throws java.lang.Exception
Throws:
java.lang.Exception

findRole

protected XElement (src)  findRole(java.lang.String role)
                     throws java.lang.Exception
Throws:
java.lang.Exception

findUserInRole

protected XElement (src)  findUserInRole(XElement (src)  role,
                                  java.lang.String user)
                           throws java.lang.Exception
Throws:
java.lang.Exception

getRoles

public java.lang.String[] getRoles(java.lang.String user)
                            throws java.lang.Exception
We currently only support one Group type Roles. The role named returned should typically be put into a Roles Group principal.

Throws:
java.lang.Exception

validatePassword

public boolean validatePassword(java.lang.String user,
                                java.lang.String inputPassword)
                         throws java.lang.Exception
Validate the user/password combination. A null inputPassword will allways reurn false.

Throws:
java.lang.Exception