Author: chris.laprun(a)jboss.com
Date: 2006-11-25 14:35:00 -0500 (Sat, 25 Nov 2006)
New Revision: 5720
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
Log:
- RegistrationManager is now an interface for MBeans wiring.
- DefaultRegistrationPolicy and RegistrationPersistenceManagerImpl are now services and
injected in RegistrationManager.
- Producer tests now work again (except for RegistrationTestCase which is being worked
on).
- Implemented ConsumerCapabilities and moved consumer agent to Consumer.
- Added services wiring.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -28,7 +28,9 @@
import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import
org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -46,9 +48,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
group = manager.createConsumerGroup(NAME);
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -27,7 +27,9 @@
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import
org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -43,9 +45,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
consumer = manager.createConsumer("name");
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -32,6 +32,7 @@
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import
org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -53,9 +54,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
registrationProperties = new HashMap();
registrationProperties.put(new QName("prop1"), "value1");
registrationProperties.put(new QName("prop2"), "value2");
@@ -136,13 +139,15 @@
public void testCreateConsumerWithGroupFromPolicy() throws RegistrationException
{
// use a different policy: now specifies that when creating a consumer, it should
be added to a group with the same name
- manager.setPolicy(new DefaultRegistrationPolicy()
+ DefaultRegistrationPolicy policy = new DefaultRegistrationPolicy()
{
public String getGroupNameFor(String consumerName)
{
return consumerName;
}
- });
+ };
+ manager.setPolicy(policy);
+ policy.setManager(manager);
String name = "name";
Consumer consumer = manager.createConsumer(name);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-23
22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -30,17 +30,25 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.core.RegistrationState;
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
+import org.jboss.portal.wsrp.producer.registration.api.Consumer;
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
import org.jboss.portal.wsrp.producer.registration.api.Registration;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
-import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
-import org.jboss.portal.common.FixMe;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import javax.xml.namespace.QName;
import java.rmi.RemoteException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -51,23 +59,12 @@
{
private final Logger log = Logger.getLogger(getClass());
- private RegistrationPolicy policy;
RegistrationHandler(WSRPProducerImpl producer)
{
super(producer);
}
- public RegistrationPolicy getPolicy()
- {
- return policy;
- }
-
- public void setPolicy(RegistrationPolicy policy)
- {
- this.policy = policy;
- }
-
public RegistrationContext register(RegistrationData registrationData) throws
MissingParametersFault, OperationFailedFault,
RemoteException
{
@@ -77,25 +74,31 @@
String consumerAgent = registrationData.getConsumerAgent();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(consumerAgent, "consumer
agent", "RegistrationData");
- throwOperationFailedFaultIfInvalid(consumerAgent);
-// Registration registration;
-// try
-// {
-// log.debug("Attempting to register consumer named '" +
consumerName + "', agent '" + consumerAgent + "'.");
-// // delegate to the policy the details on how to handle the registration
-// registration = policy.registerConsumerWith(registrationData);
-// }
-// catch (RegistrationException e)
-// {
-// log.debug(e);
-// throw WSRPUtils.createOperationFailedFault(e);
-// }
-//
-// RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext(registration.getId());
-// log.debug("Registration completed without error.");
-// return registrationContext;
- throw new FixMe();
+ Registration registration;
+ try
+ {
+ log.debug("Attempting to register consumer named '" + consumerName
+ "', agent '" + consumerAgent + "'.");
+
+ registration = producer.getRegistrationManager().addRegistrationTo(consumerName,
createRegistrationProperties(registrationData), true);
+ Consumer consumer = registration.getConsumer();
+ consumer.setConsumerAgent(consumerAgent);
+ ConsumerCapabilities capabilities = consumer.getCapabilities();
+
capabilities.setSupportedModes(getListFromArray(registrationData.getConsumerModes(),
false));
+
capabilities.setSupportedWindowStates(getListFromArray(registrationData.getConsumerWindowStates(),
false));
+
capabilities.setSupportedUserProfileData(getListFromArray(registrationData.getCustomUserProfileData(),
false));
+
capabilities.setSupportedUserScopes(getListFromArray(registrationData.getConsumerUserScopes(),
false));
+ capabilities.setSupportsGetMethod(registrationData.isMethodGetSupported());
+ }
+ catch (RegistrationException e)
+ {
+ log.debug(e);
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+
+ RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext(registration.getId());
+ log.debug("Registration completed without error.");
+ return registrationContext;
}
public ReturnAny deregister(RegistrationContext deregister) throws
OperationFailedFault, InvalidRegistrationFault,
@@ -112,34 +115,48 @@
return null; // todo: implement
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault
+ public boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
{
-// if (policy.getMetaData().requiresRegistration())
-// {
-// log.debug("registration required: checking registration");
-// if (registrationContext == null)
-// {
-// log.debug("registration is required yet no RegistrationContext was
provided!");
-// return false;
-// }
-//
-// String regHandle = registrationContext.getRegistrationHandle();
-// if (regHandle == null)
-// {
-// throwInvalidRegistrationFault("missing required registration
handle!");
-// }
-//
-// return true;
-// }
-// else
-// {
-// if (registrationContext != null)
-// {
-// throwInvalidRegistrationFault("no registration necessary yet one was
provided!");
-// }
-// return true;
-// }
- throw new FixMe();
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("registration required: checking registration");
+ if (registrationContext == null)
+ {
+ log.debug("registration is required yet no RegistrationContext was
provided!");
+ return false;
+ }
+
+ String regHandle = registrationContext.getRegistrationHandle();
+ if (regHandle == null)
+ {
+ throwInvalidRegistrationFault("missing required registration
handle!");
+ }
+
+ try
+ {
+ Registration reg =
producer.getRegistrationManager().getRegistration(regHandle);
+ if (RegistrationStatus.VALID.equals(reg.getStatus()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (RegistrationException e)
+ {
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+ }
+ else
+ {
+ if (registrationContext != null)
+ {
+ throwInvalidRegistrationFault("no registration necessary yet one was
provided!");
+ }
+ return true;
+ }
}
private boolean throwInvalidRegistrationFault(String message) throws
InvalidRegistrationFault
@@ -148,21 +165,27 @@
new Exception("Invalid registration: " + message));
}
- private void throwOperationFailedFaultIfInvalid(String consumerAgent) throws
OperationFailedFault
+ private Map createRegistrationProperties(RegistrationData registrationData)
{
- char periodChar = '.';
- int period = consumerAgent.indexOf(periodChar);
- if (period != -1)
+ Property[] regProperties = registrationData.getRegistrationProperties();
+ Map properties = new HashMap(regProperties.length);
+
+ for (int i = 0; i < regProperties.length; i++)
{
- consumerAgent = consumerAgent.substring(period);
- period = consumerAgent.indexOf(periodChar);
+ Property property = regProperties[i];
+ // todo: should be more detailed here... use the language, allow other value
types...
+ properties.put(new QName(property.getName()), property.getStringValue());
+ }
- if (period != -1)
- {
- return;
- }
+ return properties;
+ }
+
+ private List getListFromArray(String[] array, boolean useEmptyForNull)
+ {
+ if (array == null)
+ {
+ return useEmptyForNull ? Collections.EMPTY_LIST : null;
}
- throw WSRPUtils.createOperationFailedFault(new
IllegalArgumentException(consumerAgent
- + " is not a valid Consumer Agent."));
+ return Arrays.asList(array);
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -23,8 +23,7 @@
package org.jboss.portal.wsrp.producer;
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.FixMe;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.LocaleInfo;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.portlet.Portlet;
@@ -75,13 +74,13 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(gs,
"GetServiceDescription");
-// if
(producer.getRegistrationPolicy().getMetaData().fullServiceDescriptionRequiresRegistration()
&& !producer.isRegistrationValid(gs.getRegistrationContext()))
-// {
-// return getRegistrationNotProvidedServiceDescription();
-// }
-// log.debug("Returning complete service description");
-// return refreshServiceDescription(gs.getDesiredLocales());
- throw new FixMe();
+ if
(producer.getProducerRegistrationRequirements().fullServiceDescriptionRequiresRegistration()
+ && !producer.isRegistrationValid(gs.getRegistrationContext()))
+ {
+ return getRegistrationNotProvidedServiceDescription();
+ }
+ log.debug("Returning complete service description");
+ return refreshServiceDescription(gs.getDesiredLocales());
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-23
22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -75,6 +75,7 @@
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import org.jboss.portal.wsrp.producer.registration.config.RegistrationConfiguration;
import
org.jboss.portal.wsrp.producer.registration.impl.ProducerRegistrationRequirementsImpl;
import org.jboss.portal.wsrp.servlet.ServletAccess;
@@ -115,6 +116,9 @@
/** Registration configuration service */
private RegistrationConfiguration registrationConfiguration;
+ /** Registration Manager */
+ private RegistrationManager registrationManager;
+
private static final ProducerRegistrationRequirements
DEFAULT_REGISTRATION_REQUIREMENTS =
new ProducerRegistrationRequirementsImpl(false, false, false);
@@ -273,6 +277,16 @@
this.registrationConfiguration = registrationConfiguration;
}
+ public RegistrationManager getRegistrationManager()
+ {
+ return registrationManager;
+ }
+
+ public void setRegistrationManager(RegistrationManager registrationManager)
+ {
+ this.registrationManager = registrationManager;
+ }
+
// PortletManagement implementation
*********************************************************************************
public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
@@ -451,12 +465,12 @@
* @return <code>true</code> if the registration (when registration is
required) information is valid or if no
* registration is required, <code>false</code> otherwise
(registration required, invalid information).
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault
+ protected boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
{
return registrationHandler.isRegistrationValid(registrationContext);
}
- protected void checkRegistration(RegistrationContext registrationContext) throws
InvalidRegistrationFault
+ protected void checkRegistration(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
{
if (!isRegistrationValid(registrationContext))
{
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -86,4 +86,8 @@
void setCapabilities(ConsumerCapabilities capabilities);
void setGroup(ConsumerGroup group) throws RegistrationException,
DuplicateRegistrationException;
+
+ String getConsumerAgent();
+
+ void setConsumerAgent(String consumerAgent) throws IllegalArgumentException,
IllegalStateException;
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -32,8 +32,6 @@
*/
public interface ConsumerCapabilities
{
- String getConsumerAgent();
-
boolean supportsGetMethod();
List getSupportedModes();
@@ -43,4 +41,14 @@
List getSupportedUserScopes();
List getSupportedUserProfileData();
+
+ void setSupportsGetMethod(boolean supportsGetMethod);
+
+ void setSupportedModes(List supportedModes);
+
+ void setSupportedWindowStates(List supportedWindowStates);
+
+ void setSupportedUserScopes(List supportedUserScopes);
+
+ void setSupportedUserProfileData(List supportedUserProfileData);
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -23,13 +23,7 @@
package org.jboss.portal.wsrp.producer.registration.api;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.portal.common.util.ParameterValidation;
-
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
import java.util.Map;
/**
@@ -37,284 +31,47 @@
* @version $Revision$
* @since 2.6
*/
-public class RegistrationManager
+public interface RegistrationManager
{
- private RegistrationPolicy policy;
- private RegistrationPersistenceManager persistenceManager;
- private Map registrations;
+ RegistrationPolicy getPolicy();
+ void setPolicy(RegistrationPolicy policy);
- public RegistrationManager()
- {
- registrations = new ConcurrentHashMap();
- }
+ RegistrationPersistenceManager getPersistenceManager();
- public RegistrationPolicy getPolicy()
- {
- return policy;
- }
+ void setPersistenceManager(RegistrationPersistenceManager persistenceManager);
- public void setPolicy(RegistrationPolicy policy)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(policy,
"RegistrationPolicy");
- this.policy = policy;
- policy.setManager(this);
- }
+ Registration addRegistrationTo(String consumerName, Map registrationProperties,
boolean createConsumerIfNeeded)
+ throws RegistrationException;
- public RegistrationPersistenceManager getPersistenceManager()
- {
- return persistenceManager;
- }
+ Consumer createConsumer(String name) throws RegistrationException,
InvalidConsumerDataException;
- public void setPersistenceManager(RegistrationPersistenceManager persistenceManager)
- {
- this.persistenceManager = persistenceManager;
- }
+ Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean
createGroupIfNeeded,
+ boolean createConsumerIfNeeded) throws
RegistrationException;
- public Registration addRegistrationTo(String consumerName, Map registrationProperties,
boolean createConsumerIfNeeded)
- throws RegistrationException
- {
- // the policy determines the identity of the consumer based on the given
information (note that this might be obsoleted by using WS-Security)
- String identity = policy.getConsumerIdentityFrom(consumerName,
registrationProperties);
+ ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException;
- // validate the registration information
- policy.validateRegistrationDataFor(registrationProperties, identity);
+ void removeConsumer(String identity) throws RegistrationException,
NoSuchRegistrationException;
- Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded,
consumerName);
+ void removeConsumer(Consumer consumer) throws RegistrationException,
NoSuchRegistrationException;
- // create the actual registration
- Registration registration = persistenceManager.addRegistrationFor(identity,
registrationProperties);
+ Consumer getConsumerByIdentity(String identity) throws RegistrationException;
- // let the policy decide what the handle should be
- String handle = policy.createRegistrationHandleFor(registration.getId());
- registration.setRegistrationHandle(handle);
+ Consumer getConsumerFor(String registrationHandle) throws RegistrationException;
- // associate the handle to the consumer for easy retrieval
- registrations.put(handle, new ConsumerRegistration(registration, consumer));
+ Registration getRegistration(String registrationHandle) throws RegistrationException;
- return registration;
- }
+ void removeRegistration(String registrationHandle) throws RegistrationException,
NoSuchRegistrationException;
- public Consumer createConsumer(String name) throws RegistrationException,
InvalidConsumerDataException
- {
- // check with policy if we allow the consumer
- policy.validateConsumerName(name);
+ void removeRegistration(Registration registration) throws RegistrationException,
NoSuchRegistrationException;
- String identity = policy.getConsumerIdentityFrom(name, Collections.EMPTY_MAP);
+ ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException;
- Consumer consumer = persistenceManager.createConsumer(identity, name);
+ Collection getConsumerGroups() throws RegistrationException;
- // 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(consumer.getName());
- if (groupName != null)
- {
- addConsumerToGroupNamed(groupName, groupName, true, false);
- }
+ void removeConsumerGroup(ConsumerGroup group) throws RegistrationException;
- return consumer;
- }
+ void removeConsumerGroup(String name) throws RegistrationException;
- public Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean
createGroupIfNeeded, boolean createConsumerIfNeeded) throws RegistrationException
- {
- // check with the policy if we allow the group name in case we need to create it
- if (createGroupIfNeeded)
- {
- policy.validateConsumerGroupName(groupName);
- }
-
- // check with policy if we allow the consumer name in case we need to create it
- if (createConsumerIfNeeded)
- {
- policy.validateConsumerName(consumerName);
- }
-
- ConsumerGroup group = getConsumerGroup(groupName);
- boolean justCreatedGroup = false;
- if (group == null)
- {
- if (createGroupIfNeeded)
- {
- createConsumerGroup(groupName);
- justCreatedGroup = true;
- }
- else
- {
- throw new NoSuchRegistrationException("There is no existing
ConsumerGroup named '" + groupName + "'.");
- }
- }
-
- String identity = policy.getConsumerIdentityFrom(consumerName,
Collections.EMPTY_MAP);
- try
- {
- getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
- }
- catch (NoSuchRegistrationException e)
- {
- if (justCreatedGroup)
- {
- removeConsumerGroup(groupName);
- }
- }
-
- return persistenceManager.addConsumerToGroupNamed(identity, groupName);
- }
-
- public ConsumerGroup createConsumerGroup(String groupName) throws
RegistrationException
- {
- // check with the policy if we allow the group
- policy.validateConsumerGroupName(groupName);
-
- return persistenceManager.createConsumerGroup(groupName);
- }
-
- public void removeConsumer(String identity) throws RegistrationException,
NoSuchRegistrationException
- {
- Consumer consumer = getOrCreateConsumer(identity, false, null);
-
- ConsumerGroup group = consumer.getGroup();
- if (group != null)
- {
- group.removeConsumer(consumer);
- }
-
- // cascade delete the registrations
- for (Iterator i = new ArrayList(consumer.getRegistrations()).iterator();
i.hasNext();)
- {
- removeRegistration((Registration)i.next());
- }
-
- // let the registry do the actual deletion
- persistenceManager.removeConsumer(identity);
- }
-
- public void removeConsumer(Consumer consumer) throws RegistrationException,
NoSuchRegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
-
- removeConsumer(consumer.getIdentity());
- }
-
- public Consumer getConsumerByIdentity(String identity) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity,
"identity", null);
- return persistenceManager.getConsumerByIdentity(identity);
- }
-
- public Consumer getConsumerFor(String registrationHandle) throws
RegistrationException
- {
- return (Consumer)getConsumerOrRegistration(registrationHandle, true);
- }
-
- public Registration getRegistration(String registrationHandle) throws
RegistrationException
- {
- return (Registration)getConsumerOrRegistration(registrationHandle, false);
- }
-
- public void removeRegistration(String registrationHandle) throws
RegistrationException, NoSuchRegistrationException
- {
- Registration registration = getRegistration(registrationHandle);
- if (registration == null)
- {
- throw new NoSuchRegistrationException("There is no Registration with handle
'" + registrationHandle + "'");
- }
- removeRegistration(registration);
- }
-
- public void removeRegistration(Registration registration) throws
RegistrationException, NoSuchRegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
- String handle = registration.getRegistrationHandle();
- Consumer consumer = getConsumerFor(handle);
-
- if (consumer == null)
- {
- throw new NoSuchRegistrationException("Could not locate a Consumer for
Registration with handle '" + handle
- + "' (id: '" + registration.getId() + "')");
- }
-
- persistenceManager.removeRegistration(registration.getId());
- registrations.remove(registration.getRegistrationHandle());
- }
-
- public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName,
"ConsumerGroup name", null);
- return persistenceManager.getConsumerGroup(groupName);
- }
-
- private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded,
String consumerName)
- throws RegistrationException
- {
- Consumer consumer = getConsumerByIdentity(identity);
- if (consumer == null)
- {
- if (createConsumerIfNeeded)
- {
- consumer = createConsumer(consumerName);
- }
- else
- {
- throw new NoSuchRegistrationException("There is no Consumer named
'" + consumerName + "'.");
- }
- }
- return consumer;
- }
-
- private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
- // this particular implementations uses a map though it could delegate to the
registry and make a DB query to retrieve the info
- ConsumerRegistration cr =
(ConsumerRegistration)registrations.get(registrationHandle);
-
- if (cr != null)
- {
- return (getConsumer ? (Object)cr.consumer : cr.registration);
- }
- else
- {
- return null;
- }
- }
-
- public Collection getConsumerGroups()
- {
- return persistenceManager.getConsumerGroups();
- }
-
- public void removeConsumerGroup(ConsumerGroup group) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(group,
"ConsumerGroup");
-
- for (Iterator consumers = group.getConsumers().iterator(); consumers.hasNext();)
- {
- removeConsumer((Consumer)consumers.next());
- }
-
- persistenceManager.removeConsumerGroup(group.getName());
- }
-
- public void removeConsumerGroup(String name) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(name, "ConsumerGroup
name");
- removeConsumerGroup(getConsumerGroup(name));
- }
-
- public Collection getConsumers()
- {
- return persistenceManager.getConsumers();
- }
-
- private static class ConsumerRegistration
- {
- private Registration registration;
- private Consumer consumer;
-
-
- public ConsumerRegistration(Registration registration, Consumer consumer)
- {
- this.registration = registration;
- this.consumer = consumer;
- }
- }
+ Collection getConsumers() throws RegistrationException;
}
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.producer.registration.impl;
+
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerCapabilitiesImpl implements ConsumerCapabilities
+{
+ private boolean supportsGetMethod;
+ private List supportedModes;
+ private List supportedWindowStates;
+ private List supportedUserScopes;
+ private List supportedUserProfileData;
+
+ public boolean supportsGetMethod()
+ {
+ return supportsGetMethod;
+ }
+
+ public List getSupportedModes()
+ {
+ return supportedModes;
+ }
+
+ public List getSupportedWindowStates()
+ {
+ return supportedWindowStates;
+ }
+
+ public List getSupportedUserScopes()
+ {
+ return supportedUserScopes;
+ }
+
+ public List getSupportedUserProfileData()
+ {
+ return supportedUserProfileData;
+ }
+
+ public void setSupportsGetMethod(boolean supportsGetMethod)
+ {
+ this.supportsGetMethod = supportsGetMethod;
+ }
+
+ public void setSupportedModes(List supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public void setSupportedWindowStates(List supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public void setSupportedUserScopes(List supportedUserScopes)
+ {
+ this.supportedUserScopes = supportedUserScopes;
+ }
+
+ public void setSupportedUserProfileData(List supportedUserProfileData)
+ {
+ this.supportedUserProfileData = supportedUserProfileData;
+ }
+}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -46,10 +46,12 @@
private String name;
private String identity;
+ private String consumerAgent;
private Set registrations;
private RegistrationStatus status;
private ConsumerGroup group;
private ConsumerCapabilities capabilities;
+ private boolean agentSet = false;
private ConsumerImpl()
@@ -71,6 +73,7 @@
{
registrations = new HashSet(7);
status = RegistrationStatus.PENDING;
+ capabilities = new ConsumerCapabilitiesImpl();
}
@@ -105,6 +108,24 @@
return identity;
}
+
+ public String getConsumerAgent()
+ {
+ return consumerAgent;
+ }
+
+ public void setConsumerAgent(String consumerAgent) throws IllegalArgumentException,
IllegalStateException
+ {
+ if (agentSet)
+ {
+ throw new IllegalStateException("Cannot modify the agent of a
Consumer!");
+ }
+
+ validate(consumerAgent);
+ this.consumerAgent = consumerAgent;
+ agentSet = true;
+ }
+
public ConsumerCapabilities getCapabilities()
{
return capabilities;
@@ -173,4 +194,21 @@
group.addConsumer(this);
}
}
+
+ private void validate(String consumerAgent) throws IllegalArgumentException
+ {
+ char periodChar = '.';
+ int period = consumerAgent.indexOf(periodChar);
+ if (period != -1)
+ {
+ consumerAgent = consumerAgent.substring(period);
+ period = consumerAgent.indexOf(periodChar);
+
+ if (period != -1)
+ {
+ return;
+ }
+ }
+ throw new IllegalArgumentException(consumerAgent + " is not a valid Consumer
Agent.");
+ }
}
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -0,0 +1,342 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.producer.registration.impl;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.wsrp.producer.registration.api.Consumer;
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
+import org.jboss.portal.wsrp.producer.registration.api.InvalidConsumerDataException;
+import org.jboss.portal.wsrp.producer.registration.api.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.Registration;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationManagerImpl extends AbstractJBossService implements
RegistrationManager
+{
+ private RegistrationPolicy policy;
+ private RegistrationPersistenceManager persistenceManager;
+ private Map registrations;
+
+
+ public RegistrationManagerImpl()
+ {
+ registrations = new ConcurrentHashMap();
+ }
+
+ public RegistrationPolicy getPolicy()
+ {
+ return policy;
+ }
+
+ public void setPolicy(RegistrationPolicy policy)
+ {
+ this.policy = policy;
+ }
+
+ public RegistrationPersistenceManager getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public void setPersistenceManager(RegistrationPersistenceManager persistenceManager)
+ {
+ this.persistenceManager = persistenceManager;
+ }
+
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+ policy.setManager(this);
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ policy.setManager(null);
+ super.stopService();
+ }
+
+ public Registration addRegistrationTo(String consumerName, Map registrationProperties,
boolean createConsumerIfNeeded)
+ throws RegistrationException
+ {
+ // the policy determines the identity of the consumer based on the given
information (note that this might be obsoleted by using WS-Security)
+ String identity = policy.getConsumerIdentityFrom(consumerName,
registrationProperties);
+
+ // validate the registration information
+ policy.validateRegistrationDataFor(registrationProperties, identity);
+
+ Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded,
consumerName);
+
+ // create the actual registration
+ Registration registration = persistenceManager.addRegistrationFor(identity,
registrationProperties);
+
+ // let the policy decide what the handle should be
+ String handle = policy.createRegistrationHandleFor(registration.getId());
+ registration.setRegistrationHandle(handle);
+
+ // associate the handle to the consumer for easy retrieval
+ registrations.put(handle, new ConsumerRegistration(registration, consumer));
+
+ return registration;
+ }
+
+ public Consumer createConsumer(String name) throws RegistrationException,
InvalidConsumerDataException
+ {
+ // check with policy if we allow the consumer
+ policy.validateConsumerName(name);
+
+ String identity = policy.getConsumerIdentityFrom(name, Collections.EMPTY_MAP);
+
+ Consumer consumer = persistenceManager.createConsumer(identity, name);
+
+ // 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(consumer.getName());
+ if (groupName != null)
+ {
+ addConsumerToGroupNamed(groupName, groupName, true, false);
+ }
+
+ return consumer;
+ }
+
+ public Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean
createGroupIfNeeded, boolean createConsumerIfNeeded) throws RegistrationException
+ {
+ // check with the policy if we allow the group name in case we need to create it
+ if (createGroupIfNeeded)
+ {
+ policy.validateConsumerGroupName(groupName);
+ }
+
+ // check with policy if we allow the consumer name in case we need to create it
+ if (createConsumerIfNeeded)
+ {
+ policy.validateConsumerName(consumerName);
+ }
+
+ ConsumerGroup group = getConsumerGroup(groupName);
+ boolean justCreatedGroup = false;
+ if (group == null)
+ {
+ if (createGroupIfNeeded)
+ {
+ createConsumerGroup(groupName);
+ justCreatedGroup = true;
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no existing
ConsumerGroup named '" + groupName + "'.");
+ }
+ }
+
+ String identity = policy.getConsumerIdentityFrom(consumerName,
Collections.EMPTY_MAP);
+ try
+ {
+ getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
+ }
+ catch (NoSuchRegistrationException e)
+ {
+ if (justCreatedGroup)
+ {
+ removeConsumerGroup(groupName);
+ }
+ }
+
+ return persistenceManager.addConsumerToGroupNamed(identity, groupName);
+ }
+
+ public ConsumerGroup createConsumerGroup(String groupName) throws
RegistrationException
+ {
+ // check with the policy if we allow the group
+ policy.validateConsumerGroupName(groupName);
+
+ return persistenceManager.createConsumerGroup(groupName);
+ }
+
+ public void removeConsumer(String identity) throws RegistrationException,
NoSuchRegistrationException
+ {
+ Consumer consumer = getOrCreateConsumer(identity, false, null);
+
+ ConsumerGroup group = consumer.getGroup();
+ if (group != null)
+ {
+ group.removeConsumer(consumer);
+ }
+
+ // cascade delete the registrations
+ for (Iterator i = new ArrayList(consumer.getRegistrations()).iterator();
i.hasNext();)
+ {
+ removeRegistration((Registration)i.next());
+ }
+
+ // let the registry do the actual deletion
+ persistenceManager.removeConsumer(identity);
+ }
+
+ public void removeConsumer(Consumer consumer) throws RegistrationException,
NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ removeConsumer(consumer.getIdentity());
+ }
+
+ public Consumer getConsumerByIdentity(String identity) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity,
"identity", null);
+ return persistenceManager.getConsumerByIdentity(identity);
+ }
+
+ public Consumer getConsumerFor(String registrationHandle) throws
RegistrationException
+ {
+ return (Consumer)getConsumerOrRegistration(registrationHandle, true);
+ }
+
+ public Registration getRegistration(String registrationHandle) throws
RegistrationException
+ {
+ return (Registration)getConsumerOrRegistration(registrationHandle, false);
+ }
+
+ public void removeRegistration(String registrationHandle) throws
RegistrationException, NoSuchRegistrationException
+ {
+ Registration registration = getRegistration(registrationHandle);
+ if (registration == null)
+ {
+ throw new NoSuchRegistrationException("There is no Registration with handle
'" + registrationHandle + "'");
+ }
+ removeRegistration(registration);
+ }
+
+ public void removeRegistration(Registration registration) throws
RegistrationException, NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
+ String handle = registration.getRegistrationHandle();
+ Consumer consumer = getConsumerFor(handle);
+
+ if (consumer == null)
+ {
+ throw new NoSuchRegistrationException("Could not locate a Consumer for
Registration with handle '" + handle
+ + "' (id: '" + registration.getId() + "')");
+ }
+
+ persistenceManager.removeRegistration(registration.getId());
+ registrations.remove(registration.getRegistrationHandle());
+ }
+
+ public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName,
"ConsumerGroup name", null);
+ return persistenceManager.getConsumerGroup(groupName);
+ }
+
+ private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded,
String consumerName)
+ throws RegistrationException
+ {
+ Consumer consumer = getConsumerByIdentity(identity);
+ if (consumer == null)
+ {
+ if (createConsumerIfNeeded)
+ {
+ consumer = createConsumer(consumerName);
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no Consumer named
'" + consumerName + "'.");
+ }
+ }
+ return consumer;
+ }
+
+ private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
+ // this particular implementations uses a map though it could delegate to the
registry and make a DB query to retrieve the info
+ ConsumerRegistration cr =
(ConsumerRegistration)registrations.get(registrationHandle);
+
+ if (cr != null)
+ {
+ return (getConsumer ? (Object)cr.consumer : cr.registration);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Collection getConsumerGroups()
+ {
+ return persistenceManager.getConsumerGroups();
+ }
+
+ public void removeConsumerGroup(ConsumerGroup group) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(group,
"ConsumerGroup");
+
+ for (Iterator consumers = group.getConsumers().iterator(); consumers.hasNext();)
+ {
+ removeConsumer((Consumer)consumers.next());
+ }
+
+ persistenceManager.removeConsumerGroup(group.getName());
+ }
+
+ public void removeConsumerGroup(String name) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "ConsumerGroup
name");
+ removeConsumerGroup(getConsumerGroup(name));
+ }
+
+ public Collection getConsumers()
+ {
+ return persistenceManager.getConsumers();
+ }
+
+ private static class ConsumerRegistration
+ {
+ private Registration registration;
+ private Consumer consumer;
+
+
+ public ConsumerRegistration(Registration registration, Consumer consumer)
+ {
+ this.registration = registration;
+ this.consumer = consumer;
+ }
+ }
+}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-25
19:35:00 UTC (rev 5720)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer.registration.impl;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
import org.jboss.portal.wsrp.producer.registration.api.DuplicateRegistrationException;
@@ -43,7 +44,7 @@
* @version $Revision$
* @since 2.6
*/
-public class RegistrationPersistenceManagerImpl implements
RegistrationPersistenceManager
+public class RegistrationPersistenceManagerImpl extends AbstractJBossService implements
RegistrationPersistenceManager
{
private long lastRegistrationId;
private Map consumers = new HashMap();
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-23
22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-25
19:35:00 UTC (rev 5720)
@@ -80,14 +80,16 @@
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=WSRPProducer</depends>
<depends optional-attribute-name="RegistrationConfiguration"
proxy-type="attribute">portal.wsrp:service=RegistrationConfiguration</depends>
+ <depends optional-attribute-name="RegistrationManager"
proxy-type="attribute">portal.wsrp:service=RegistrationManager</depends>
</mbean>
- <!-- Configure a consumer that is the portal itself -->
- <mbean
- code="org.jboss.portal.wsrp.deployment.WSRPDeployer"
- name="portal.wsrp:service=WSRPDeployer">
- <attribute
name="DefaultWSRPLocation">default-wsrp.xml</attribute>
- <depends optional-attribute-name="FederatingPortletInvoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
+ <!-- Registration manager -->
+ <mbean
code="org.jboss.portal.wsrp.producer.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>
<!-- Registration policy -->
@@ -97,6 +99,13 @@
<xmbean/>
</mbean>
+ <!-- Persistence manager for registrations -->
+ <mbean
code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl"
+ name="portal.wsrp:service=PersistenceManager" xmbean-dd=""
+
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
<!-- Registration configuration service -->
<mbean
code="org.jboss.portal.wsrp.producer.registration.config.RegistrationConfigurationService"
name="portal.wsrp:service=RegistrationConfiguration"
xmbean-dd=""
@@ -104,5 +113,13 @@
<xmbean/>
<attribute name="ConfigLocation">conf/config.xml</attribute>
</mbean>
+
+ <!-- Configure a consumer that is the portal itself -->
+ <mbean
+ code="org.jboss.portal.wsrp.deployment.WSRPDeployer"
+ name="portal.wsrp:service=WSRPDeployer">
+ <attribute
name="DefaultWSRPLocation">default-wsrp.xml</attribute>
+ <depends optional-attribute-name="FederatingPortletInvoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
+ </mbean>
</server>
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 2006-11-23
22:49:44 UTC (rev 5719)
+++
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2006-11-25
19:35:00 UTC (rev 5720)
@@ -174,8 +174,32 @@
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Stateful</depends>
<attribute name="RemotableByDefault">true</attribute>
+ <depends optional-attribute-name="RegistrationManager"
proxy-type="attribute">portal.wsrp:service=RegistrationManager</depends>
</mbean>
+ <!-- Registration manager -->
+ <mbean
code="org.jboss.portal.wsrp.producer.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>
+
+ <!-- Use DefaultRegistrationPolicy for registration -->
+ <mbean
code="org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy"
+ name="portal.wsrp:service=RegistrationPolicy" xmbean-dd=""
+
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <!-- Persistence manager for registrations -->
+ <mbean
code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl"
+ name="portal.wsrp:service=PersistenceManager" xmbean-dd=""
+
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
<!-- Hack to get access to req/resp -->
<mbean
code="org.jboss.portal.wsrp.servlet.ServletAccessService"