Author: chris.laprun(a)jboss.com
Date: 2006-11-28 00:41:09 -0500 (Tue, 28 Nov 2006)
New Revision: 5730
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfiguration.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfigurationService.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
Log:
- Renamed RegistrationConfiguration to ProducerConfiguration since it will include more
than just registration configuration.
- ProducerRegistrationRequirements now is able to notify listeners of changes to
registration properties.
- RegistrationPropertyDescription now knows about its parent
ProducerRegistrationRequirements so that changes can be propagated.
- RegistrationManager now listens for changes to registration configuration so that
registrations can be invalidated.
- Fixed incorrect behavior of RegistrationHandler.isRegistrationValid.
- Simplified RegistrationManager handling of registrations.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-28
01:46:21 UTC (rev 5729)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -156,20 +156,31 @@
}
String regHandle = registrationContext.getRegistrationHandle();
- if (regHandle == null)
- {
- throwInvalidRegistrationFault("missing required registration
handle!");
- }
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(regHandle,
"registration handle");
+ Registration reg;
try
{
- Registration reg =
producer.getRegistrationManager().getRegistration(regHandle);
- return reg != null &&
RegistrationStatus.VALID.equals(reg.getStatus());
+ reg = producer.getRegistrationManager().getRegistration(regHandle);
}
catch (RegistrationException e)
{
throw WSRPUtils.createOperationFailedFault(e);
}
+
+ if (reg == null)
+ {
+ throwInvalidRegistrationFault("provided registration handle '"
+ regHandle +
+ "' is not registered with this producer");
+ }
+
+ if (!RegistrationStatus.VALID.equals(reg.getStatus()))
+ {
+ throwInvalidRegistrationFault("provided registration is no longer
valid");
+ }
+
+ log.debug("registration is valid!");
+ return true;
}
else
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-28
01:46:21 UTC (rev 5729)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -75,7 +75,7 @@
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
-import org.jboss.portal.wsrp.producer.registration.config.RegistrationConfiguration;
+import org.jboss.portal.wsrp.producer.registration.config.ProducerConfiguration;
import
org.jboss.portal.wsrp.producer.registration.impl.ProducerRegistrationRequirementsImpl;
import org.jboss.portal.wsrp.servlet.ServletAccess;
@@ -113,7 +113,7 @@
private PortletManagementHandler portletManagementHandler;
/** Registration configuration service */
- private RegistrationConfiguration registrationConfiguration;
+ private ProducerConfiguration producerConfiguration;
/** Registration Manager */
private RegistrationManager registrationManager;
@@ -143,9 +143,9 @@
public ProducerRegistrationRequirements getProducerRegistrationRequirements()
{
ProducerRegistrationRequirements registrationRequirements =
DEFAULT_REGISTRATION_REQUIREMENTS;
- if (registrationConfiguration != null)
+ if (producerConfiguration != null)
{
- registrationRequirements =
registrationConfiguration.getRegistrationRequirements();
+ registrationRequirements = producerConfiguration.getRegistrationRequirements();
}
// still need to check for null, in case there wasn't any registration info in
the descriptor
@@ -252,14 +252,14 @@
return registrationState;
}
- public RegistrationConfiguration getRegistrationConfiguration()
+ public ProducerConfiguration getProducerConfiguration()
{
- return registrationConfiguration;
+ return producerConfiguration;
}
- public void setRegistrationConfiguration(RegistrationConfiguration
registrationConfiguration)
+ public void setProducerConfiguration(ProducerConfiguration producerConfiguration)
{
- this.registrationConfiguration = registrationConfiguration;
+ this.producerConfiguration = producerConfiguration;
}
public RegistrationManager getRegistrationManager()
@@ -272,6 +272,18 @@
this.registrationManager = registrationManager;
}
+ protected void startService() throws Exception
+ {
+ super.startService();
+
getProducerRegistrationRequirements().addRegistrationPropertyChangeListeners(registrationManager);
+ }
+
+ protected void stopService() throws Exception
+ {
+
getProducerRegistrationRequirements().removeRegistrationPropertyChangeListener(registrationManager);
+ super.stopService();
+ }
+
// PortletManagement implementation
*********************************************************************************
public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -56,7 +56,14 @@
{
}
+ public LocalizedString(LocalizedString other)
+ {
+ this.value = other.value;
+ this.locale = other.locale;
+ this.resourceName = other.resourceName;
+ }
+
public String toString()
{
return "LocalizedString{" +
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -33,7 +33,6 @@
*/
public interface ProducerRegistrationRequirements
{
-
boolean requiresRegistration();
void setRequiresRegistration(boolean requiresRegistration);
@@ -52,11 +51,24 @@
void clearRegistrationProperties();
- boolean acceptValueFor(Object value, QName propertyName);
+ boolean acceptValueFor(QName propertyName, Object value);
- boolean acceptValueFor(Object value, String propertyName);
+ boolean acceptValueFor(String propertyName, Object value);
RegistrationPropertyDescription getRegistrationPropertyWith(String name);
RegistrationPropertyDescription getRegistrationPropertyWith(QName name);
+
+ void notifyRegistrationPropertyChangeListeners();
+
+ void addRegistrationPropertyChangeListeners(RegistrationPropertyChangeListener
listener);
+
+ void clearRegistrationPropertyChangeListeners();
+
+ void removeRegistrationPropertyChangeListener(RegistrationPropertyChangeListener
listener);
+
+ interface RegistrationPropertyChangeListener
+ {
+ void propertiesHaveChanged();
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -31,7 +31,7 @@
* @version $Revision$
* @since 2.6
*/
-public interface RegistrationManager
+public interface RegistrationManager extends
ProducerRegistrationRequirements.RegistrationPropertyChangeListener
{
RegistrationPolicy getPolicy();
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -31,7 +31,7 @@
* @version $Revision$
* @since 2.6
*/
-public class RegistrationPropertyDescription
+public class RegistrationPropertyDescription implements Cloneable
{
private QName name;
private QName type;
@@ -41,6 +41,7 @@
private LocalizedString label;
private String[] usages;
private QName[] aliases;
+ private transient ProducerRegistrationRequirements parent;
public RegistrationPropertyDescription(QName name, QName type)
@@ -58,6 +59,25 @@
{
}
+ public RegistrationPropertyDescription(RegistrationPropertyDescription other)
+ {
+ setName(new QName(other.name.toString()));
+ setType(new QName(other.type.toString()));
+
+ aliases = new QName[other.aliases.length];
+ System.arraycopy(other.aliases, 0, aliases, 0, other.aliases.length);
+
+ setDescription(new LocalizedString(other.description));
+ setHint(new LocalizedString(other.hint));
+ setLabel(new LocalizedString(other.label));
+ setSchemaLocation(other.schemaLocation);
+
+ usages = new String[other.usages.length];
+ System.arraycopy(other.usages, 0, usages, 0, other.usages.length);
+
+ parent = other.parent;
+ }
+
public QName getName()
{
return name;
@@ -66,6 +86,7 @@
public void setName(QName name)
{
this.name = name;
+ notifyParentOfChangeIfNeeded();
}
public QName getType()
@@ -76,6 +97,7 @@
public void setType(QName type)
{
this.type = type;
+ notifyParentOfChangeIfNeeded();
}
public URI getSchemaLocation()
@@ -86,6 +108,7 @@
public void setSchemaLocation(URI schemaLocation)
{
this.schemaLocation = schemaLocation;
+ notifyParentOfChangeIfNeeded();
}
public LocalizedString getDescription()
@@ -96,6 +119,7 @@
public void setDescription(LocalizedString description)
{
this.description = description;
+ notifyParentOfChangeIfNeeded();
}
public void setDefaultDescription(String value)
@@ -111,6 +135,7 @@
public void setHint(LocalizedString hint)
{
this.hint = hint;
+ notifyParentOfChangeIfNeeded();
}
public void setDefaultHint(String value)
@@ -126,6 +151,7 @@
public void setLabel(LocalizedString label)
{
this.label = label;
+ notifyParentOfChangeIfNeeded();
}
public void setDefaultLabel(String value)
@@ -140,7 +166,9 @@
public void setUsages(String[] usages)
{
- this.usages = usages;
+ this.usages = new String[usages.length];
+ System.arraycopy(usages, 0, this.usages, 0, usages.length);
+ notifyParentOfChangeIfNeeded();
}
public QName[] getAliases()
@@ -150,6 +178,21 @@
public void setAliases(QName[] aliases)
{
- this.aliases = aliases;
+ this.aliases = new QName[aliases.length];
+ System.arraycopy(aliases, 0, this.aliases, 0, aliases.length);
+ notifyParentOfChangeIfNeeded();
}
+
+ public void setParent(ProducerRegistrationRequirements requirements)
+ {
+ this.parent = requirements;
+ }
+
+ private void notifyParentOfChangeIfNeeded()
+ {
+ if (parent != null)
+ {
+ parent.notifyRegistrationPropertyChangeListeners();
+ }
+ }
}
Copied:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfiguration.java
(from rev 5722,
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java)
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java 2006-11-27
17:06:21 UTC (rev 5722)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfiguration.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.producer.registration.config;
+
+import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public interface ProducerConfiguration
+{
+ ProducerRegistrationRequirements getRegistrationRequirements();
+}
Copied:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfigurationService.java
(from rev 5722,
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java)
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java 2006-11-27
17:06:21 UTC (rev 5722)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/ProducerConfigurationService.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.producer.registration.config;
+
+import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ProducerConfigurationService extends AbstractJBossService implements
ProducerConfiguration
+{
+ private ProducerRegistrationRequirements requirements;
+ private String configLocation;
+
+ public ProducerRegistrationRequirements getRegistrationRequirements()
+ {
+ return requirements;
+ }
+
+ public String getConfigLocation()
+ {
+ return configLocation;
+ }
+
+ public void setConfigLocation(String configLocation)
+ {
+ this.configLocation = configLocation;
+ }
+
+
+ protected void createService() throws Exception
+ {
+ // Setup URLs
+ if (configLocation == null)
+ {
+ throw new Exception("The config location is null");
+ }
+ URL configURL =
Thread.currentThread().getContextClassLoader().getResource(configLocation);
+ if (configURL == null)
+ {
+ throw new Exception("The config " + configLocation + " does not
exist");
+ }
+ if (!URLTools.exists(configURL))
+ {
+ throw new Exception("The config " + configURL + " does not
exist");
+ }
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ ObjectModelFactory factory = new RegistrationConfigurationFactory();
+ requirements =
(ProducerRegistrationRequirements)unmarshaller.unmarshal(configURL.openStream(), factory,
null);
+ }
+}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfiguration.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -1,36 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.producer.registration.config;
-
-import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public interface RegistrationConfiguration
-{
- ProducerRegistrationRequirements getRegistrationRequirements();
-}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/config/RegistrationConfigurationService.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -1,82 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.wsrp.producer.registration.config;
-
-import org.jboss.portal.common.util.URLTools;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-
-import java.net.URL;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class RegistrationConfigurationService extends AbstractJBossService implements
RegistrationConfiguration
-{
- private ProducerRegistrationRequirements requirements;
- private String configLocation;
-
- public ProducerRegistrationRequirements getRegistrationRequirements()
- {
- return requirements;
- }
-
- public String getConfigLocation()
- {
- return configLocation;
- }
-
- public void setConfigLocation(String configLocation)
- {
- this.configLocation = configLocation;
- }
-
-
- protected void createService() throws Exception
- {
- // Setup URLs
- if (configLocation == null)
- {
- throw new Exception("The config location is null");
- }
- URL configURL =
Thread.currentThread().getContextClassLoader().getResource(configLocation);
- if (configURL == null)
- {
- throw new Exception("The config " + configLocation + " does not
exist");
- }
- if (!URLTools.exists(configURL))
- {
- throw new Exception("The config " + configURL + " does not
exist");
- }
-
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- ObjectModelFactory factory = new RegistrationConfigurationFactory();
- requirements =
(ProducerRegistrationRequirements)unmarshaller.unmarshal(configURL.openStream(), factory,
null);
- }
-}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -30,7 +30,10 @@
import javax.xml.namespace.QName;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -41,6 +44,7 @@
{
private boolean requiresRegistration;
private boolean fullServiceDescriptionRequiresRegistration;
+ private transient Set listeners = new HashSet(3);
/** property name (QName) -> PropertyDescription */
private Map registrationProperties;
@@ -85,19 +89,26 @@
public void addRegistrationProperty(RegistrationPropertyDescription
propertyDescription)
{
ParameterValidation.throwIllegalArgExceptionIfNull(propertyDescription,
"PropertyDescription");
- registrationProperties.put(propertyDescription.getName(), propertyDescription);
+ QName name = propertyDescription.getName();
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "Property
name");
+
+ registrationProperties.put(name, propertyDescription);
+ propertyDescription.setParent(this);
+ notifyRegistrationPropertyChangeListeners();
}
- public boolean acceptValueFor(Object value, QName propertyName)
+ public boolean acceptValueFor(QName propertyName, Object value)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
+
QName type = getPropertyDescription(propertyName).getType();
// todo: decide if type is actually compatible with value...
return true;
}
- public boolean acceptValueFor(Object value, String propertyName)
+ public boolean acceptValueFor(String propertyName, Object value)
{
- return acceptValueFor(value, new QName(propertyName));
+ return acceptValueFor(new QName(propertyName), value);
}
public RegistrationPropertyDescription getRegistrationPropertyWith(String name)
@@ -115,22 +126,51 @@
private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
{
- return (RegistrationPropertyDescription)registrationProperties.get(propertyName);
+ // copy to ensure immutability
+ return new
RegistrationPropertyDescription((RegistrationPropertyDescription)registrationProperties.get(propertyName));
}
public void removeRegistrationProperty(QName propertyName)
{
ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property
name");
registrationProperties.remove(propertyName);
+ notifyRegistrationPropertyChangeListeners();
}
public void clearRegistrationProperties()
{
registrationProperties.clear();
+ notifyRegistrationPropertyChangeListeners();
}
public void removeRegistrationProperty(String propertyName)
{
removeRegistrationProperty(new QName(propertyName));
}
+
+ public void notifyRegistrationPropertyChangeListeners()
+ {
+ for (Iterator iterator = listeners.iterator(); iterator.hasNext();)
+ {
+ RegistrationPropertyChangeListener listener =
(RegistrationPropertyChangeListener)iterator.next();
+ listener.propertiesHaveChanged();
+ }
+ }
+
+ public void clearRegistrationPropertyChangeListeners()
+ {
+ listeners.clear();
+ }
+
+ public void addRegistrationPropertyChangeListeners(RegistrationPropertyChangeListener
listener)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"RegistrationPropertyChangeListener");
+ listeners.add(listener);
+ }
+
+ public void
removeRegistrationPropertyChangeListener(RegistrationPropertyChangeListener listener)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"RegistrationPropertyChangeListener");
+ listeners.remove(listener);
+ }
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-28
01:46:21 UTC (rev 5729)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-28
05:41:09 UTC (rev 5730)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer.registration.impl;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
@@ -50,6 +51,8 @@
*/
public class RegistrationManagerImpl extends AbstractJBossService implements
RegistrationManager
{
+ private static final Logger log = Logger.getLogger(RegistrationManager.class);
+
private RegistrationPolicy policy;
private RegistrationPersistenceManager persistenceManager;
private Map registrations;
@@ -113,7 +116,7 @@
registration.setRegistrationHandle(handle);
// associate the handle to the consumer for easy retrieval
- registrations.put(handle, new ConsumerRegistration(registration, consumer));
+ registrations.put(handle, registration);
return registration;
}
@@ -283,15 +286,15 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
// this particular implementations uses a map though it could delegate to the
registry and make a DB query to retrieve the info
- ConsumerRegistration cr =
(ConsumerRegistration)registrations.get(registrationHandle);
+ Registration registration = (Registration)registrations.get(registrationHandle);
- if (cr != null)
+ if (registration == null)
{
- return (getConsumer ? (Object)cr.consumer : cr.registration);
+ return null;
}
else
{
- return null;
+ return getConsumer ? (Object)registration.getConsumer() : registration;
}
}
@@ -338,16 +341,19 @@
}
}
- private static class ConsumerRegistration
+ /**
+ * We listened 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...
+ */
+ public void propertiesHaveChanged()
{
- private Registration registration;
- private Consumer consumer;
-
-
- public ConsumerRegistration(Registration registration, Consumer consumer)
+ log.debug("Registration properties have changed, existing registrations will
be invalidated...");
+ for (Iterator regs = registrations.values().iterator(); regs.hasNext();)
{
- this.registration = registration;
- this.consumer = consumer;
+ Registration reg = (Registration)regs.next();
+ reg.setStatus(RegistrationStatus.INVALID);
+ reg.clearAssociatedState(); //todo: or should we wait until current operations
are done?
}
}
+
}
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-28
01:46:21 UTC (rev 5729)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-28
05:41:09 UTC (rev 5730)
@@ -79,7 +79,7 @@
<xmbean/>
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=WSRPProducer</depends>
- <depends optional-attribute-name="RegistrationConfiguration"
proxy-type="attribute">portal.wsrp:service=RegistrationConfiguration</depends>
+ <depends optional-attribute-name="ProducerConfiguration"
proxy-type="attribute">portal.wsrp:service=ProducerConfiguration</depends>
<depends optional-attribute-name="RegistrationManager"
proxy-type="attribute">portal.wsrp:service=RegistrationManager</depends>
</mbean>
@@ -107,8 +107,8 @@
</mbean>
<!-- Registration configuration service -->
- <mbean
code="org.jboss.portal.wsrp.producer.registration.config.RegistrationConfigurationService"
- name="portal.wsrp:service=RegistrationConfiguration"
xmbean-dd=""
+ <mbean
code="org.jboss.portal.wsrp.producer.registration.config.ProducerConfigurationService"
+ name="portal.wsrp:service=ProducerConfiguration"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="ConfigLocation">conf/config.xml</attribute>