Author: chris.laprun(a)jboss.com
Date: 2007-02-07 10:53:15 -0500 (Wed, 07 Feb 2007)
New Revision: 6184
Modified:
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
trunk/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
trunk/registration/src/main/org/jboss/portal/test/registration/RegistrationManagerTestCase.java
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/producer-config.xml
Log:
- Added javadoc for RegistrationPolicy.
- Renamed getGroupNameFor to getAutomaticGroupNameFor for clarity.
- Removed un-needed RegistrationPolicy service (if producer configuration doesn't
define one, DefaultRegistrationPolicy is automatically used) in test-wsrp-producer-sar.
Modified:
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2007-02-07
15:25:12 UTC (rev 6183)
+++
trunk/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2007-02-07
15:53:15 UTC (rev 6184)
@@ -26,37 +26,104 @@
import java.util.Map;
/**
+ * An interface allowing users of the Registration service to customize different aspects
of how Consumers are handled.
+ * Methods of this interface are used by RegistrationManager to make appropriate
decisions.
+ *
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
* @since 2.6
*/
public interface RegistrationPolicy
{
+ /**
+ * Examines and determines whether the given registration properties are adequate for
the Consumer associated with
+ * the given identity. This method is called before a Registration is created and thus
allows users to decide whether
+ * or not to reject a given registration if not satisfied with the given registration
properties.
+ *
+ * @param registrationProperties a Map containing the registration properties in the
form of property name (QName) -
+ * property value (Object) mappings
+ * @param consumerIdentity the Consumer identity (as returned by {@link
#getConsumerIdFrom(String,
+ *java.util.Map)}) for which the registration properties must be ascertained
+ * @throws IllegalArgumentException if any of the registration properties is invalid
for the specified Consumer
+ * @throws RegistrationException if an exception occured in the registration
service
+ */
void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException,
DuplicateRegistrationException;
+ throws IllegalArgumentException, RegistrationException;
- String createRegistrationHandleFor(String registrationId);
+ /**
+ * Generates a registration handle based on the database identity of the Registration.
This allows users to customize
+ * the registration handle format if they want to prevent exposure of database-related
data.
+ *
+ * @param registrationId the database identity of the Registration for which a handle
is required.
+ * @return a registration handle for the Registration associated with the specified
identifier.
+ * @throws IllegalArgumentException if the specified registration identity if
<code>null</code> or empty
+ */
+ String createRegistrationHandleFor(String registrationId) throws
IllegalArgumentException;
- String getGroupNameFor(String consumerName);
+ /**
+ * Determines the ConsumerGroup name to which the Consumer associated with the
specified name should be assigned with
+ * or <code>null</code> if the Consumer should not be automatically
assigned to a ConsumerGroup. This method is
+ * called during the Consumer creation process to see if the Consumer should be
automatically added to a
+ * ConsumerGroup.
+ *
+ * @param consumerName the name of the Consumer being created
+ * @return the name of the ConsumerGroup the Consumer must be automatically added to
or <code>null</code> if the
+ * Consumer will not be automatically to a ConsumerGroup at creation
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
+ */
+ String getAutomaticGroupNameFor(String consumerName) throws IllegalArgumentException;
/**
- * Obtain a consumer id in function of the consumer name and registration properties.
+ * Obtains a consumer identity which uniquely identifies a Consumer in function of the
consumer name and registration
+ * properties. This is potentially necessary because Consumer names are not guaranteed
to be unique (even though the
+ * specification states that they should).
*
* @param consumerName the consumer name
- * @param registrationProperties the provided registration properties
- * @return the consumer id
- * @throws IllegalArgumentException
- * @throws InvalidConsumerDataException
+ * @param 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.
+ * @return the consumer identity
+ * @throws InvalidConsumerDataException if the Policy examines the specified
registration properties to determine the
+ * Consumer identity and decides that they are
not in a proper state
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
*/
String getConsumerIdFrom(String consumerName, Map registrationProperties)
throws IllegalArgumentException, InvalidConsumerDataException;
+ /**
+ * Determines if the specified Consumer name is acceptable. This method is called
before a Consumer is created and
+ * before a unique Consumer identity is created. This is in particular used if the
Policy mandates that Consumer
+ * names must be unique.
+ *
+ * @param consumerName the name of the Consumer as passed during the registration
process
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
+ * @throws RegistrationException if an exception occurred in the Registration
service
+ */
void validateConsumerName(String consumerName)
throws IllegalArgumentException, RegistrationException;
+ /**
+ * Determines if the specified ConsumerGroup name is acceptable. This method is called
before a ConsumerGroup is
+ * created.
+ *
+ * @param groupName the name of the ConsumerGroup to be created
+ * @throws IllegalArgumentException if the specified ConsumerGroup name if
<code>null</code> or empty
+ * @throws RegistrationException if an exception occurred in the Registration
service
+ */
void validateConsumerGroupName(String groupName) throws IllegalArgumentException,
RegistrationException;
+ /**
+ * Retrieves the RegistrationManager with which this RegistrationPolicy is
associated.
+ *
+ * @return the RegistrationManager with which this RegistrationPolicy is associated.
+ */
RegistrationManager getManager();
+ /**
+ * 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.
+ *
+ * @param manager the RegistrationManager with which this RegistrationPolicy should be
associated.
+ */
void setManager(RegistrationManager manager);
}
Modified:
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java 2007-02-07
15:25:12 UTC (rev 6183)
+++
trunk/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java 2007-02-07
15:53:15 UTC (rev 6184)
@@ -119,7 +119,7 @@
// deal with group if needed
// let the policy decide if there should be a group associated with the Consumer
and if yes, with which id
- String groupName = policy.getGroupNameFor(name);
+ String groupName = policy.getAutomaticGroupNameFor(name);
if (groupName != null)
{
addConsumerToGroupNamed(name, groupName, true, false);
Modified:
trunk/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2007-02-07
15:25:12 UTC (rev 6183)
+++
trunk/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2007-02-07
15:53:15 UTC (rev 6184)
@@ -105,7 +105,7 @@
}
/** Doesn't support automatic ConsumerGroups so always return
<code>null</code>. */
- public String getGroupNameFor(String consumerName)
+ public String getAutomaticGroupNameFor(String consumerName)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"Consumer name", null);
return null;
Modified:
trunk/registration/src/main/org/jboss/portal/test/registration/RegistrationManagerTestCase.java
===================================================================
---
trunk/registration/src/main/org/jboss/portal/test/registration/RegistrationManagerTestCase.java 2007-02-07
15:25:12 UTC (rev 6183)
+++
trunk/registration/src/main/org/jboss/portal/test/registration/RegistrationManagerTestCase.java 2007-02-07
15:53:15 UTC (rev 6184)
@@ -145,7 +145,7 @@
// use a different policy: now specifies that when creating a consumer, it should
be added to a group with the same name
DefaultRegistrationPolicy policy = new DefaultRegistrationPolicy()
{
- public String getGroupNameFor(String consumerName)
+ public String getAutomaticGroupNameFor(String consumerName)
{
return "group_" + consumerName;
}
Modified:
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2007-02-07
15:25:12 UTC (rev 6183)
+++
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2007-02-07
15:53:15 UTC (rev 6184)
@@ -164,19 +164,11 @@
proxy-type="attribute">portal:service=WebAppRegistry</depends>
</mbean>
- <!-- Use DefaultRegistrationPolicy for registration -->
- <mbean
code="org.jboss.portal.registration.policies.DefaultRegistrationPolicy"
- name="portal.wsrp:service=RegistrationPolicy" xmbean-dd=""
-
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean>
-
<!-- Registration manager -->
<mbean code="org.jboss.portal.registration.impl.RegistrationManagerImpl"
name="portal.wsrp:service=RegistrationManager"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends optional-attribute-name="Policy"
proxy-type="attribute">portal.wsrp:service=RegistrationPolicy</depends>
<depends optional-attribute-name="PersistenceManager"
proxy-type="attribute">portal.wsrp:service=PersistenceManager</depends>
</mbean>
Modified: trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/producer-config.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/producer-config.xml 2007-02-07
15:25:12 UTC (rev 6183)
+++ trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/producer-config.xml 2007-02-07
15:53:15 UTC (rev 6184)
@@ -1,6 +1,6 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ JBoss, a division of Red Hat ~
- ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ Copyright 2007, Red Hat Middleware, LLC, and individual ~
~ contributors as indicated by the @authors tag. See the ~
~ copyright.txt in the distribution for a full listing of ~
~ individual contributors. ~
Show replies by date