Author: chris.laprun(a)jboss.com
Date: 2009-08-26 06:12:59 -0400 (Wed, 26 Aug 2009)
New Revision: 13791
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Consumer.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerCapabilities.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerGroup.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/DuplicateRegistrationException.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/InvalidConsumerDataException.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/NoSuchRegistrationException.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/PropertyDescription.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Registration.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationException.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationFailedException.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationLocal.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationManager.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPersistenceManager.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicy.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPropertyChangeListener.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationStatus.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationUtils.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerCapabilitiesImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerGroupImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPropertyValidator.java
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/RegistrationPropertyValidator.java
Modified:
jbossexo/modules/wsrp/trunk/producer/pom.xml
Log:
- Merged formerly extracted registration module into producer module as it won't be
used for anything else, normally.
Modified: jbossexo/modules/wsrp/trunk/producer/pom.xml
===================================================================
--- jbossexo/modules/wsrp/trunk/producer/pom.xml 2009-08-26 08:30:21 UTC (rev 13790)
+++ jbossexo/modules/wsrp/trunk/producer/pom.xml 2009-08-26 10:12:59 UTC (rev 13791)
@@ -58,16 +58,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.portal.registration</groupId>
- <artifactId>registration-api</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.portal.registration</groupId>
- <artifactId>registration-impl</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
<groupId>org.jboss.portal.portlet</groupId>
<artifactId>portlet-portlet</artifactId>
<version>${version.portlet}</version>
@@ -79,45 +69,6 @@
<version>${version.portlet}</version>
<scope>provided</scope>
</dependency>
- <!-- <dependency>
- <groupId>org.jboss.portal.jems</groupId>
- <artifactId>jems</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>-->
-
- <!-- JBoss dependencies -->
- <!--<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common</artifactId>
- <version>${version.jbossas}</version>
- </dependency>-->
- <!--<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- <version>${version.jbossas}</version>
- </dependency>-->
- <!-- For JBoss AOP -->
- <!--<dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-jmx</artifactId>
- <version>${version.jbossas}</version>
- </dependency>-->
- <!-- Services & Hibernate dependencies -->
- <!--<dependency>
- <groupId>org.jboss.portal.jems</groupId>
- <artifactId>jems</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>-->
-
-
- <!-- other dependencies -->
- <!-- <dependency>
- <groupId>javax.xml</groupId>
- <artifactId>jaxrpc-api</artifactId>
- <version>${version.jaxrpc}</version>
- <scope>provided</scope>
- </dependency>-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Consumer.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Consumer.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Consumer.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.util.Collection;
+
+/**
+ * An entity that groups several registrations under the same scope, for exemple a
Consumer entity could be related to
+ * several registrations for the same consumer with different capabilities.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision:5641 $
+ * @since 2.6
+ */
+public interface Consumer
+{
+
+ /**
+ * Return the consumer name.
+ *
+ * @return the consumer name
+ */
+ String getName();
+
+ /**
+ * Return the registration status of the consumer entity.
+ *
+ * @return the registration stats.
+ */
+ RegistrationStatus getStatus();
+
+ /**
+ * Set the registration status of the consumer entity.
+ *
+ * @param status the registration status
+ */
+ void setStatus(RegistrationStatus status);
+
+ /**
+ * Return all the registrations for the specified consumer.
+ *
+ * @return the consumer registrations
+ * @throws RegistrationException
+ */
+ Collection getRegistrations() throws RegistrationException;
+
+ /**
+ * Returns the group that this consumer belongs to.
+ *
+ * @return the consumer group
+ */
+ ConsumerGroup getGroup();
+
+ /**
+ * Retrieves this Consumer's identity, which uniquely identifies the Consumer
since the name cannot be relied on. It
+ * is up to the {@link RegistrationPolicy} to determine what the Consumer's
identity is. Note also that this is
+ * different from the Consumer's database identifier.
+ *
+ * @return this Consumer's identity.
+ */
+ String getId();
+
+ ConsumerCapabilities getCapabilities();
+
+ void setCapabilities(ConsumerCapabilities capabilities);
+
+ void setGroup(ConsumerGroup group) throws RegistrationException,
DuplicateRegistrationException;
+
+ String getConsumerAgent();
+
+ void setConsumerAgent(String consumerAgent) throws IllegalArgumentException,
IllegalStateException;
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerCapabilities.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerCapabilities.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerCapabilities.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public interface ConsumerCapabilities
+{
+ boolean supportsGetMethod();
+
+ /**
+ * Returns the list of supported {@link org.jboss.portal.Mode}s
+ *
+ * @return
+ */
+ List getSupportedModes();
+
+ /**
+ * Returns the list of supported {@link org.jboss.portal.WindowState}s
+ *
+ * @return
+ */
+ List getSupportedWindowStates();
+
+ /**
+ * Returns the list of user scopes (e.g. "wsrp:perUser") the associated
Consumer is willing to process. See WSRP 1.0
+ * 7.1.1 for more details.
+ *
+ * @return
+ */
+ List getSupportedUserScopes();
+
+ /**
+ * Returns the list of names of UserProfile extensions the associated Consumer
supports. See WSRP 1.0 7.1.1 for more
+ * details.
+ *
+ * @return
+ */
+ List getSupportedUserProfileData();
+
+ void setSupportsGetMethod(boolean supportsGetMethod);
+
+ void setSupportedModes(List supportedModes);
+
+ void setSupportedWindowStates(List supportedWindowStates);
+
+ void setSupportedUserScopes(List supportedUserScopes);
+
+ void setSupportedUserProfileData(List supportedUserProfileData);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerGroup.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerGroup.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/ConsumerGroup.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.util.Collection;
+
+/**
+ * A business entity that is related to several consumers.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public interface ConsumerGroup
+{
+
+ /**
+ * Return this ConsumerGroup's name (i.e. the name of the the business entity
aggregating the associated consumers)
+ *
+ * @return the ConsumerGroup's name
+ */
+ String getName();
+
+ /**
+ * Return a collection of associated consumers.
+ *
+ * @return the consumer collection
+ * @throws RegistrationException
+ */
+ Collection getConsumers() throws RegistrationException;
+
+ /**
+ * Return the member Consumer associated with the given identifier
+ *
+ * @param consumerId
+ * @return the Consumer associated with the identity or <code>null</code>
if no such Consumer is part of this
+ * ConsumerGroup
+ * @throws IllegalArgumentException if the consumer identity is null
+ * @throws RegistrationException
+ */
+ Consumer getConsumer(String consumerId) throws IllegalArgumentException,
RegistrationException;
+
+ void addConsumer(Consumer consumer) throws RegistrationException;
+
+ void removeConsumer(Consumer consumer) throws RegistrationException;
+
+ boolean contains(Consumer consumer);
+
+ boolean isEmpty();
+
+ RegistrationStatus getStatus();
+
+ void setStatus(RegistrationStatus status);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/DuplicateRegistrationException.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/DuplicateRegistrationException.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/DuplicateRegistrationException.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5641 $
+ */
+public class DuplicateRegistrationException extends RegistrationException
+{
+ public DuplicateRegistrationException()
+ {
+ }
+
+ public DuplicateRegistrationException(String message)
+ {
+ super(message);
+ }
+
+ public DuplicateRegistrationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public DuplicateRegistrationException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/InvalidConsumerDataException.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/InvalidConsumerDataException.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/InvalidConsumerDataException.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class InvalidConsumerDataException extends RegistrationException
+{
+
+ public InvalidConsumerDataException()
+ {
+ }
+
+ public InvalidConsumerDataException(String message)
+ {
+ super(message);
+ }
+
+ public InvalidConsumerDataException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public InvalidConsumerDataException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/NoSuchRegistrationException.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/NoSuchRegistrationException.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/NoSuchRegistrationException.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5641 $
+ */
+public class NoSuchRegistrationException extends RegistrationException
+{
+ public NoSuchRegistrationException()
+ {
+ }
+
+ public NoSuchRegistrationException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchRegistrationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NoSuchRegistrationException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/PropertyDescription.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/PropertyDescription.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/PropertyDescription.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 9177 $
+ * @since 2.6.3
+ */
+public interface PropertyDescription
+{
+ QName getName();
+
+ QName getType();
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Registration.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Registration.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/Registration.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * A class representing an association between a consumer and a producer.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public interface Registration
+{
+ /**
+ * Retrieves the internal identifier for this Registration. This will correspond to
the database key for this
+ * Registration. This identifier can be used by {@link RegistrationPolicy} to create a
handle for this Registration.
+ *
+ * @return this Registration's internal identifier.
+ */
+ String getId();
+
+ /**
+ * Sets the handle for this Registration.
+ *
+ * @param handle
+ */
+ void setRegistrationHandle(String handle);
+
+ /**
+ * Retrieves the handle associated with this Registration
+ *
+ * @return the registration handle
+ */
+ String getRegistrationHandle();
+
+ /**
+ * Return the consumer owning this registration.
+ *
+ * @return the owning consumer
+ */
+ Consumer getConsumer();
+
+ /**
+ * Retrieve the properties associated with this Registration.
+ *
+ * @return a Map containing the associated properties
+ */
+ Map getProperties();
+
+ void setPropertyValueFor(QName propertyName, Object value) throws
IllegalArgumentException;
+
+ void setPropertyValueFor(String propertyName, Object value);
+
+ boolean hasEqualProperties(Registration registration);
+
+ boolean hasEqualProperties(Map properties);
+
+ /**
+ * Return the status of this specific registration.
+ *
+ * @return the status
+ */
+ RegistrationStatus getStatus();
+
+ /**
+ * Update the registration status
+ *
+ * @param status the new status
+ */
+ void setStatus(RegistrationStatus status);
+
+ /** Clears any state (cloned portlet information, session, etc) associated with this
Registration */
+ void clearAssociatedState();
+
+ void updateProperties(Map registrationProperties);
+
+ void removeProperty(QName propertyName);
+
+ void removeProperty(String propertyName);
+
+ Object getPropertyValueFor(QName propertyName);
+
+ Object getPropertyValueFor(String propertyName);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationException.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationException.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationException.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5641 $
+ */
+public class RegistrationException extends Exception
+{
+ public RegistrationException()
+ {
+ }
+
+ public RegistrationException(String message)
+ {
+ super(message);
+ }
+
+ public RegistrationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public RegistrationException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationFailedException.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationFailedException.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationFailedException.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5641 $
+ */
+public class RegistrationFailedException
+{
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationLocal.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationLocal.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationLocal.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+
+/**
+ * Hold registration provided by the consumer for the duration of the invocation.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class RegistrationLocal
+{
+
+ /** The thread local to keep track of the registration associated with the current
thread of execution. */
+ private static final ThreadLocal registrationLocal = new ThreadLocal();
+
+ /**
+ * Sets the current registration for the Consumer for the current invocation.
+ *
+ * @param registration the Registration associated with the Consumer. Set to
<code>null</code> if no Registration
+ * exists for the current Consumer.
+ */
+ public static void setRegistration(Registration registration)
+ {
+ registrationLocal.set(registration);
+ }
+
+ public static Registration getRegistration()
+ {
+ return (Registration)registrationLocal.get();
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationManager.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationManager.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationManager.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8966 $
+ * @since 2.6
+ */
+public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener
+{
+ RegistrationPolicy getPolicy();
+
+ void setPolicy(RegistrationPolicy policy);
+
+ RegistrationPersistenceManager getPersistenceManager();
+
+ void setPersistenceManager(RegistrationPersistenceManager persistenceManager);
+
+ Registration addRegistrationTo(String consumerName, Map registrationProperties,
boolean createConsumerIfNeeded)
+ throws RegistrationException;
+
+ Consumer createConsumer(String name) throws RegistrationException,
InvalidConsumerDataException;
+
+ Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean
createGroupIfNeeded,
+ boolean createConsumerIfNeeded) throws
RegistrationException;
+
+ ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException;
+
+ void removeConsumer(String identity) throws RegistrationException,
NoSuchRegistrationException;
+
+ void removeConsumer(Consumer consumer) throws RegistrationException,
NoSuchRegistrationException;
+
+ Consumer getConsumerByIdentity(String identity) throws RegistrationException;
+
+ Consumer getConsumerFor(String registrationHandle) throws RegistrationException;
+
+ Registration getRegistration(String registrationHandle) throws RegistrationException;
+
+ void removeRegistration(String registrationHandle) throws RegistrationException,
NoSuchRegistrationException;
+
+ void removeRegistration(Registration registration) throws RegistrationException,
NoSuchRegistrationException;
+
+ ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException;
+
+ Collection getConsumerGroups() throws RegistrationException;
+
+ void removeConsumerGroup(ConsumerGroup group) throws RegistrationException;
+
+ void removeConsumerGroup(String name) throws RegistrationException;
+
+ Collection getConsumers() throws RegistrationException;
+
+ void clear() throws RegistrationException;
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPersistenceManager.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPersistenceManager.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPersistenceManager.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public interface RegistrationPersistenceManager
+{
+ /**
+ * Creates a Consumer with the specified identity and name (which might be the same,
depending on the policy)
+ *
+ * @param consumerId
+ * @param consumerName
+ */
+ Consumer createConsumer(String consumerId, String consumerName) throws
RegistrationException;
+
+ /**
+ * Retrieves the ConsumerGroup identified by the specified name.
+ *
+ * @param name the name of the group to be retrieved
+ * @return the ConsumerGroup identified by the specified name
+ * @throws RegistrationException
+ */
+ ConsumerGroup getConsumerGroup(String name) throws RegistrationException;
+
+ /**
+ * Creates a new ConsumerGroup with the associated name.
+ *
+ * @param name the name of the ConsumerGroup to be created
+ * @return a new ConsumerGroup with the associated name
+ * @throws RegistrationException
+ */
+ ConsumerGroup createConsumerGroup(String name) throws RegistrationException;
+
+ void removeConsumerGroup(String name) throws RegistrationException;
+
+ void removeConsumer(String consumerId) throws RegistrationException;
+
+ void removeRegistration(String registrationId) throws RegistrationException;
+
+ /**
+ * Return an existing consumer from its id.
+ *
+ * @param consumerId the consumer id
+ * @return the consumer or null if it does not exist
+ * @throws IllegalArgumentException if the consumer id argument is null
+ * @throws RegistrationException
+ */
+ Consumer getConsumerById(String consumerId) throws IllegalArgumentException,
RegistrationException;
+
+ Registration addRegistrationFor(String consumerId, Map registrationProperties) throws
RegistrationException;
+
+ Collection getConsumerGroups();
+
+ Registration getRegistration(String registrationId);
+
+ Consumer addConsumerToGroupNamed(String consumerId, String groupName) throws
RegistrationException;
+
+ Collection getConsumers();
+
+ Collection getRegistrations();
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicy.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicy.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicy.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * An interface allowing users of the Registration service to customize different aspects
of how Consumers are handled.
+ * Methods of this interface are used by RegistrationManager to make appropriate
decisions. Implementations of this
+ * interface <strong>MUST</strong> provide a no-argument constructor for
instantiation from the class name.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11406 $
+ * @since 2.6
+ */
+public interface RegistrationPolicy
+{
+ /**
+ * Examines and determines whether the given registration properties are adequate for
the Consumer associated with
+ * the given identity. This method is called before a Registration is created and thus
allows users to decide whether
+ * or not to reject a given registration if not satisfied with the given registration
properties.
+ *
+ * @param registrationProperties a Map containing the registration properties in the
form of property name (QName) -
+ * property value (Object) mappings
+ * @param consumerIdentity the Consumer identity (as returned by {@link
#getConsumerIdFrom(String,
+ * java.util.Map)}) for which the registration
properties must be ascertained
+ * @throws IllegalArgumentException if any of the registration properties is invalid
for the specified Consumer
+ * @throws RegistrationException if an exception occured in the registration
service
+ */
+ void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription>
registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException;
+
+ /**
+ * Generates a registration handle based on the database identity of the Registration.
This allows users to customize
+ * the registration handle format if they want to prevent exposure of database-related
data.
+ *
+ * @param registrationId the database identity of the Registration for which a handle
is required.
+ * @return a registration handle for the Registration associated with the specified
identifier.
+ * @throws IllegalArgumentException if the specified registration identity if
<code>null</code> or empty
+ */
+ String createRegistrationHandleFor(String registrationId) throws
IllegalArgumentException;
+
+ /**
+ * Determines the ConsumerGroup name to which the Consumer associated with the
specified name should be assigned with
+ * or <code>null</code> if the Consumer should not be automatically
assigned to a ConsumerGroup. This method is
+ * called during the Consumer creation process to see if the Consumer should be
automatically added to a
+ * ConsumerGroup.
+ *
+ * @param consumerName the name of the Consumer being created
+ * @return the name of the ConsumerGroup the Consumer must be automatically added to
or <code>null</code> if the
+ * Consumer will not be automatically to a ConsumerGroup at creation
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
+ */
+ String getAutomaticGroupNameFor(String consumerName) throws IllegalArgumentException;
+
+ /**
+ * Obtains a consumer identity which uniquely identifies a Consumer in function of the
consumer name and registration
+ * properties. This is potentially necessary because Consumer names are not guaranteed
to be unique (even though the
+ * specification states that they should).
+ *
+ * @param consumerName the consumer name
+ * @param registrationProperties a Map containing the registration properties in the
form of property name (QName) -
+ * property value (Object) mappings. Producer
implementations might use the
+ * registration properties to provide secure Consumer
identity.
+ * @return the consumer identity
+ * @throws InvalidConsumerDataException if the Policy examines the specified
registration properties to determine the
+ * Consumer identity and decides that they are
not in a proper state
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
+ */
+ String getConsumerIdFrom(String consumerName, Map registrationProperties)
+ throws IllegalArgumentException, InvalidConsumerDataException;
+
+ /**
+ * Determines if the specified Consumer name is acceptable. This method is called
before a Consumer is created and
+ * before a unique Consumer identity is created. This is in particular used if the
Policy mandates that Consumer
+ * names must be unique.
+ *
+ * @param consumerName the name of the Consumer as passed during the registration
process
+ * @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
+ * @throws RegistrationException if an exception occurred in the Registration
service
+ */
+ void validateConsumerName(String consumerName)
+ throws IllegalArgumentException, RegistrationException;
+
+ /**
+ * Determines if the specified ConsumerGroup name is acceptable. This method is called
before a ConsumerGroup is
+ * created.
+ *
+ * @param groupName the name of the ConsumerGroup to be created
+ * @throws IllegalArgumentException if the specified ConsumerGroup name if
<code>null</code> or empty
+ * @throws RegistrationException if an exception occurred in the Registration
service
+ */
+ void validateConsumerGroupName(String groupName) throws IllegalArgumentException,
RegistrationException;
+
+ /**
+ * Retrieves the RegistrationManager with which this RegistrationPolicy is
associated.
+ *
+ * @return the RegistrationManager with which this RegistrationPolicy is associated.
+ */
+ RegistrationManager getManager();
+
+ /**
+ * Associates this RegistrationPolicy with the specified RegistrationManager. This
method should not be called
+ * directly by client code as it used in the wiring process of the Registration
service.
+ *
+ * @param manager the RegistrationManager with which this RegistrationPolicy should be
associated.
+ */
+ void setManager(RegistrationManager manager);
+
+ /**
+ * Define what the expectations are as far as acceptable registration properties go.
+ *
+ * @param registrationPropertyDescriptions
+ * a map of containing the description of expected registrations
+ * @since 2.6.3
+ */
+ void setExpectations(Map<QName, ? extends PropertyDescription>
registrationPropertyDescriptions);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPolicyChangeListener.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8966 $
+ * @since 2.6.3
+ */
+public interface RegistrationPolicyChangeListener
+{
+ void policyUpdatedTo(RegistrationPolicy policy);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPropertyChangeListener.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPropertyChangeListener.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationPropertyChangeListener.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 9177 $
+ * @since 2.6
+ */
+public interface RegistrationPropertyChangeListener
+{
+ void propertiesHaveChanged(Map<QName, ? extends PropertyDescription>
newRegistrationProperties);
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationStatus.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationStatus.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationStatus.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import java.io.Serializable;
+
+/**
+ * Type safe enumeration that describes the status of a registration.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5641 $
+ */
+public class RegistrationStatus implements Serializable
+{
+ private String humanReadable;
+
+ /** The registration is valid. */
+ public static final RegistrationStatus VALID = new
RegistrationStatus("valid");
+
+ /** The registration is waiting for validation. */
+ public static final RegistrationStatus PENDING = new
RegistrationStatus("pending");
+
+ /** The registration is not valid. */
+ public static final RegistrationStatus INVALID = new
RegistrationStatus("invalid");
+
+ private RegistrationStatus(String humanReadable)
+ {
+ this.humanReadable = humanReadable;
+ }
+
+ public String toString()
+ {
+ return "RegistrationStatus: " + humanReadable;
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationUtils.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationUtils.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/RegistrationUtils.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 10388 $
+ * @since 2.6
+ */
+public class RegistrationUtils
+{
+ private static boolean strict = true;
+ private static final Logger log = LoggerFactory.getLogger(RegistrationUtils.class);
+
+ public static void setStrict(boolean strict)
+ {
+ RegistrationUtils.strict = strict;
+ log.debug("Using " + (strict ? "strict" : "lenient")
+ " Consumer Agent validation mode.");
+ }
+
+ /**
+ * @param consumerAgent
+ * @throws IllegalArgumentException
+ * @since 2.6
+ */
+ public static void validateConsumerAgent(String consumerAgent) throws
IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerAgent,
"consumer agent", null);
+ char periodChar = '.';
+ int period = consumerAgent.indexOf(periodChar);
+ if (period != -1)
+ {
+ consumerAgent = consumerAgent.substring(period);
+ period = consumerAgent.indexOf(periodChar);
+
+ if (period != -1)
+ {
+ return;
+ }
+ }
+
+ String msg = "'" + consumerAgent + "' is not a valid
Consumer Agent. Please notify your Consumer provider that it is not
WSRP-compliant.";
+ if (strict)
+ {
+ throw new IllegalArgumentException(msg);
+ }
+ else
+ {
+ log.debug(msg);
+ }
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerCapabilitiesImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerCapabilitiesImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerCapabilitiesImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.registration.ConsumerCapabilities;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class ConsumerCapabilitiesImpl implements ConsumerCapabilities
+{
+ private boolean supportsGetMethod;
+ private List supportedModes;
+ private List supportedWindowStates;
+ private List supportedUserScopes;
+ private List supportedUserProfileData;
+
+ public boolean supportsGetMethod()
+ {
+ return supportsGetMethod;
+ }
+
+ public List getSupportedModes()
+ {
+ return supportedModes;
+ }
+
+ public List getSupportedWindowStates()
+ {
+ return supportedWindowStates;
+ }
+
+ public List getSupportedUserScopes()
+ {
+ return supportedUserScopes;
+ }
+
+ public List getSupportedUserProfileData()
+ {
+ return supportedUserProfileData;
+ }
+
+ public void setSupportsGetMethod(boolean supportsGetMethod)
+ {
+ this.supportsGetMethod = supportsGetMethod;
+ }
+
+ public void setSupportedModes(List supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public void setSupportedWindowStates(List supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public void setSupportedUserScopes(List supportedUserScopes)
+ {
+ this.supportedUserScopes = supportedUserScopes;
+ }
+
+ public void setSupportedUserProfileData(List supportedUserProfileData)
+ {
+ this.supportedUserProfileData = supportedUserProfileData;
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerGroupImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerGroupImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerGroupImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.ConsumerGroup;
+import org.jboss.portal.registration.NoSuchRegistrationException;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationStatus;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5672 $
+ */
+public class ConsumerGroupImpl implements ConsumerGroup
+{
+
+ private String name;
+ private Map consumers;
+ private RegistrationStatus status;
+
+
+ private ConsumerGroupImpl()
+ {
+ init();
+ }
+
+ ConsumerGroupImpl(String name)
+ {
+ this.name = name;
+ init();
+ }
+
+ private void init()
+ {
+ this.consumers = new HashMap();
+ status = RegistrationStatus.PENDING;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ConsumerGroupImpl that = (ConsumerGroupImpl)o;
+
+ return name.equals(that.name);
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ public RegistrationStatus getStatus()
+ {
+ return status;
+ }
+
+ public void setStatus(RegistrationStatus status)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(status,
"RegistrationStatus");
+ this.status = status;
+ }
+
+ public Collection getConsumers() throws RegistrationException
+ {
+ return Collections.unmodifiableCollection(consumers.values());
+ }
+
+ public Consumer getConsumer(String consumerId) throws IllegalArgumentException,
RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer name", null);
+ return (Consumer)consumers.get(consumerId);
+ }
+
+ public boolean isEmpty()
+ {
+ return consumers.isEmpty();
+ }
+
+ public void addConsumer(Consumer consumer) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+ String identity = consumer.getId();
+ if (consumers.containsKey(identity))
+ {
+ throw new IllegalArgumentException("ConsumerGroup named '" + name
+ + "' already contains a Consumer named '" +
consumer.getName() + "' (identity: '" + identity + "')");
+ }
+
+ consumers.put(identity, consumer);
+ consumer.setGroup(this);
+ }
+
+ public void removeConsumer(Consumer consumer) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ if (consumers.remove(consumer.getId()) == null)
+ {
+ throw new NoSuchRegistrationException("ConsumerGroup named '" +
name
+ + "' does not contain a Consumer named '" +
consumer.getName() + "' (identity: '" + consumer.getId()
+ + "')");
+ }
+
+ consumer.setGroup(null);
+ }
+
+ public boolean contains(Consumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ return consumers.containsKey(consumer.getId());
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/ConsumerImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.ConsumerCapabilities;
+import org.jboss.portal.registration.ConsumerGroup;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationStatus;
+import org.jboss.portal.registration.RegistrationUtils;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class ConsumerImpl implements Consumer
+{
+
+ private String name;
+ private String identity;
+ private String consumerAgent;
+ private Set registrations;
+ private RegistrationStatus status;
+ private ConsumerGroup group;
+ private ConsumerCapabilities capabilities;
+
+
+ private ConsumerImpl()
+ {
+ init();
+ }
+
+ ConsumerImpl(String identity, String name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "name",
"Consumer");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name,
"identity", "Consumer");
+
+ this.name = name;
+ this.identity = identity;
+ init();
+ }
+
+ private void init()
+ {
+ registrations = new HashSet(7);
+ status = RegistrationStatus.PENDING;
+ capabilities = new ConsumerCapabilitiesImpl();
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ ConsumerImpl consumer = (ConsumerImpl)o;
+
+ return identity.equals(consumer.identity);
+ }
+
+ public int hashCode()
+ {
+ return identity.hashCode();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getId()
+ {
+ return identity;
+ }
+
+
+ public String getConsumerAgent()
+ {
+ return consumerAgent;
+ }
+
+ public void setConsumerAgent(String consumerAgent) throws IllegalArgumentException,
IllegalStateException
+ {
+ if (consumerAgent != null && !consumerAgent.equals(this.consumerAgent))
+ {
+ RegistrationUtils.validateConsumerAgent(consumerAgent);
+ this.consumerAgent = consumerAgent;
+ }
+ }
+
+ public ConsumerCapabilities getCapabilities()
+ {
+ return capabilities;
+ }
+
+ public void setCapabilities(ConsumerCapabilities capabilities)
+ {
+ this.capabilities = capabilities;
+ }
+
+ public RegistrationStatus getStatus()
+ {
+ return status;
+ }
+
+ public void setStatus(RegistrationStatus status)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(status,
"RegistrationStatus");
+ this.status = status;
+ }
+
+ public Collection getRegistrations() throws RegistrationException
+ {
+ return Collections.unmodifiableSet(registrations);
+ }
+
+ public ConsumerGroup getGroup()
+ {
+ return group;
+ }
+
+ void addRegistration(Registration registration)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
+
+ registrations.add(registration);
+ }
+
+ void removeRegistration(Registration registration) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
+
+ registrations.remove(registration);
+
+ // status should become pending if there are no registrations
+ if (registrations.isEmpty())
+ {
+ setStatus(RegistrationStatus.PENDING);
+ }
+ }
+
+ public void setGroup(ConsumerGroup group) throws RegistrationException
+ {
+ if (this.group != null)
+ {
+ // if we're trying to set the same group, just return
+ if (this.group.equals(group))
+ {
+ return;
+ }
+
+ if (this.group.contains(this))
+ {
+ this.group.removeConsumer(this);
+ }
+ }
+
+ this.group = group;
+
+ if (group != null && !this.group.contains(this))
+ {
+ group.addConsumer(this);
+ }
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationStatus;
+
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class RegistrationImpl implements Registration
+{
+
+ private final String id;
+ private ConsumerImpl consumer;
+ private RegistrationStatus status;
+ private Map properties;
+ private String registrationHandle;
+
+
+ public RegistrationImpl(String id, ConsumerImpl consumer, RegistrationStatus status,
Map properties)
+ {
+ this.id = id;
+ this.consumer = consumer;
+ this.status = status;
+ this.properties = new HashMap(properties);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setRegistrationHandle(String handle)
+ {
+ this.registrationHandle = handle;
+ }
+
+ public String getRegistrationHandle()
+ {
+ return registrationHandle;
+ }
+
+ public Consumer getConsumer()
+ {
+ return consumer;
+ }
+
+ public Map getProperties()
+ {
+ return Collections.unmodifiableMap(properties);
+ }
+
+ public void setPropertyValueFor(QName propertyName, Object value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ ParameterValidation.throwIllegalArgExceptionIfNull(value, "Property
value");
+
+ // avoid modifying the properties if new value is the same as old one
+ Object oldValue = properties.get(propertyName);
+ if (!value.equals(oldValue))
+ {
+ properties.put(propertyName, value);
+ }
+ }
+
+ public void setPropertyValueFor(String propertyName, Object value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ setPropertyValueFor(new QName(propertyName), value);
+ }
+
+ public Object getPropertyValueFor(QName propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ return properties.get(propertyName);
+ }
+
+ public Object getPropertyValueFor(String propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ return getPropertyValueFor(new QName(propertyName));
+ }
+
+
+ public void removeProperty(QName propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ properties.remove(propertyName);
+ }
+
+ public void removeProperty(String propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+ removeProperty(new QName(propertyName));
+ }
+
+ public boolean hasEqualProperties(Registration registration)
+ {
+ if (registration == null)
+ {
+ return false;
+ }
+
+ Map other = registration.getProperties();
+ return hasEqualProperties(other);
+ }
+
+ public boolean hasEqualProperties(Map registrationProperties)
+ {
+ if (registrationProperties == null)
+ {
+ return false;
+ }
+
+ if (properties.size() != registrationProperties.size())
+ {
+ return false;
+ }
+
+ // check properties
+ for (Iterator props = properties.entrySet().iterator(); props.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)props.next();
+
+ // we should have a 1-1 match between name/value pair
+ QName name = (QName)entry.getKey();
+ if (!entry.getValue().equals(registrationProperties.get(name)))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public void setRegistrationPropertyValueFor(String propertyName, Object value)
+ {
+ setPropertyValueFor(new QName(propertyName), value);
+ }
+
+ public RegistrationStatus getStatus()
+ {
+ return status;
+ }
+
+ public void setStatus(RegistrationStatus status)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(status,
"RegistrationStatus");
+ this.status = status;
+ }
+
+ public void clearAssociatedState()
+ {
+ //todo: implement
+ }
+
+ public void updateProperties(Map registrationProperties)
+ {
+ properties = new HashMap(registrationProperties);
+ }
+
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationManagerImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,358 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.ConsumerGroup;
+import org.jboss.portal.registration.InvalidConsumerDataException;
+import org.jboss.portal.registration.NoSuchRegistrationException;
+import org.jboss.portal.registration.PropertyDescription;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationManager;
+import org.jboss.portal.registration.RegistrationPersistenceManager;
+import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11604 $
+ * @since 2.6
+ */
+public class RegistrationManagerImpl implements RegistrationManager
+{
+ private static final Logger log = LoggerFactory.getLogger(RegistrationManager.class);
+
+ private RegistrationPolicy policy;
+ private RegistrationPersistenceManager persistenceManager;
+
+ public RegistrationManagerImpl()
+ {
+ }
+
+ public RegistrationPolicy getPolicy()
+ {
+ return policy;
+ }
+
+ public void setPolicy(RegistrationPolicy policy)
+ {
+ this.policy = policy;
+ policy.setManager(this);
+ }
+
+ public RegistrationPersistenceManager getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public void setPersistenceManager(RegistrationPersistenceManager persistenceManager)
+ {
+ this.persistenceManager = persistenceManager;
+ }
+
+ public Registration addRegistrationTo(String consumerName, Map registrationProperties,
boolean createConsumerIfNeeded)
+ throws RegistrationException
+ {
+ // the policy determines the identity of the consumer based on the given
information (note that this might be obsoleted by using WS-Security)
+ String identity = policy.getConsumerIdFrom(consumerName, registrationProperties);
+
+ // validate the registration information
+ policy.validateRegistrationDataFor(registrationProperties, identity);
+
+ Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded,
consumerName);
+
+ // create the actual registration
+ Registration registration = persistenceManager.addRegistrationFor(identity,
registrationProperties);
+
+ // let the policy decide what the handle should be
+ String handle = policy.createRegistrationHandleFor(registration.getId());
+ registration.setRegistrationHandle(handle);
+
+ return registration;
+ }
+
+ public Consumer createConsumer(String name) throws RegistrationException,
InvalidConsumerDataException
+ {
+ // check with policy if we allow the consumer
+ policy.validateConsumerName(name);
+
+ String identity = policy.getConsumerIdFrom(name, Collections.EMPTY_MAP);
+
+ Consumer consumer = persistenceManager.createConsumer(identity, name);
+
+ // deal with group if needed
+ // let the policy decide if there should be a group associated with the Consumer
and if yes, with which id
+ String groupName = policy.getAutomaticGroupNameFor(name);
+ if (groupName != null)
+ {
+ addConsumerToGroupNamed(name, groupName, true, false);
+ }
+
+ return consumer;
+ }
+
+ public Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean
createGroupIfNeeded, boolean createConsumerIfNeeded) throws RegistrationException
+ {
+ // check with the policy if we allow the group name in case we need to create it
+ if (createGroupIfNeeded)
+ {
+ policy.validateConsumerGroupName(groupName);
+ }
+
+ // check with policy if we allow the consumer name in case we need to create it
+ if (createConsumerIfNeeded)
+ {
+ policy.validateConsumerName(consumerName);
+ }
+
+ ConsumerGroup group = getConsumerGroup(groupName);
+ boolean justCreatedGroup = false;
+ if (group == null)
+ {
+ if (createGroupIfNeeded)
+ {
+ createConsumerGroup(groupName);
+ justCreatedGroup = true;
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no existing
ConsumerGroup named '" + groupName + "'.");
+ }
+ }
+
+ String identity = policy.getConsumerIdFrom(consumerName, Collections.EMPTY_MAP);
+ try
+ {
+ getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
+ }
+ catch (NoSuchRegistrationException e)
+ {
+ if (justCreatedGroup)
+ {
+ removeConsumerGroup(groupName);
+ }
+ }
+
+ return persistenceManager.addConsumerToGroupNamed(identity, groupName);
+ }
+
+ public ConsumerGroup createConsumerGroup(String groupName) throws
RegistrationException
+ {
+ // check with the policy if we allow the group
+ policy.validateConsumerGroupName(groupName);
+
+ return persistenceManager.createConsumerGroup(groupName);
+ }
+
+ public void removeConsumer(String identity) throws RegistrationException,
NoSuchRegistrationException
+ {
+ Consumer consumer = getOrCreateConsumer(identity, false, null);
+
+ ConsumerGroup group = consumer.getGroup();
+ if (group != null)
+ {
+ group.removeConsumer(consumer);
+ }
+
+ // cascade delete the registrations
+ for (Iterator i = new ArrayList(consumer.getRegistrations()).iterator();
i.hasNext();)
+ {
+ removeRegistration((Registration)i.next());
+ }
+
+ // let the registry do the actual deletion
+ persistenceManager.removeConsumer(identity);
+ }
+
+ public void removeConsumer(Consumer consumer) throws RegistrationException,
NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
+
+ removeConsumer(consumer.getId());
+ }
+
+ public Consumer getConsumerByIdentity(String identity) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity,
"identity", null);
+ return persistenceManager.getConsumerById(identity);
+ }
+
+ public Consumer getConsumerFor(String registrationHandle) throws
RegistrationException
+ {
+ return (Consumer)getConsumerOrRegistration(registrationHandle, true);
+ }
+
+ public Registration getRegistration(String registrationHandle) throws
RegistrationException
+ {
+ return (Registration)getConsumerOrRegistration(registrationHandle, false);
+ }
+
+ public void removeRegistration(String registrationHandle) throws
RegistrationException, NoSuchRegistrationException
+ {
+ Registration registration = getRegistration(registrationHandle);
+ if (registration == null)
+ {
+ throw new NoSuchRegistrationException("There is no Registration with handle
'" + registrationHandle + "'");
+ }
+ removeRegistration(registration);
+ }
+
+ public void removeRegistration(Registration registration) throws
RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
+
+ registration.setStatus(RegistrationStatus.INVALID); // just in case...
+// registration.clearAssociatedState(); // todo: do we need to clear associated
state?
+
+ persistenceManager.removeRegistration(registration.getId());
+ }
+
+ public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName,
"ConsumerGroup name", null);
+ return persistenceManager.getConsumerGroup(groupName);
+ }
+
+ private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded,
String consumerName)
+ throws RegistrationException
+ {
+ Consumer consumer = getConsumerByIdentity(identity);
+ if (consumer == null)
+ {
+ if (createConsumerIfNeeded)
+ {
+ consumer = createConsumer(consumerName);
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no Consumer named
'" + consumerName + "'.");
+ }
+ }
+ return consumer;
+ }
+
+ private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
+
+ Registration registration =
persistenceManager.getRegistration(registrationHandle);
+ if (registration == null)
+ {
+ return null;
+ }
+ else
+ {
+ return getConsumer ? registration.getConsumer() : registration;
+ }
+ }
+
+ public Collection getConsumerGroups()
+ {
+ return persistenceManager.getConsumerGroups();
+ }
+
+ public void removeConsumerGroup(ConsumerGroup group) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(group,
"ConsumerGroup");
+
+ for (Object consumer : group.getConsumers())
+ {
+ removeConsumer((Consumer)consumer);
+ }
+
+ persistenceManager.removeConsumerGroup(group.getName());
+ }
+
+ public void removeConsumerGroup(String name) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "ConsumerGroup
name");
+ removeConsumerGroup(getConsumerGroup(name));
+ }
+
+ public Collection getConsumers()
+ {
+ return persistenceManager.getConsumers();
+ }
+
+ public void clear() throws RegistrationException
+ {
+ Collection<Consumer> consumers = new
ArrayList<Consumer>(getConsumers());
+ for (Consumer consumer : consumers)
+ {
+ removeConsumer(consumer);
+ }
+
+ Collection<ConsumerGroup> groups = new
ArrayList<ConsumerGroup>(getConsumerGroups());
+ for (ConsumerGroup group : groups)
+ {
+ removeConsumerGroup(group);
+ }
+ }
+
+ /**
+ * We listen to registration property changes on the producer configuration so that we
can invalidate the current
+ * registrations. Consumers will need to call modifyRegistration since properties have
changed... which requires
+ * throwing an OperationFailedFault... not an InvalidRegistrationFault!
+ *
+ * @param registrationProperties
+ */
+ public void propertiesHaveChanged(Map<QName, ? extends PropertyDescription>
registrationProperties)
+ {
+ log.debug("Registration properties have changed, existing registrations will
be invalidated...");
+ Collection registrations = persistenceManager.getRegistrations();
+ for (Object registration : registrations)
+ {
+ Registration reg = (Registration)registration;
+
+ // pending instead of invalid as technically, the registration is not yet
invalid
+ reg.setStatus(RegistrationStatus.PENDING);
+// reg.clearAssociatedState(); //todo: do we need to clear the associated state?
If we do, should we wait until current operations are done?
+ }
+
+ // make policy aware of new registration properties
+ policy.setExpectations(registrationProperties);
+ }
+
+ /**
+ * We listen for RegistrationPolicy changes so that we can provide the proper behavior
at all time if the policy has
+ * been changed by users since this RegistrationManager was initialized...
+ *
+ * @param policy
+ */
+ public void policyUpdatedTo(RegistrationPolicy policy)
+ {
+ setPolicy(policy);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/impl/RegistrationPersistenceManagerImpl.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.impl;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.ConsumerGroup;
+import org.jboss.portal.registration.DuplicateRegistrationException;
+import org.jboss.portal.registration.NoSuchRegistrationException;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationPersistenceManager;
+import org.jboss.portal.registration.RegistrationStatus;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class RegistrationPersistenceManagerImpl implements
RegistrationPersistenceManager
+{
+ private long lastRegistrationId;
+ private Map consumers = new HashMap();
+ private Map groups = new HashMap();
+ private Map registrations = new HashMap();
+
+ public Consumer createConsumer(String consumerId, String consumerName) throws
RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"Consumer name", null);
+
+ ConsumerImpl consumer = new ConsumerImpl(consumerId, consumerName);
+ consumer.setStatus(RegistrationStatus.PENDING);
+ consumers.put(consumerId, consumer);
+
+ return consumer;
+ }
+
+ public ConsumerGroup getConsumerGroup(String name) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "ConsumerGroup
name", null);
+
+ return (ConsumerGroup)groups.get(name);
+ }
+
+ public ConsumerGroup createConsumerGroup(String name) throws RegistrationException
+ {
+ ConsumerGroup group = getConsumerGroup(name);
+ if (group != null)
+ {
+ throw new DuplicateRegistrationException("A ConsumerGroup named '"
+ name + "' has already been registered.");
+ }
+ else
+ {
+ group = new ConsumerGroupImpl(name);
+ groups.put(name, group);
+ return group;
+ }
+ }
+
+ public void removeConsumerGroup(String name) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "ConsumerGroup
name", null);
+ if (groups.remove(name) == null)
+ {
+ throw new NoSuchRegistrationException("There is no ConsumerGroup named
'" + name + "'.");
+ }
+ }
+
+ public void removeConsumer(String consumerId) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
+ if (consumers.remove(consumerId) == null)
+ {
+ throw new RegistrationException("There is no Consumer with identity
'" + consumerId + "'.");
+ }
+ }
+
+ public void removeRegistration(String registrationId) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationId,
"Registration identity", null);
+
+ RegistrationImpl registration =
(RegistrationImpl)registrations.get(registrationId);
+ if (registration == null)
+ {
+ throw new NoSuchRegistrationException("There is no Registration with id
'" + registrationId + "'");
+ }
+
+ ConsumerImpl consumer = (ConsumerImpl)registration.getConsumer();
+ consumer.removeRegistration(registration);
+ registrations.remove(registrationId);
+ }
+
+ public Consumer getConsumerById(String consumerId) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
+
+ return (Consumer)consumers.get(consumerId);
+ }
+
+ public Registration addRegistrationFor(String consumerId, Map registrationProperties)
throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties,
"Registration properties");
+
+ ConsumerImpl consumer = (ConsumerImpl)getConsumerById(consumerId);
+ if (consumer == null)
+ {
+ throw new NoSuchRegistrationException("There is no Consumer with identity
'" + consumerId
+ + "' to add a Registration to...");
+ }
+
+ RegistrationImpl registration = new RegistrationImpl("" +
lastRegistrationId++, consumer,
+ RegistrationStatus.PENDING, registrationProperties);
+ consumer.addRegistration(registration);
+
+ registrations.put(registration.getId(), registration);
+
+ return registration;
+ }
+
+ public Consumer addConsumerToGroupNamed(String consumerId, String groupName) throws
RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName,
"ConsumerGroup name", null);
+
+ ConsumerGroupImpl group = (ConsumerGroupImpl)getConsumerGroup(groupName);
+ if (group == null)
+ {
+ throw new NoSuchRegistrationException("There is no ConsumerGroup named
'" + groupName
+ + "' to add a Consumer to...");
+ }
+
+ ConsumerImpl consumer = (ConsumerImpl)getConsumerById(consumerId);
+ if (consumer == null)
+ {
+ throw new NoSuchRegistrationException("There is no Consumer with identity
'" + consumerId
+ + "' to add to ConsumerGroup named '" + groupName +
"'. Did you create it?");
+ }
+
+ group.addConsumer(consumer);
+
+ return consumer;
+ }
+
+ public Collection getConsumers()
+ {
+ return Collections.unmodifiableCollection(consumers.values());
+ }
+
+ public Collection getRegistrations()
+ {
+ return Collections.unmodifiableCollection(registrations.values());
+ }
+
+ public Collection getConsumerGroups()
+ {
+ return Collections.unmodifiableCollection(groups.values());
+ }
+
+ public Registration getRegistration(String registrationId)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationId,
"Registration id", null);
+
+ return (Registration)registrations.get(registrationId);
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.policies;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.registration.Consumer;
+import org.jboss.portal.registration.DuplicateRegistrationException;
+import org.jboss.portal.registration.InvalidConsumerDataException;
+import org.jboss.portal.registration.PropertyDescription;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationException;
+import org.jboss.portal.registration.RegistrationManager;
+import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Provides a default implementation of RegistrationPolicy which should be enough for
most user needs provided the
+ * appropriate {@link RegistrationPropertyValidator} has been configured to validate
registration properties.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11406 $
+ * @since 2.6
+ */
+public class DefaultRegistrationPolicy implements RegistrationPolicy
+{
+ private RegistrationManager manager;
+ private RegistrationPropertyValidator validator;
+ private Map<QName, ? extends PropertyDescription> expectations;
+ private static final Logger log =
LoggerFactory.getLogger(DefaultRegistrationPolicy.class);
+
+
+ public RegistrationManager getManager()
+ {
+ return manager;
+ }
+
+ public void setManager(RegistrationManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public void setExpectations(Map<QName, ? extends PropertyDescription>
registrationPropertyDescriptions)
+ {
+ this.expectations = registrationPropertyDescriptions;
+ }
+
+ /**
+ * Only accepts the registration if no registration with identical values exists for
the Consumer identified by the
+ * specified identify and delegates the validation of properties to the configured
RegistrationPropertyValidator.
+ *
+ * @throws DuplicateRegistrationException if a Consumer with the same identity has
already registered with the same
+ * registration properties.
+ */
+ public void validateRegistrationDataFor(Map<QName, ? extends
PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties,
"Registration properties");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerIdentity,
"Consumer identity", null);
+
+ StringBuilder message = new StringBuilder();
+
+ // check that values are consistent with expectations
+ if (expectations != null)
+ {
+ Set<QName> expectedNames = expectations.keySet();
+ boolean consistentWithExpectations = true;
+
+ // check for extra properties
+ Set<QName> unexpected = new
HashSet<QName>(registrationProperties.keySet());
+ unexpected.removeAll(expectedNames);
+ if (!unexpected.isEmpty())
+ {
+ consistentWithExpectations = false;
+ message.append("Consumer '").append(consumerIdentity)
+ .append("' provided values for unexpected registration
properties:\n");
+ for (QName name : unexpected)
+ {
+ message.append("\t- ").append(name).append("\n");
+ }
+ }
+
+ for (Map.Entry<QName, ? extends PropertyDescription> entry :
expectations.entrySet())
+ {
+ QName name = entry.getKey();
+ Object value = registrationProperties.get(name);
+ try
+ {
+ validator.validateValueFor(name, value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ message.append("Missing value for expected
'").append(name.getLocalPart()).append("' property.\n");
+ consistentWithExpectations = false;
+ }
+ }
+
+ if (!consistentWithExpectations)
+ {
+ String messageString = message.toString();
+ log.debug(messageString);
+ throw new InvalidConsumerDataException(messageString);
+ }
+ }
+
+ // check that this is not a duplicate registration if the status is not pending
+ Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
+ if (consumer != null &&
!RegistrationStatus.PENDING.equals(consumer.getStatus()))
+ {
+ // allow the new registration only if the registration properties are different
that existing registrations
+ // for this consumer...
+ for (Object o : consumer.getRegistrations())
+ {
+ Registration registration = (Registration)o;
+ if (registration.hasEqualProperties(registrationProperties))
+ {
+ throw new DuplicateRegistrationException("Consumer named '"
+ consumer.getName()
+ + "' has already been registered with the same set of
registration properties. Registration rejected!");
+ }
+ }
+ }
+ }
+
+ /** Simply returns the given registration id. */
+ public String createRegistrationHandleFor(String registrationId)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationId,
"Registration id", null);
+ return registrationId;
+ }
+
+ /** Doesn't support automatic ConsumerGroups so always return
<code>null</code>. */
+ public String getAutomaticGroupNameFor(String consumerName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"Consumer name", null);
+ return null;
+ }
+
+ /** Simply returns the given consumer name, trusted (!) to be unique. */
+ public String getConsumerIdFrom(String consumerName, Map registrationProperties)
throws IllegalArgumentException, InvalidConsumerDataException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"Consumer name", null);
+ return consumerName;
+ }
+
+ /** Rejects registration if a Consumer with the specified name already exists. */
+ public void validateConsumerName(String consumerName) throws IllegalArgumentException,
RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName,
"Consumer name", null);
+
+ Consumer consumer = manager.getConsumerByIdentity(getConsumerIdFrom(consumerName,
Collections.EMPTY_MAP));
+ if (consumer != null)
+ {
+ throw new DuplicateRegistrationException("A Consumer named '" +
consumerName + "' has already been registered.");
+ }
+ }
+
+ /** Rejects name if a ConsumerGroup with the specified name already exists. */
+ public void validateConsumerGroupName(String groupName) throws
IllegalArgumentException, RegistrationException
+ {
+ // this is already the behavior in the RegistrationPersistenceManager so no need to
do anything
+ }
+
+ /**
+ * Instructs this policy to use the specified RegistrationPropertyValidator. There
shouldn't be any need to call this
+ * method manually, as the validator is configured via the WSRP Producer xml
configuration file.
+ *
+ * @param validator
+ */
+ public void setValidator(RegistrationPropertyValidator validator)
+ {
+ this.validator = validator;
+ }
+
+ /**
+ * Retrieves the currently configured RegistrationPropertyValidator.
+ *
+ * @return
+ */
+ public RegistrationPropertyValidator getValidator()
+ {
+ return validator;
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPropertyValidator.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPropertyValidator.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/DefaultRegistrationPropertyValidator.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.policies;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class DefaultRegistrationPropertyValidator implements
RegistrationPropertyValidator
+{
+ public void validateValueFor(QName propertyName, Object value) throws
IllegalArgumentException
+ {
+ // accepts only non-null, non-empty String values
+ if (!(value instanceof String) || ((String)value).length() <= 0)
+ {
+ throw new IllegalArgumentException(value + " is not a valid value for
property '" + propertyName +
+ "'. DefaultRegistrationPropertyValidator only accepts non-null,
non-empty Strings.");
+ }
+ }
+}
Added:
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/RegistrationPropertyValidator.java
===================================================================
---
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/RegistrationPropertyValidator.java
(rev 0)
+++
jbossexo/modules/wsrp/trunk/producer/src/main/java/org/jboss/portal/registration/policies/RegistrationPropertyValidator.java 2009-08-26
10:12:59 UTC (rev 13791)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, 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.registration.policies;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An interface providing an entry point for WSRP deployers to plug their registration
property validation mechanism in
+ * {@link org.jboss.portal.registration.policies.DefaultRegistrationPolicy}.
Implementations of this interface
+ * <strong>MUST</strong> provide a no-argument constructor for instantiation
from the class name.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public interface RegistrationPropertyValidator
+{
+ /**
+ * Validates the given value for the registration property identified by the specified
name. If the value is
+ * acceptable, the method simply returns. An invalid value will raise an exception.
+ *
+ * @param propertyName the qualified name for the property name
+ * @param value the value that needs to be validated
+ * @throws IllegalArgumentException if the specified value is not acceptable for the
specified property.
+ */
+ void validateValueFor(QName propertyName, Object value) throws
IllegalArgumentException;
+}