[jboss-svn-commits] JBoss Portal SVN: r5598 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: producer producer/registration producer/registration/impl producer/registration/policies registration

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Nov 7 22:20:08 EST 2006


Author: chris.laprun at jboss.com
Date: 2006-11-07 22:19:54 -0500 (Tue, 07 Nov 2006)
New Revision: 5598

Added:
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchRegistrationException.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationException.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationFailedException.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationStatus.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerMetaDataImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
Removed:
   trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/
Modified:
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.java
Log:
More registration work:
- Consolidated packages.
- Added ConsumerMetaData concept.
- Added basic implementations.
- Added basic policy for inline registration.
- Probably doesn't work but a good commit point...

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-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -35,8 +35,11 @@
 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.Consumer;
 import org.jboss.portal.wsrp.producer.registration.Registration;
-import org.jboss.portal.wsrp.producer.registration.RegistrationRegistry;
+import org.jboss.portal.wsrp.producer.registration.RegistrationConversionException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
 
 import java.rmi.RemoteException;
 
@@ -49,13 +52,23 @@
 {
 
    private final Logger log = Logger.getLogger(getClass());
-   private RegistrationRegistry registry = new RegistrationRegistry();
+   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
    {
@@ -65,13 +78,33 @@
       String consumerAgent = registrationData.getConsumerAgent();
       WSRPUtils.throwMissingParametersFaultIfValueIsMissing(consumerAgent, "consumer agent", "RegistrationData");
 
-      Registration registration = registry.register(registrationData);
+      Consumer consumer;
+      Registration registration;
+      try
+      {
+         // delegate to the policy the details on how to handle the registration
+         registration = policy.registerConsumerWith(registrationData);
+      }
+      catch (RegistrationException e)
+      {
+         throw WSRPUtils.createOperationFailedFault(e);
+      }
+
       RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getRegistrationHandle());
-      byte[] registrationState = registration.getRegistrationState();
-      if (registrationState != null && registrationState.length > 0)
+
+      if (policy.requireRegistrationMarshalling())
       {
-         registrationContext.setRegistrationState(registrationState);
+         try
+         {
+            byte[] registrationState = policy.getRegistrationConverter().marshall(registration);
+            registrationContext.setRegistrationState(registrationState);
+         }
+         catch (RegistrationConversionException e)
+         {
+            throw WSRPUtils.createOperationFailedFault(e);
+         }
       }
+
       return registrationContext;
    }
 

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/Consumer.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/Consumer.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Collection;
+
+/**
+ * A well known consumer (a business entity) in the portal.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @author @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision: 1.1 $
+ * @since 2.6
+ */
+public interface Consumer
+{
+   /**
+    * Return the consumer name.
+    *
+    * @return the consumer name
+    */
+   String getName();
+
+   /**
+    * Return the registration status of the consumer entity.
+    *
+    * @return the registration stats.
+    */
+   RegistrationStatus getStatus();
+
+   /**
+    * Set the registration status of the consumer entity.
+    *
+    * @param status the registration status
+    */
+   void setStatus(RegistrationStatus status);
+
+   /**
+    * Return all the registrations for the specified consumer.
+    *
+    * @return the consumer registrations
+    */
+   Collection getRegistrations() throws RegistrationException;
+
+   /**
+    * Return a specific registration for this consumer.
+    *
+    * @param registrationHandle the registration handle
+    * @return the registration
+    */
+   Registration getRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException;
+
+   /**
+    * Add the given Registration to this Consumer.
+    *
+    * @param registration the Registration to be added
+    */
+   void addRegistration(Registration registration) throws RegistrationException;
+
+   /**
+    * Remove the Registration associated with the given handle from this Consumer's registrations.
+    *
+    * @param registrationHandle the registration handle
+    */
+   void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException;
+
+   /**
+    * Retrieves the metadata associated with this Consumer.
+    *
+    * @return the ConsumerMetaData associated with this Consumer
+    * @throws RegistrationException
+    */
+   ConsumerMetaData getMetaData() throws RegistrationException;
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public interface ConsumerMetaData
+{
+   String getConsumerAgent();
+
+   boolean supportsGetMethod();
+
+   List getSupportedModes();
+
+   List getSupportedWindowStates();
+
+   List getSupportedUserScopes();
+
+   List getSupportedUserProfileData();
+}

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/ConsumerRegistry.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/ConsumerRegistry.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ConsumerRegistry
+{
+   /**
+    * Return a collection of the known consumers.
+    *
+    * @return the consumer collection
+    */
+   Collection getConsumers() throws RegistrationException;
+
+   /**
+    * Return a specific consumer in the portal
+    *
+    * @param consumerName the consumer name
+    * @return the consumer registration
+    */
+   Consumer getConsumer(String consumerName) throws RegistrationException;
+
+   /**
+    * Adds the given Consumer to the list of registered Consumers.
+    *
+    * @param consumer the Consumer to be added
+    * @return the newly created consumer
+    */
+   void addConsumer(Consumer consumer) throws RegistrationException;
+
+   /**
+    * Removes the given consumer from the list of registered Consumers.
+    *
+    * @param consumerName the consumer name
+    */
+   void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException;
+}

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/NoSuchConsumerException.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/NoSuchConsumerException.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchConsumerException.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoSuchConsumerException extends RegistrationException
+{
+   public NoSuchConsumerException()
+   {
+   }
+
+   public NoSuchConsumerException(String message)
+   {
+      super(message);
+   }
+
+   public NoSuchConsumerException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+   public NoSuchConsumerException(Throwable cause)
+   {
+      super(cause);
+   }
+}

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchRegistrationException.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/NoSuchRegistrationException.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/NoSuchRegistrationException.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/NoSuchRegistrationException.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoSuchRegistrationException extends RegistrationException
+{
+   public NoSuchRegistrationException()
+   {
+   }
+
+   public NoSuchRegistrationException(String message)
+   {
+      super(message);
+   }
+
+   public NoSuchRegistrationException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+   public NoSuchRegistrationException(Throwable cause)
+   {
+      super(cause);
+   }
+}

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -23,61 +23,54 @@
 
 package org.jboss.portal.wsrp.producer.registration;
 
-import java.util.List;
+import org.jboss.portal.portlet.state.PropertyMap;
 
-
 /**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.Registration">Chris
- *         Laprun</a>
+ * A class representing an association between a consumer and a producer.
+ *
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  * @since 2.6
  */
-public class Registration
+public interface Registration
 {
-   private RegistrationMetaData registrationMetaData;
+   /**
+    * Retrieve the handle associated with this Registration
+    *
+    * @return the registration handle
+    */
+   String getRegistrationHandle();
 
-   public String getRegistrationHandle()
-   {
-      return null;  // todo: implement
-   }
+   /**
+    * Return the consumer owning this registration.
+    *
+    * @return the owning consumer
+    */
+   Consumer getConsumer();
 
-   public byte[] getRegistrationState()
-   {
-      return null; // todo: implement
-   }
+   /**
+    * Retrieve the properties associated with this Registration.
+    *
+    * @return a PropertyMap containing the associated properties
+    */
+   PropertyMap getProperties();
 
-   public boolean supportsGetMethod()
-   {
-      return false; // todo: implement
-   }
+   /**
+    * Return the status of this specific registration.
+    *
+    * @return the status
+    */
+   RegistrationStatus getStatus();
 
-   public List getSupportedModes()
-   {
-      return null; // todo: implement
-   }
+   /**
+    * Update the registration status
+    *
+    * @param status the new status
+    */
+   void setStatus(RegistrationStatus status);
 
-   public List getSupportedWindowStates()
-   {
-      return null; // todo: implement
-   }
+   RegistrationMetaData getMetaData();
 
-   public List getSupportedUserScopes()
-   {
-      return null; // todo: implement
-   }
-
-   public List getSupportedUserProfileData()
-   {
-      return null; // todo: implement
-   }
-
-   public RegistrationMetaData getMetaData()
-   {
-      return registrationMetaData;
-   }
-
-   public void setRegistrationMetaData(RegistrationMetaData registrationMetaData)
-   {
-      this.registrationMetaData = registrationMetaData;
-   }
+   void setRegistrationMetaData(RegistrationMetaData registrationMetaData);
 }

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationException.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationException.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationException.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationException.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegistrationException extends Exception
+{
+   public RegistrationException()
+   {
+   }
+
+   public RegistrationException(String message)
+   {
+      super(message);
+   }
+
+   public RegistrationException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+   public RegistrationException(Throwable cause)
+   {
+      super(cause);
+   }
+}

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationFailedException.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationFailedException.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationFailedException.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationFailedException.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegistrationFailedException
+{
+}

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -31,5 +31,5 @@
  */
 public interface RegistrationMetaData
 {
-   // TBD
+   boolean requiresMarshalling();
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -33,5 +33,38 @@
  */
 public interface RegistrationPolicy
 {
-   Registration getRegistrationFor(RegistrationData registrationData);
+   /**
+    * Registers the consumer with the given registration data if it is acceptable according to the specific registration
+    * rules defined by this RegistrationPolicy. This method is responsible for creating a Consumer object associated
+    * with this registration data (if needed), adding it to the associated ConsumerRegistry andadding the new
+    * registration to the associated RegistrationRegistry and to the Consumer.
+    *
+    * @param registrationData the registration data upon which a registration decision will be made
+    * @return a Registration describing the association between the given Consumer and the producer
+    * @throws RegistrationException if something went wrong during the registration process
+    */
+   Registration registerConsumerWith(RegistrationData registrationData) throws RegistrationException;
+
+   /**
+    * Determines whether Registrations administered by this RegistrationPolicy needs to be marshalled to the Consumer.
+    *
+    * @return <code>true</code> if Registrations need to be marshalled, <code>false</code> otherwise.
+    */
+   boolean requireRegistrationMarshalling();
+
+   ConsumerRegistry getConsumerRegistry();
+
+   void setConsumerRegistry(ConsumerRegistry consumerRegistry);
+
+   void setRegistrationRegistry(RegistrationRegistry registrationRegistry);
+
+   RegistrationRegistry getRegistrationRegistry();
+
+   void setRegistrationConverter(RegistrationConverter converter);
+
+   RegistrationConverter getRegistrationConverter();
+
+   void setRegistrationMetaData(RegistrationMetaData metadata);
+
+   RegistrationMetaData getRegistrationMetaData();
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -23,41 +23,22 @@
 
 package org.jboss.portal.wsrp.producer.registration;
 
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.RegistrationData;
+import java.util.Collection;
 
-import java.util.Map;
-
 /**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationRegistry">Chris
- *         Laprun</a>
+ * A registry for Registrations.
+ *
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  * @version $Revision$
  * @since 2.6
  */
-public class RegistrationRegistry
+public interface RegistrationRegistry
 {
-   private RegistrationPolicy policy;
-   private Map registrations = new ConcurrentHashMap();
+   void addRegistration(Registration registration) throws RegistrationException;
 
-   public RegistrationPolicy getPolicy()
-   {
-      return policy;
-   }
+   void removeRegistration(String registrationHandle) throws NoSuchRegistrationException, RegistrationException;
 
-   public void setPolicy(RegistrationPolicy policy)
-   {
-      this.policy = policy;
-   }
+   Registration getRegistration(String registrationHandle) throws RegistrationException;
 
-   public Registration register(RegistrationData registrationData) throws MissingParametersFault, OperationFailedFault
-   {
-      Registration registration = policy.getRegistrationFor(registrationData);
-      if (registration != null)
-      {
-         registrations.put(registration.getRegistrationHandle(), registration);
-      }
-      throw new OperationFailedFault();
-   }
+   Collection getRegistrations();
 }

Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationStatus.java (from rev 5590, trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationStatus.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/registration/producer/RegistrationStatus.java	2006-11-06 09:00:07 UTC (rev 5590)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationStatus.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * Type safe enumeration that describes the status of a registration.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegistrationStatus
+{
+   /** The registration is valid. */
+   public static final RegistrationStatus VALID = new RegistrationStatus();
+
+   /** The registration is waiting for validation. */
+   public static final RegistrationStatus PENDING = new RegistrationStatus();
+
+   /** The registration is not valid. */
+   public static final RegistrationStatus INVALID = new RegistrationStatus();
+
+   private RegistrationStatus()
+   {
+   }
+}

Added: 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-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,154 @@
+/******************************************************************************
+ * 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.common.util.ParameterValidation;
+import org.jboss.portal.wsrp.producer.registration.Consumer;
+import org.jboss.portal.wsrp.producer.registration.ConsumerMetaData;
+import org.jboss.portal.wsrp.producer.registration.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerImpl implements Consumer
+{
+   private String name;
+   private Map registrations;
+   private RegistrationStatus status;
+   private ConsumerMetaData metadata;
+
+
+   public ConsumerImpl(String name, ConsumerMetaData metadata)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(name, "Consumer name");
+      this.name = name;
+      ParameterValidation.throwIllegalArgExceptionIfNull(metadata, "ConsumerMetaData");
+      this.metadata = metadata;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public RegistrationStatus getStatus()
+   {
+      if (status != null)
+      {
+         return status;
+      }
+
+      for (Iterator regs = registrations.values().iterator(); regs.hasNext();)
+      {
+         Registration registration = (Registration)regs.next();
+         RegistrationStatus regStatus = registration.getStatus();
+         if (regStatus != RegistrationStatus.VALID)
+         {
+            status = regStatus;
+            return status;
+         }
+      }
+
+      status = RegistrationStatus.VALID;
+      return status;
+   }
+
+   public void setStatus(RegistrationStatus status)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(status, "RegistrationStatus");
+      this.status = status;
+   }
+
+   public Collection getRegistrations() throws RegistrationException
+   {
+      if (registrations == null)
+      {
+         return Collections.EMPTY_LIST;
+      }
+
+      return registrations.values();
+   }
+
+   public Registration getRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+   {
+      Registration registration;
+      if (registrations == null)
+      {
+         registration = null;
+      }
+      else
+      {
+         registration = (Registration)registrations.get(registrationHandle);
+      }
+
+      checkRegistrationExistence(registration, registrationHandle);
+      return registration;
+   }
+
+   public void addRegistration(Registration registration) throws RegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
+      String registrationHandle = registration.getRegistrationHandle();
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
+      if (registrations == null)
+      {
+         registrations = new HashMap(7);
+      }
+      registrations.put(registrationHandle, registration);
+   }
+
+   public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
+      Registration reg = (Registration)registrations.remove(registrationHandle);
+      checkRegistrationExistence(reg, registrationHandle);
+   }
+
+
+   public ConsumerMetaData getMetaData() throws RegistrationException
+   {
+      return metadata;
+   }
+
+   private void checkRegistrationExistence(Registration registration, String registrationHandle)
+      throws NoSuchRegistrationException
+   {
+      if (registration == null)
+      {
+         throw new NoSuchRegistrationException("The consumer named '" + name
+            + "' does not own a registration with the '" + registrationHandle + "'.");
+      }
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerMetaDataImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerMetaDataImpl.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerMetaDataImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * 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.ConsumerMetaData;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerMetaDataImpl implements ConsumerMetaData
+{
+   private String agent;
+   private boolean supportsGetMethod;
+   private List supportedModes;
+   private List supportedWindowStates;
+   private List supportedUserScopes;
+   private List supportedUserProfileData;
+
+
+   public ConsumerMetaDataImpl(String agent, boolean supportsGetMethod, List supportedModes, List supportedWindowStates,
+                               List supportedUserScopes, List supportedUserProfileData)
+   {
+      this.agent = agent;
+      this.supportsGetMethod = supportsGetMethod;
+      this.supportedModes = supportedModes;
+      this.supportedWindowStates = supportedWindowStates;
+      this.supportedUserScopes = supportedUserScopes;
+      this.supportedUserProfileData = supportedUserProfileData;
+   }
+
+   public String getConsumerAgent()
+   {
+      return agent;
+   }
+
+   public boolean supportsGetMethod()
+   {
+      return supportsGetMethod;
+   }
+
+   public List getSupportedModes()
+   {
+      return Collections.unmodifiableList(supportedModes);
+   }
+
+   public List getSupportedWindowStates()
+   {
+      return Collections.unmodifiableList(supportedWindowStates);
+   }
+
+   public List getSupportedUserScopes()
+   {
+      return Collections.unmodifiableList(supportedUserScopes);
+   }
+
+   public List getSupportedUserProfileData()
+   {
+      return Collections.unmodifiableList(supportedUserProfileData);
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * 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.common.util.ParameterValidation;
+import org.jboss.portal.wsrp.producer.registration.Consumer;
+import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
+import org.jboss.portal.wsrp.producer.registration.NoSuchConsumerException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerRegistryImpl implements ConsumerRegistry
+{
+   private Map consumers;
+
+   public Collection getConsumers() throws RegistrationException
+   {
+      if (consumers == null)
+      {
+         return Collections.EMPTY_LIST;
+      }
+      return consumers.values();
+   }
+
+   public Consumer getConsumer(String consumerName) throws RegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
+      Consumer consumer = null;
+      if (consumers != null)
+      {
+         consumer = (Consumer)consumers.get(consumerName);
+      }
+
+      return consumer;
+   }
+
+   public void addConsumer(Consumer consumer) throws RegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "Consumer");
+      String name = consumer.getName();
+      ParameterValidation.throwIllegalArgExceptionIfNull(name, "Consumer name");
+      if (consumers == null)
+      {
+         consumers = new HashMap(7);
+      }
+      consumers.put(name, consumer);
+   }
+
+   public void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
+      Consumer consumer = (Consumer)consumers.remove(consumerName);
+      if (consumer == null)
+      {
+         throw new NoSuchConsumerException("No registered consumer named '" + consumerName + "'");
+      }
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.common.util.ParameterValidation;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.wsrp.producer.registration.Consumer;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationImpl implements Registration
+{
+   private String handle;
+   private Consumer consumer;
+   private RegistrationStatus status;
+   private RegistrationMetaData metadata;
+   private PropertyMap properties;
+
+
+   public RegistrationImpl(String handle, Consumer consumer, RegistrationStatus status, RegistrationMetaData metadata)
+   {
+      this.handle = handle;
+      this.consumer = consumer;
+      this.status = status;
+      this.metadata = metadata;
+   }
+
+   public String getRegistrationHandle()
+   {
+      return handle;
+   }
+
+   public Consumer getConsumer()
+   {
+      return consumer;
+   }
+
+   public PropertyMap getProperties()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public RegistrationStatus getStatus()
+   {
+      return status;
+   }
+
+   public void setStatus(RegistrationStatus status)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(status, "RegistrationStatus");
+      this.status = status;
+   }
+
+   public RegistrationMetaData getMetaData()
+   {
+      return metadata;
+   }
+
+   public void setRegistrationMetaData(RegistrationMetaData registrationMetaData)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationMetaData, "RegistrationMetaData");
+      this.metadata = registrationMetaData;
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.RegistrationMetaData;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationMetaDataImpl implements RegistrationMetaData
+{
+   private boolean requiresMarshalling;
+
+   public RegistrationMetaDataImpl(boolean requiresMarshalling)
+   {
+      this.requiresMarshalling = requiresMarshalling;
+   }
+
+   public boolean requiresMarshalling()
+   {
+      return requiresMarshalling;
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.common.util.ParameterValidation;
+import org.jboss.portal.wsrp.producer.registration.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationRegistry;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationRegistryImpl implements RegistrationRegistry
+{
+   private Map registrations;
+
+   public Collection getRegistrations()
+   {
+      if (registrations == null)
+      {
+         return Collections.EMPTY_LIST;
+      }
+
+      return registrations.values();
+   }
+
+   public Registration getRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+   {
+      Registration registration;
+      if (registrations == null)
+      {
+         registration = null;
+      }
+      else
+      {
+         registration = (Registration)registrations.get(registrationHandle);
+      }
+
+      return registration;
+   }
+
+   public void addRegistration(Registration registration) throws RegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
+      String registrationHandle = registration.getRegistrationHandle();
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
+      if (registrations == null)
+      {
+         registrations = new HashMap(7);
+      }
+      registrations.put(registrationHandle, registration);
+   }
+
+   public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
+      Registration reg = (Registration)registrations.remove(registrationHandle);
+      checkRegistrationExistence(reg, registrationHandle);
+   }
+
+   private void checkRegistrationExistence(Registration registration, String registrationHandle)
+      throws NoSuchRegistrationException
+   {
+      if (registration == null)
+      {
+         throw new NoSuchRegistrationException("There is no Registration with handle '" + registrationHandle + "'.");
+      }
+   }
+}

Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java	2006-11-07 22:16:29 UTC (rev 5597)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java	2006-11-08 03:19:54 UTC (rev 5598)
@@ -0,0 +1,196 @@
+/******************************************************************************
+ * 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.policies;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.SimplePropertyMap;
+import org.jboss.portal.wsrp.core.Property;
+import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.producer.registration.Consumer;
+import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.RegistrationConverter;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.RegistrationRegistry;
+import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.ConsumerImpl;
+import org.jboss.portal.wsrp.producer.registration.impl.ConsumerMetaDataImpl;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationImpl;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.policies.BasicRegistrationPolicy">Chris
+ *         Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class BasicRegistrationPolicy implements RegistrationPolicy
+{
+   protected RegistrationRegistry registrationRegistry;
+   protected ConsumerRegistry consumerRegistry;
+   protected RegistrationConverter converter;
+   protected RegistrationMetaData metadata;
+   private static long lastHandle = 0;
+
+   public Registration registerConsumerWith(RegistrationData registrationData) throws RegistrationException
+   {
+      Registration registration = createRegistrationFor(registrationData);
+
+      // if a registration with this handle already exists, reject it
+      String handle = registration.getRegistrationHandle();
+      if (registrationRegistry.getRegistration(handle) != null)
+      {
+         throw new RegistrationException("A Registration with handle: '" + handle + "' already exists.");
+      }
+      else
+      {
+         registrationRegistry.addRegistration(registration);
+      }
+
+      return registration;
+   }
+
+   public boolean requireRegistrationMarshalling()
+   {
+      return metadata.requiresMarshalling();
+   }
+
+
+   public ConsumerRegistry getConsumerRegistry()
+   {
+      return consumerRegistry;
+   }
+
+   public void setConsumerRegistry(ConsumerRegistry consumerRegistry)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(consumerRegistry, "ConsumerRegistry");
+      this.consumerRegistry = consumerRegistry;
+   }
+
+   public void setRegistrationRegistry(RegistrationRegistry registrationRegistry)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationRegistry, "RegistrationRegistry");
+      this.registrationRegistry = registrationRegistry;
+   }
+
+   public RegistrationRegistry getRegistrationRegistry()
+   {
+      return registrationRegistry;
+   }
+
+   public void setRegistrationConverter(RegistrationConverter converter)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(converter, "RegistrationConverter");
+      this.converter = converter;
+   }
+
+   public RegistrationConverter getRegistrationConverter()
+   {
+      return converter;
+   }
+
+
+   public void setRegistrationMetaData(RegistrationMetaData metadata)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(metadata, "RegistrationMetaData");
+      this.metadata = metadata;
+   }
+
+   public RegistrationMetaData getRegistrationMetaData()
+   {
+      return metadata;
+   }
+
+   protected Consumer createConsumerFor(RegistrationData registrationData) throws RegistrationException
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(registrationData, "RegistrationData");
+
+      String name = registrationData.getConsumerName();
+      Consumer consumer = consumerRegistry.getConsumer(name);
+
+      // a consumer already exists with that name, we need to check that we can allow a new registration
+      if (consumer != null)
+      {
+         PropertyMap properties = createProperties(registrationData);
+
+         // allow the new registration only if the registration properties are different that existing registrations
+         // for this consumer...
+         Collection registrations = consumer.getRegistrations();
+         for (Iterator iterator = registrations.iterator(); iterator.hasNext();)
+         {
+            Registration registration = (Registration)iterator.next();
+            if (registration.getProperties().equals(properties)) // todo: need to implement equals on TypedMap
+            {
+               throw new RegistrationException("Consumer named '" + name
+                  + "' has already been registered with the same set of registration properties. Registration rejected!");
+            }
+         }
+      }
+      else
+      {
+         ConsumerMetaDataImpl metadata = new ConsumerMetaDataImpl(registrationData.getConsumerAgent(),
+            registrationData.isMethodGetSupported(), Arrays.asList(registrationData.getConsumerModes()),
+            Arrays.asList(registrationData.getConsumerWindowStates()), Arrays.asList(registrationData.getConsumerUserScopes()),
+            Arrays.asList(registrationData.getCustomUserProfileData()));
+
+         consumer = new ConsumerImpl(name, metadata);
+         consumerRegistry.addConsumer(consumer);
+      }
+
+      return consumer;
+   }
+
+   protected Registration createRegistrationFor(RegistrationData registrationData) throws RegistrationException
+   {
+      Consumer consumer = createConsumerFor(registrationData);
+
+      return new RegistrationImpl(getHandleFor(consumer), consumer, RegistrationStatus.VALID, metadata);
+   }
+
+   protected String getHandleFor(Consumer consumer)
+   {
+      return "" + lastHandle++;
+   }
+
+   private PropertyMap createProperties(RegistrationData registrationData)
+   {
+      Property[] regProperties = registrationData.getRegistrationProperties();
+      PropertyMap properties = new SimplePropertyMap();
+
+      for (int i = 0; i < regProperties.length; i++)
+      {
+         Property property = regProperties[i];
+         // todo: should be more detailed here... use the language, allow other value types...
+         properties.setProperty(property.getName(), new StringValue(property.getStringValue()));
+      }
+      return properties;
+   }
+}




More information about the jboss-svn-commits mailing list