[jboss-svn-commits] JBoss Portal SVN: r5619 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/framework test/wsrp/v1/producer wsrp wsrp/producer wsrp/producer/registration wsrp/producer/registration/impl wsrp/producer/registration/policies
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Nov 10 09:14:48 EST 2006
Author: julien at jboss.com
Date: 2006-11-10 09:14:17 -0500 (Fri, 10 Nov 2006)
New Revision: 5619
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/LocalizedString.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaData.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaDataImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPolicy.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPropertyDescription.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConversionException.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConverter.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/RegistrationPropertyDescription.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.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/RegistrationMetaDataImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.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/Consumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.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/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/policies/BasicRegistrationPolicy.java
Log:
- improve registration consumer registry
- the consumer registry is responsible to create handles and not the registration policy
- split producer registration metadata from the effective consumer registrations within the registry
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -70,7 +70,7 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
-import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -35,7 +35,7 @@
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.core.ServiceDescription;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -40,7 +40,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -28,7 +28,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
-import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaData;
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -39,8 +39,8 @@
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.StateChange;
-import org.jboss.portal.wsrp.producer.registration.LocalizedString;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
+import org.jboss.portal.wsrp.producer.registration.policies.LocalizedString;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPropertyDescription;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -36,10 +36,8 @@
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.producer.registration.Registration;
-import org.jboss.portal.wsrp.producer.registration.RegistrationConversionException;
-import org.jboss.portal.wsrp.producer.registration.RegistrationConverter;
import org.jboss.portal.wsrp.producer.registration.RegistrationException;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPolicy;
import java.rmi.RemoteException;
@@ -93,22 +91,7 @@
throw WSRPUtils.createOperationFailedFault(e);
}
- RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getRegistrationHandle());
- if (policy.getRegistrationMetaData().requiresMarshalling())
- {
- try
- {
- log.debug("Marshalling state.");
- byte[] registrationState = policy.getRegistrationConverter().marshall(registration);
- registrationContext.setRegistrationState(registrationState);
- }
- catch (RegistrationConversionException e)
- {
- log.debug(e);
- throw WSRPUtils.createOperationFailedFault(e);
- }
- }
-
+ RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getId());
log.debug("Registration completed without error.");
return registrationContext;
}
@@ -129,7 +112,7 @@
public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
{
- if (policy.getRegistrationMetaData().requiresRegistration())
+ if (policy.getMetaData().requiresRegistration())
{
log.debug("registration required: checking registration");
if (registrationContext == null)
@@ -144,35 +127,6 @@
throwInvalidRegistrationFault("missing required registration handle!");
}
- if (policy.getRegistrationMetaData().requiresMarshalling())
- {
- byte[] state = registrationContext.getRegistrationState();
- if (state == null)
- {
- throwInvalidRegistrationFault("missing required registration state!");
- }
-
- RegistrationConverter converter = policy.getRegistrationConverter();
- try
- {
- Registration registration = converter.unmarshall(state);
- Registration expected = policy.getRegistrationRegistry().getRegistration(regHandle);
- if (!expected.equals(registration))
- {
- throwInvalidRegistrationFault("unmarshalled state is not the expected one!");
- }
- }
- catch (RegistrationConversionException e)
- {
- throwInvalidRegistrationFault("could not unmarshall state (" + e.getLocalizedMessage() + ")!");
- }
- catch (RegistrationException e)
- {
- throwInvalidRegistrationFault("could not retrieve registration with handle '" + regHandle
- + "' from the registry (" + e.getLocalizedMessage() + ")!");
- }
- }
-
return true;
}
else
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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -44,7 +44,8 @@
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
-import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPolicy;
import java.rmi.RemoteException;
import java.util.Collection;
@@ -74,8 +75,7 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- RegistrationMetaData metadata = producer.getRegistrationPolicy().getRegistrationMetaData();
- if (metadata.fullServiceDescriptionRequiresRegistration() && !producer.isRegistrationValid(gs.getRegistrationContext()))
+ if (producer.getRegistrationPolicy().getMetaData().fullServiceDescriptionRequiresRegistration() && !producer.isRegistrationValid(gs.getRegistrationContext()))
{
return getRegistrationNotProvidedServiceDescription();
}
@@ -132,8 +132,8 @@
private ServiceDescription refreshServiceDescription(String[] desiredLocales)
{
// todo: find out how to cache this
- RegistrationMetaData metaData = producer.getRegistrationPolicy().getRegistrationMetaData();
- ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(metaData.requiresRegistration());
+ RegistrationPolicy policy = producer.getRegistrationPolicy();
+ ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(policy.getMetaData().requiresRegistration());
serviceDescription.setRequiresInitCookie(CookieProtocol.none);
PortletDescription[] descriptions = (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
.toArray(new PortletDescription[]{});
@@ -150,7 +150,8 @@
{
// todo: find out how to cache this
log.debug("Using service description offered for unregistered consumers");
- RegistrationMetaData metaData = producer.getRegistrationPolicy().getRegistrationMetaData();
+ RegistrationPolicy policy = producer.getRegistrationPolicy();
+ RegistrationMetaData metaData = policy.getMetaData();
return new ServiceDescription(true, null, null, null, null, null, CookieProtocol.none,
WSRPUtils.convertRegistrationPropertiesToModelDescription(metaData.getRegistrationProperties()),
producer.getSupportedLocales(), null, null);
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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -74,8 +74,8 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
-import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPolicy;
import org.jboss.portal.wsrp.servlet.ServletAccess;
import javax.servlet.http.HttpSession;
@@ -149,7 +149,7 @@
public RegistrationMetaData getRegistrationMetaData()
{
- return registrationPolicy.getRegistrationMetaData();
+ return registrationPolicy.getMetaData();
}
// ServiceDescription implementation ********************************************************************************
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Consumer.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.wsrp.producer.registration;
+import org.jboss.portal.wsrp.core.RegistrationData;
+
import java.util.Collection;
/**
@@ -32,7 +34,7 @@
* @version $Revision: 1.1 $
* @since 2.6
*/
-public interface Consumer
+public interface Consumer
{
/**
* Return the consumer name.
@@ -63,32 +65,9 @@
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;
+ Registration addRegistration(RegistrationData registration) throws RegistrationException;
}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java (from rev 5618, 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerData.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * 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;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerData
+{
+
+ private String agent;
+ private boolean supportsGetMethod;
+ private List supportedModes;
+ private List supportedWindowStates;
+ private List supportedUserScopes;
+ private List supportedUserProfileData;
+
+
+ public ConsumerData(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);
+ }
+}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerMetaData.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,46 +0,0 @@
-/******************************************************************************
- * 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();
-}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/ConsumerRegistry.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -48,15 +48,32 @@
/**
* Adds the given Consumer to the list of registered Consumers.
*
- * @param consumer the Consumer to be added
+ * @param consumerName the consumer name
+ * @param data the meta data of the consumer to be added
* @return the newly created consumer
*/
- void addConsumer(Consumer consumer) throws RegistrationException;
+ Consumer addConsumer(String consumerName, ConsumerData data) throws RegistrationException;
/**
- * Removes the given consumer from the list of registered Consumers.
+ * Removes the given consumer from the list of registered Consumers as well as all the related registrations
+ * of that consumer.
*
* @param consumerName the consumer name
*/
void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException;
+
+ /**
+ * Return a specific registration for this consumer.
+ *
+ * @param registrationId
+ * @return the registration
+ */
+ Registration getRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException;
+
+ /**
+ * Remove the Registration associated with the given handle from this Consumer's registrations.
+ *
+ * @param registrationId
+ */
+ void removeRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException;
}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,82 +0,0 @@
-/******************************************************************************
- * 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.Locale;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class LocalizedString
-{
- private String value;
- private Locale locale;
- private String resourceName;
-
-
- public LocalizedString(String value, Locale locale)
- {
- this.value = value;
- this.locale = locale;
- }
-
-
- public LocalizedString(String value)
- {
- this.value = value;
- this.locale = Locale.getDefault();
- }
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public Locale getLocale()
- {
- return locale;
- }
-
- public void setLocale(Locale locale)
- {
- this.locale = locale;
- }
-
- public String getResourceName()
- {
- return resourceName;
- }
-
- public void setResourceName(String resourceName)
- {
- this.resourceName = resourceName;
- }
-}
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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -41,7 +41,7 @@
*
* @return the registration handle
*/
- String getRegistrationHandle();
+ String getId();
/**
* Return the consumer owning this registration.
@@ -78,8 +78,4 @@
* @param status the new status
*/
void setStatus(RegistrationStatus status);
-
- RegistrationMetaData getMetaData();
-
- void setRegistrationMetaData(RegistrationMetaData registrationMetaData);
}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConversionException.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConversionException.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConversionException.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,53 +0,0 @@
-/******************************************************************************
- * 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:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationConversionException">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class RegistrationConversionException extends Exception
-{
-
- public RegistrationConversionException()
- {
- }
-
- public RegistrationConversionException(String message)
- {
- super(message);
- }
-
- public RegistrationConversionException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public RegistrationConversionException(Throwable cause)
- {
- super(cause);
- }
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConverter.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConverter.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationConverter.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,55 +0,0 @@
-/******************************************************************************
- * 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:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationConverter">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface RegistrationConverter
-{
- /**
- * Marshall the registration as a byte array.
- *
- * @param registration the registration
- * @return the marshalled registration
- * @throws RegistrationConversionException
- * if marshalling cannot be performed
- * @throws IllegalArgumentException if the registration is null
- */
- byte[] marshall(Registration registration) throws RegistrationConversionException, IllegalArgumentException;
-
- /**
- * Unmarshall the producer state from a byte array.
- *
- * @param marshalledState the marshalled state
- * @return the producer state
- * @throws RegistrationConversionException
- * if unmarshalling cannot be performed
- * @throws IllegalArgumentException if the argument is null
- */
- Registration unmarshall(byte[] marshalledState) throws RegistrationConversionException, IllegalArgumentException;
-}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,62 +0,0 @@
-/******************************************************************************
- * 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 javax.xml.namespace.QName;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationMetadata">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface RegistrationMetaData
-{
- boolean requiresMarshalling();
-
- void setRequiresMarshalling(boolean requiresMarshalling);
-
- boolean requiresRegistration();
-
- void setRequiresRegistration(boolean requiresRegistration);
-
- boolean fullServiceDescriptionRequiresRegistration();
-
- void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration);
-
- Map getRegistrationProperties();
-
- void addRegistrationProperty(RegistrationPropertyDescription propertyDescription);
-
- void removeRegistrationProperty(String propertyName);
-
- void removeRegistrationProperty(QName propertyName);
-
- void clearRegistrationProperties();
-
- boolean acceptValueFor(Object value, QName propertyName);
-
- boolean acceptValueFor(Object value, String propertyName);
-}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,63 +0,0 @@
-/******************************************************************************
- * 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 org.jboss.portal.wsrp.core.RegistrationData;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationPolicy">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface RegistrationPolicy
-{
- /**
- * 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;
-
- ConsumerRegistry getConsumerRegistry();
-
- void setConsumerRegistry(ConsumerRegistry consumerRegistry);
-
- void setRegistrationRegistry(RegistrationRegistry registrationRegistry);
-
- RegistrationRegistry getRegistrationRegistry();
-
- void setRegistrationConverter(RegistrationConverter converter);
-
- RegistrationConverter getRegistrationConverter();
-
- void setRegistrationMetaData(RegistrationMetaData metadata);
-
- RegistrationMetaData getRegistrationMetaData();
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,151 +0,0 @@
-/******************************************************************************
- * 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 javax.xml.namespace.QName;
-import java.net.URI;
-
-/**
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class RegistrationPropertyDescription
-{
- private QName name;
- private QName type;
- private URI schemaLocation;
- private LocalizedString description;
- private LocalizedString hint;
- private LocalizedString label;
- private String[] usages;
- private QName[] aliases;
-
-
- public RegistrationPropertyDescription(QName name, QName type)
- {
- this.name = name;
- this.type = type;
- }
-
- public RegistrationPropertyDescription(String name, QName type)
- {
- this(new QName(name), type);
- }
-
- public QName getName()
- {
- return name;
- }
-
- public void setName(QName name)
- {
- this.name = name;
- }
-
- public QName getType()
- {
- return type;
- }
-
- public void setType(QName type)
- {
- this.type = type;
- }
-
- public URI getSchemaLocation()
- {
- return schemaLocation;
- }
-
- public void setSchemaLocation(URI schemaLocation)
- {
- this.schemaLocation = schemaLocation;
- }
-
- public LocalizedString getDescription()
- {
- return description;
- }
-
- public void setDescription(LocalizedString description)
- {
- this.description = description;
- }
-
- public void setDefaultDescription(String value)
- {
- setDescription(new LocalizedString(value));
- }
-
- public LocalizedString getHint()
- {
- return hint;
- }
-
- public void setHint(LocalizedString hint)
- {
- this.hint = hint;
- }
-
- public void setDefaultHint(String value)
- {
- setHint(new LocalizedString(value));
- }
-
- public LocalizedString getLabel()
- {
- return label;
- }
-
- public void setLabel(LocalizedString label)
- {
- this.label = label;
- }
-
- public void setDefaultLabel(String value)
- {
- setLabel(new LocalizedString(value));
- }
-
- public String[] getUsages()
- {
- return usages;
- }
-
- public void setUsages(String[] usages)
- {
- this.usages = usages;
- }
-
- public QName[] getAliases()
- {
- return aliases;
- }
-
- public void setAliases(QName[] aliases)
- {
- this.aliases = aliases;
- }
-}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationRegistry.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,44 +0,0 @@
-/******************************************************************************
- * 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 registry for Registrations.
- *
- * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface RegistrationRegistry
-{
- void addRegistration(Registration registration) throws RegistrationException;
-
- void removeRegistration(String registrationHandle) throws NoSuchRegistrationException, RegistrationException;
-
- Registration getRegistration(String registrationHandle) throws RegistrationException;
-
- Collection getRegistrations();
-}
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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -25,17 +25,16 @@
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.ConsumerData;
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 org.jboss.portal.wsrp.core.RegistrationData;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
@@ -44,18 +43,23 @@
*/
public class ConsumerImpl implements Consumer
{
+
private String name;
- private Map registrations;
+ Set registrationIds;
private RegistrationStatus status;
- private ConsumerMetaData metadata;
+ private ConsumerData metadata;
+ private ConsumerRegistryImpl registry;
-
- public ConsumerImpl(String name, ConsumerMetaData metadata)
+ public ConsumerImpl(String name, ConsumerData metadata, ConsumerRegistryImpl registry)
{
ParameterValidation.throwIllegalArgExceptionIfNull(name, "Consumer name");
- this.name = name;
ParameterValidation.throwIllegalArgExceptionIfNull(metadata, "ConsumerMetaData");
+
+ //
+ this.name = name;
this.metadata = metadata;
+ this.registrationIds = new HashSet();
+ this.registry = registry;
}
public String getName()
@@ -65,23 +69,6 @@
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;
}
@@ -93,62 +80,30 @@
public Collection getRegistrations() throws RegistrationException
{
- if (registrations == null)
+ Set registrations = new HashSet();
+ for (Iterator i = registrationIds.iterator();i.hasNext();)
{
- return Collections.EMPTY_LIST;
+ String regId = (String)i.next();
+ registrations.add(registry.getRegistration(regId));
}
-
- return registrations.values();
+ return registrations;
}
- public Registration getRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+ public Registration addRegistration(RegistrationData metaData) throws RegistrationException
{
- Registration registration;
- if (registrations == null)
- {
- registration = null;
- }
- else
- {
- registration = (Registration)registrations.get(registrationHandle);
- }
-
- checkRegistrationExistence(registration, registrationHandle);
+ Registration registration = registry.addRegistration(this, metaData);
+ registrationIds.add(registration.getId());
return registration;
}
- public void addRegistration(Registration registration) throws RegistrationException
+ void removeRegistration(String registrationId)
{
- ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
- String registrationHandle = registration.getRegistrationHandle();
- ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
- if (registrations == null)
- {
- registrations = new HashMap(7);
- }
- registrations.put(registrationHandle, registration);
+ registrationIds.remove(registrationId);
}
- public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+ public ConsumerData getMetaData() throws RegistrationException
{
- 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 + "'.");
- }
- }
}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerMetaDataImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,86 +0,0 @@
-/******************************************************************************
- * 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);
- }
-}
Modified: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerRegistryImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -28,11 +28,17 @@
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 org.jboss.portal.wsrp.producer.registration.ConsumerData;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+import org.jboss.portal.wsrp.core.RegistrationData;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Iterator;
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
@@ -41,8 +47,13 @@
*/
public class ConsumerRegistryImpl implements ConsumerRegistry
{
+
+ long lastId;
+
private Map consumers;
+ private Map registrations = new HashMap();
+
public Collection getConsumers() throws RegistrationException
{
if (consumers == null)
@@ -64,25 +75,86 @@
return consumer;
}
- public void addConsumer(Consumer consumer) throws RegistrationException
+ public Consumer addConsumer(String consumerName, ConsumerData data) throws RegistrationException
{
- ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "Consumer");
- String name = consumer.getName();
- ParameterValidation.throwIllegalArgExceptionIfNull(name, "Consumer name");
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
+ ParameterValidation.throwIllegalArgExceptionIfNull(data, "Consumer meta data");
+
if (consumers == null)
{
consumers = new HashMap(7);
}
- consumers.put(name, consumer);
+
+ Consumer consumer = new ConsumerImpl(consumerName, data, this);
+ consumers.put(consumerName, consumer);
+ return consumer;
}
public void removeConsumer(String consumerName) throws RegistrationException, NoSuchConsumerException
{
ParameterValidation.throwIllegalArgExceptionIfNull(consumerName, "Consumer name");
- Consumer consumer = (Consumer)consumers.remove(consumerName);
+
+ //
+ ConsumerImpl consumer = (ConsumerImpl)consumers.remove(consumerName);
if (consumer == null)
{
throw new NoSuchConsumerException("No registered consumer named '" + consumerName + "'");
}
+
+ //
+ for (Iterator i = consumer.registrationIds.iterator();i.hasNext();)
+ {
+ String regId = (String)i.next();
+ registrations.remove(regId);
+ }
}
+
+ public Registration getRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationId, "Registration id");
+ Registration reg = (Registration)registrations.get(registrationId);
+ if (reg == null)
+ {
+ throw new NoSuchRegistrationException();
+ }
+ return reg;
+ }
+
+ public void removeRegistration(String registrationId) throws RegistrationException, NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationId, "Registration id");
+ RegistrationImpl reg = (RegistrationImpl)registrations.remove(registrationId);
+ if (reg == null)
+ {
+ throw new NoSuchRegistrationException();
+ }
+
+ // Remove association
+ reg.consumer.removeRegistration(reg.id);
+ reg.consumer = null;
+ }
+
+ Registration addRegistration(ConsumerImpl consumer, RegistrationData metaData) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(metaData, "Registration meta data");
+
+ // todo
+
+ // allow the new registration only if the registration properties are different that existing registrations
+ // for this consumer...
+// for (Iterator iterator = registrations.values().iterator(); iterator.hasNext();)
+// {
+// Registration registration = (Registration)iterator.next();
+// if (registration.hasEqualProperties(props))
+// {
+// throw new RegistrationException("Consumer named '" + name
+// + "' has already been registered with the same set of registration properties. Registration rejected!");
+// }
+// }
+
+ String id = "" + lastId++;
+ RegistrationImpl registration = new RegistrationImpl(id, consumer, RegistrationStatus.VALID, metaData);
+ registrations.put(id, registration);
+ return registration;
+ }
}
Modified: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -26,8 +26,9 @@
import org.jboss.portal.common.util.ParameterValidation;
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;
+import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.Property;
import javax.xml.namespace.QName;
import java.util.Collections;
@@ -42,25 +43,33 @@
*/
public class RegistrationImpl implements Registration
{
- private String handle;
- private Consumer consumer;
+
+ final String id;
+ ConsumerImpl consumer;
private RegistrationStatus status;
- private RegistrationMetaData metadata;
+ private RegistrationData data;
private Map properties;
- public RegistrationImpl(String handle, Consumer consumer, RegistrationStatus status, RegistrationMetaData metadata)
+ public RegistrationImpl(String id, ConsumerImpl consumer, RegistrationStatus status, RegistrationData data)
{
- this.handle = handle;
+ this.id = id;
this.consumer = consumer;
this.status = status;
- this.metadata = metadata;
- properties = new HashMap(7);
+ this.data = data;
+ this.properties = new HashMap(7);
+
+ // Update state with data
+ Property[] props = data.getRegistrationProperties();
+ for (int i = 0; i < props.length; i++)
+ {
+ Property prop = props[i];
+ }
}
- public String getRegistrationHandle()
+ public String getId()
{
- return handle;
+ return id;
}
public Consumer getConsumer()
@@ -77,15 +86,7 @@
{
ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
ParameterValidation.throwIllegalArgExceptionIfNull(value, "Property value");
-
- if (metadata.acceptValueFor(value, propertyName))
- {
- properties.put(propertyName, value);
- }
- else
- {
- throw new IllegalArgumentException(value + " is not an acceptable value for property named '" + propertyName + "'");
- }
+ properties.put(propertyName, value);
}
public void setPropertyValueFor(String propertyName, Object value)
@@ -147,15 +148,4 @@
ParameterValidation.throwIllegalArgExceptionIfNull(status, "RegistrationStatus");
this.status = status;
}
-
- public RegistrationMetaData getMetaData()
- {
- return metadata;
- }
-
- public void setRegistrationMetaData(RegistrationMetaData registrationMetaData)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(registrationMetaData, "RegistrationMetaData");
- this.metadata = registrationMetaData;
- }
}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,130 +0,0 @@
-/******************************************************************************
- * 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.RegistrationMetaData;
-import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
-
-import javax.xml.namespace.QName;
-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 RegistrationMetaDataImpl implements RegistrationMetaData
-{
- private boolean requiresMarshalling;
- private boolean requiresRegistration;
- private boolean fullServiceDescriptionRequiresRegistration;
-
- /** property name (QName) -> PropertyDescription */
- private Map registrationProperties;
-
- public RegistrationMetaDataImpl(boolean requiresMarshalling, boolean requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
- {
- this.requiresMarshalling = requiresMarshalling;
- this.requiresRegistration = requiresRegistration;
- this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
- registrationProperties = new HashMap(7);
- }
-
- public boolean requiresMarshalling()
- {
- return requiresMarshalling;
- }
-
- public void setRequiresMarshalling(boolean requiresMarshalling)
- {
- this.requiresMarshalling = requiresMarshalling;
- }
-
- public boolean requiresRegistration()
- {
- return requiresRegistration;
- }
-
- public void setRequiresRegistration(boolean requiresRegistration)
- {
- this.requiresRegistration = requiresRegistration;
- }
-
- public boolean fullServiceDescriptionRequiresRegistration()
- {
- return fullServiceDescriptionRequiresRegistration;
- }
-
- public void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration)
- {
- this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
- }
-
- public Map getRegistrationProperties()
- {
- return Collections.unmodifiableMap(registrationProperties);
- }
-
- public void addRegistrationProperty(RegistrationPropertyDescription propertyDescription)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(propertyDescription, "PropertyDescription");
- registrationProperties.put(propertyDescription.getName(), propertyDescription);
- }
-
- public boolean acceptValueFor(Object value, QName propertyName)
- {
- QName type = getPropertyDescription(propertyName).getType();
- // todo: decide if type is actually compatible with value...
- return true;
- }
-
- public boolean acceptValueFor(Object value, String propertyName)
- {
- return acceptValueFor(value, new QName(propertyName));
- }
-
- private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
- {
- return (RegistrationPropertyDescription)registrationProperties.get(propertyName);
- }
-
- public void removeRegistrationProperty(QName propertyName)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
- registrationProperties.remove(propertyName);
- }
-
- public void clearRegistrationProperties()
- {
- registrationProperties.clear();
- }
-
- public void removeRegistrationProperty(String propertyName)
- {
- removeRegistrationProperty(new QName(propertyName));
- }
-}
Deleted: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationRegistryImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -1,98 +0,0 @@
-/******************************************************************************
- * 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 + "'.");
- }
- }
-}
Modified: 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -30,25 +30,15 @@
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.ConsumerData;
import org.jboss.portal.wsrp.producer.registration.impl.ConsumerRegistryImpl;
-import org.jboss.portal.wsrp.producer.registration.impl.RegistrationImpl;
-import org.jboss.portal.wsrp.producer.registration.impl.RegistrationMetaDataImpl;
-import org.jboss.portal.wsrp.producer.registration.impl.RegistrationRegistryImpl;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationMetaDataImpl;
import javax.xml.namespace.QName;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -60,134 +50,47 @@
*/
public class BasicRegistrationPolicy extends AbstractJBossService implements RegistrationPolicy
{
- protected RegistrationRegistry registrationRegistry;
+
protected ConsumerRegistry consumerRegistry;
- protected RegistrationConverter converter;
- protected RegistrationMetaData metadata;
- private static long lastHandle = 0;
+ protected RegistrationMetaData metaData;
-
public BasicRegistrationPolicy()
{
consumerRegistry = new ConsumerRegistryImpl();
- registrationRegistry = new RegistrationRegistryImpl();
- metadata = new RegistrationMetaDataImpl(false, true, false);
+ metaData = new RegistrationMetaDataImpl(false, true, false);
}
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 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)
+ // A consumer already exists with that name, we need to check that we can allow a new registration
+ if (consumer == null)
{
- log.debug("Consumer named '" + name + "' already exists. Checking that we can add a new Registration.");
- Map props = createRegistrationProperties(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.hasEqualProperties(props))
- {
- 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(),
+ ConsumerData metaData = new ConsumerData(registrationData.getConsumerAgent(),
registrationData.isMethodGetSupported(), getListFromArray(registrationData.getConsumerModes()),
getListFromArray(registrationData.getConsumerWindowStates()),
getListFromArray(registrationData.getConsumerUserScopes()),
getListFromArray(registrationData.getCustomUserProfileData()));
-
- consumer = new ConsumerImpl(name, metadata);
- consumerRegistry.addConsumer(consumer);
+ consumer = consumerRegistry.addConsumer(name, metaData);
}
- return consumer;
+ return consumer.addRegistration(registrationData);
}
- protected Registration createRegistrationFor(RegistrationData registrationData) throws RegistrationException
+ public ConsumerRegistry getConsumerRegistry()
{
- Consumer consumer = createConsumerFor(registrationData);
-
- return new RegistrationImpl(getHandleFor(consumer), consumer, RegistrationStatus.VALID, metadata);
+ return consumerRegistry;
}
- protected String getHandleFor(Consumer consumer)
+ public void setConsumerRegistry(ConsumerRegistry consumerRegistry)
{
- return "" + lastHandle++;
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumerRegistry, "ConsumerRegistry");
+ this.consumerRegistry = consumerRegistry;
}
private Map createRegistrationProperties(RegistrationData registrationData)
@@ -213,4 +116,9 @@
}
return Arrays.asList(array);
}
+
+ public RegistrationMetaData getMetaData()
+ {
+ return metaData;
+ }
}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/LocalizedString.java (from rev 5618, trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/LocalizedString.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * 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 java.util.Locale;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class LocalizedString
+{
+ private String value;
+ private Locale locale;
+ private String resourceName;
+
+
+ public LocalizedString(String value, Locale locale)
+ {
+ this.value = value;
+ this.locale = locale;
+ }
+
+
+ public LocalizedString(String value)
+ {
+ this.value = value;
+ this.locale = Locale.getDefault();
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public String getResourceName()
+ {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName)
+ {
+ this.resourceName = resourceName;
+ }
+}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaData.java (from rev 5618, 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaData.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.wsrp.producer.registration.policies.RegistrationPropertyDescription;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationMetadata">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public interface RegistrationMetaData
+{
+
+ boolean requiresRegistration();
+
+ void setRequiresRegistration(boolean requiresRegistration);
+
+ boolean fullServiceDescriptionRequiresRegistration();
+
+ void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration);
+
+ Map getRegistrationProperties();
+
+ void addRegistrationProperty(RegistrationPropertyDescription propertyDescription);
+
+ void removeRegistrationProperty(String propertyName);
+
+ void removeRegistrationProperty(QName propertyName);
+
+ void clearRegistrationProperties();
+
+ boolean acceptValueFor(Object value, QName propertyName);
+
+ boolean acceptValueFor(Object value, String propertyName);
+}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaDataImpl.java (from rev 5618, 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationMetaDataImpl.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * 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.wsrp.producer.registration.policies.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.policies.RegistrationPropertyDescription;
+
+import javax.xml.namespace.QName;
+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 RegistrationMetaDataImpl implements RegistrationMetaData
+{
+ private boolean requiresRegistration;
+ private boolean fullServiceDescriptionRequiresRegistration;
+
+ /** property name (QName) -> PropertyDescription */
+ private Map registrationProperties;
+
+ public RegistrationMetaDataImpl(boolean requiresMarshalling, boolean requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
+ {
+ this.requiresRegistration = requiresRegistration;
+ this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
+ registrationProperties = new HashMap(7);
+ }
+
+ public boolean requiresRegistration()
+ {
+ return requiresRegistration;
+ }
+
+ public void setRequiresRegistration(boolean requiresRegistration)
+ {
+ this.requiresRegistration = requiresRegistration;
+ }
+
+ public boolean fullServiceDescriptionRequiresRegistration()
+ {
+ return fullServiceDescriptionRequiresRegistration;
+ }
+
+ public void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration)
+ {
+ this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
+ }
+
+ public Map getRegistrationProperties()
+ {
+ return Collections.unmodifiableMap(registrationProperties);
+ }
+
+ public void addRegistrationProperty(RegistrationPropertyDescription propertyDescription)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyDescription, "PropertyDescription");
+ registrationProperties.put(propertyDescription.getName(), propertyDescription);
+ }
+
+ public boolean acceptValueFor(Object value, QName propertyName)
+ {
+ QName type = getPropertyDescription(propertyName).getType();
+ // todo: decide if type is actually compatible with value...
+ return true;
+ }
+
+ public boolean acceptValueFor(Object value, String propertyName)
+ {
+ return acceptValueFor(value, new QName(propertyName));
+ }
+
+ private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
+ {
+ return (RegistrationPropertyDescription)registrationProperties.get(propertyName);
+ }
+
+ public void removeRegistrationProperty(QName propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
+ registrationProperties.remove(propertyName);
+ }
+
+ public void clearRegistrationProperties()
+ {
+ registrationProperties.clear();
+ }
+
+ public void removeRegistrationProperty(String propertyName)
+ {
+ removeRegistrationProperty(new QName(propertyName));
+ }
+}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPolicy.java (from rev 5618, 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-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPolicy.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.producer.registration.Registration;
+import org.jboss.portal.wsrp.producer.registration.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.ConsumerRegistry;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationPolicy">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public interface RegistrationPolicy
+{
+ /**
+ * 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 org.jboss.portal.wsrp.producer.registration.RegistrationException if something went wrong during the registration process
+ */
+ Registration registerConsumerWith(RegistrationData registrationData) throws RegistrationException;
+
+ ConsumerRegistry getConsumerRegistry();
+
+ void setConsumerRegistry(ConsumerRegistry consumerRegistry);
+
+ RegistrationMetaData getMetaData();
+}
Copied: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPropertyDescription.java (from rev 5618, trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java 2006-11-10 07:41:15 UTC (rev 5618)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/RegistrationPropertyDescription.java 2006-11-10 14:14:17 UTC (rev 5619)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * 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 javax.xml.namespace.QName;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationPropertyDescription
+{
+ private QName name;
+ private QName type;
+ private URI schemaLocation;
+ private LocalizedString description;
+ private LocalizedString hint;
+ private LocalizedString label;
+ private String[] usages;
+ private QName[] aliases;
+
+
+ public RegistrationPropertyDescription(QName name, QName type)
+ {
+ this.name = name;
+ this.type = type;
+ }
+
+ public RegistrationPropertyDescription(String name, QName type)
+ {
+ this(new QName(name), type);
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public void setName(QName name)
+ {
+ this.name = name;
+ }
+
+ public QName getType()
+ {
+ return type;
+ }
+
+ public void setType(QName type)
+ {
+ this.type = type;
+ }
+
+ public URI getSchemaLocation()
+ {
+ return schemaLocation;
+ }
+
+ public void setSchemaLocation(URI schemaLocation)
+ {
+ this.schemaLocation = schemaLocation;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(LocalizedString description)
+ {
+ this.description = description;
+ }
+
+ public void setDefaultDescription(String value)
+ {
+ setDescription(new LocalizedString(value));
+ }
+
+ public LocalizedString getHint()
+ {
+ return hint;
+ }
+
+ public void setHint(LocalizedString hint)
+ {
+ this.hint = hint;
+ }
+
+ public void setDefaultHint(String value)
+ {
+ setHint(new LocalizedString(value));
+ }
+
+ public LocalizedString getLabel()
+ {
+ return label;
+ }
+
+ public void setLabel(LocalizedString label)
+ {
+ this.label = label;
+ }
+
+ public void setDefaultLabel(String value)
+ {
+ setLabel(new LocalizedString(value));
+ }
+
+ public String[] getUsages()
+ {
+ return usages;
+ }
+
+ public void setUsages(String[] usages)
+ {
+ this.usages = usages;
+ }
+
+ public QName[] getAliases()
+ {
+ return aliases;
+ }
+
+ public void setAliases(QName[] aliases)
+ {
+ this.aliases = aliases;
+ }
+}
More information about the jboss-svn-commits
mailing list