org.jboss.portal.registration.policies
Class DefaultRegistrationPolicy

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.portal.jems.as.system.AbstractJBossService
              extended by org.jboss.portal.registration.policies.DefaultRegistrationPolicy
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, RegistrationPolicy, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class DefaultRegistrationPolicy
extends AbstractJBossService
implements RegistrationPolicy

Provides a default implementation of RegistrationPolicy which should be enough for most user needs provided the appropriate RegistrationPropertyValidator has been configured to validate registration properties.

Since:
2.6
Version:
$Revision: 9180 $
Author:
Chris Laprun

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
DefaultRegistrationPolicy()
           
 
Method Summary
 java.lang.String createRegistrationHandleFor(java.lang.String registrationId)
          Simply returns the given registration id.
 java.lang.String getAutomaticGroupNameFor(java.lang.String consumerName)
          Doesn't support automatic ConsumerGroups so always return null.
 java.lang.String getConsumerIdFrom(java.lang.String consumerName, java.util.Map registrationProperties)
          Simply returns the given consumer name, trusted (!) to be unique.
 RegistrationManager getManager()
          Retrieves the RegistrationManager with which this RegistrationPolicy is associated.
 RegistrationPropertyValidator getValidator()
          Retrieves the currently configured RegistrationPropertyValidator.
 void setExpectations(java.util.Map<javax.xml.namespace.QName,? extends PropertyDescription> registrationPropertyDescriptions)
          Define what the expectations are as far as acceptable registration properties go.
 void setManager(RegistrationManager manager)
          Associates this RegistrationPolicy with the specified RegistrationManager.
 void setValidator(RegistrationPropertyValidator validator)
          Instructs this policy to use the specified RegistrationPropertyValidator.
 void validateConsumerGroupName(java.lang.String groupName)
          Rejects name if a ConsumerGroup with the specified name already exists.
 void validateConsumerName(java.lang.String consumerName)
          Rejects registration if a Consumer with the specified name already exists.
 void validateRegistrationDataFor(java.util.Map registrationProperties, java.lang.String consumerIdentity)
          Only accepts the registration if no registration with identical values exists for the Consumer identified by the specified identify and delegates the validation of properties to the configured RegistrationPropertyValidator.
 
Methods inherited from class org.jboss.portal.jems.as.system.AbstractJBossService
create, destroy, getState, getStateString, start, stop
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
createService, destroyService, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, startService, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRegistrationPolicy

public DefaultRegistrationPolicy()
Method Detail

getManager

public RegistrationManager getManager()
Description copied from interface: RegistrationPolicy
Retrieves the RegistrationManager with which this RegistrationPolicy is associated.

Specified by:
getManager in interface RegistrationPolicy
Returns:
the RegistrationManager with which this RegistrationPolicy is associated.

setManager

public void setManager(RegistrationManager manager)
Description copied from interface: RegistrationPolicy
Associates this RegistrationPolicy with the specified RegistrationManager. This method should not be called directly by client code as it used in the wiring process of the Registration service.

Specified by:
setManager in interface RegistrationPolicy
Parameters:
manager - the RegistrationManager with which this RegistrationPolicy should be associated.

setExpectations

public void setExpectations(java.util.Map<javax.xml.namespace.QName,? extends PropertyDescription> registrationPropertyDescriptions)
Description copied from interface: RegistrationPolicy
Define what the expectations are as far as acceptable registration properties go.

Specified by:
setExpectations in interface RegistrationPolicy
Parameters:
registrationPropertyDescriptions - a map of containing the description of expected registrations

validateRegistrationDataFor

public void validateRegistrationDataFor(java.util.Map registrationProperties,
                                        java.lang.String consumerIdentity)
                                 throws java.lang.IllegalArgumentException,
                                        RegistrationException,
                                        DuplicateRegistrationException
Only accepts the registration if no registration with identical values exists for the Consumer identified by the specified identify and delegates the validation of properties to the configured RegistrationPropertyValidator.

Specified by:
validateRegistrationDataFor in interface RegistrationPolicy
Parameters:
registrationProperties - a Map containing the registration properties in the form of property name (QName) - property value (Object) mappings
consumerIdentity - the Consumer identity (as returned by RegistrationPolicy.getConsumerIdFrom(String, java.util.Map)) for which the registration properties must be ascertained
Throws:
DuplicateRegistrationException - if a Consumer with the same identity has already registered with the same registration properties.
java.lang.IllegalArgumentException - if any of the registration properties is invalid for the specified Consumer
RegistrationException - if an exception occured in the registration service

createRegistrationHandleFor

public java.lang.String createRegistrationHandleFor(java.lang.String registrationId)
Simply returns the given registration id.

Specified by:
createRegistrationHandleFor in interface RegistrationPolicy
Parameters:
registrationId - the database identity of the Registration for which a handle is required.
Returns:
a registration handle for the Registration associated with the specified identifier.

getAutomaticGroupNameFor

public java.lang.String getAutomaticGroupNameFor(java.lang.String consumerName)
Doesn't support automatic ConsumerGroups so always return null.

Specified by:
getAutomaticGroupNameFor in interface RegistrationPolicy
Parameters:
consumerName - the name of the Consumer being created
Returns:
the name of the ConsumerGroup the Consumer must be automatically added to or null if the Consumer will not be automatically to a ConsumerGroup at creation

getConsumerIdFrom

public java.lang.String getConsumerIdFrom(java.lang.String consumerName,
                                          java.util.Map registrationProperties)
                                   throws java.lang.IllegalArgumentException,
                                          InvalidConsumerDataException
Simply returns the given consumer name, trusted (!) to be unique.

Specified by:
getConsumerIdFrom in interface RegistrationPolicy
Parameters:
consumerName - the consumer name
registrationProperties - a Map containing the registration properties in the form of property name (QName) - property value (Object) mappings. Producer implementations might use the registration properties to provide secure Consumer identity.
Returns:
the consumer identity
Throws:
java.lang.IllegalArgumentException - if the specified Consumer name if null or empty
InvalidConsumerDataException - if the Policy examines the specified registration properties to determine the Consumer identity and decides that they are not in a proper state

validateConsumerName

public void validateConsumerName(java.lang.String consumerName)
                          throws java.lang.IllegalArgumentException,
                                 RegistrationException
Rejects registration if a Consumer with the specified name already exists.

Specified by:
validateConsumerName in interface RegistrationPolicy
Parameters:
consumerName - the name of the Consumer as passed during the registration process
Throws:
java.lang.IllegalArgumentException - if the specified Consumer name if null or empty
RegistrationException - if an exception occurred in the Registration service

validateConsumerGroupName

public void validateConsumerGroupName(java.lang.String groupName)
                               throws java.lang.IllegalArgumentException,
                                      RegistrationException
Rejects name if a ConsumerGroup with the specified name already exists.

Specified by:
validateConsumerGroupName in interface RegistrationPolicy
Parameters:
groupName - the name of the ConsumerGroup to be created
Throws:
java.lang.IllegalArgumentException - if the specified ConsumerGroup name if null or empty
RegistrationException - if an exception occurred in the Registration service

setValidator

public void setValidator(RegistrationPropertyValidator validator)
Instructs this policy to use the specified RegistrationPropertyValidator. There shouldn't be any need to call this method manually, as the validator is configured via the WSRP Producer xml configuration file.

Parameters:
validator -

getValidator

public RegistrationPropertyValidator getValidator()
Retrieves the currently configured RegistrationPropertyValidator.

Returns: