Author: chris.laprun(a)jboss.com
Date: 2007-05-03 17:09:53 -0400 (Thu, 03 May 2007)
New Revision: 7186
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
Log:
- Added isRefreshNeeded on ProducerInfo, use it and related test cases.
- Added dirty concept on RegistrationInfo and ability to force a refresh.
- RegistrationProperties now have a status string and prefixed persistent fields.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-03
16:49:07 UTC (rev 7185)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-03
21:09:53 UTC (rev 7186)
@@ -72,21 +72,35 @@
assertNull(info.getExpirationCacheSeconds());
+ assertTrue(info.isRefreshNeeded(false));
+ assertFalse(info.isRegistrationChecked());
assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
assertEquals(2, behavior.getCallCount());
info.setExpirationCacheSeconds(new Integer(1));
assertEquals(new Integer(1), info.getExpirationCacheSeconds());
assertTrue(info.refresh(false));
assertFalse(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
assertEquals(3, behavior.getCallCount());
// wait for cache expiration
Thread.sleep(1500);
+ assertFalse("refresh is not needed if cache is not considered",
info.isRefreshNeeded(false));
+ assertTrue("refresh is needed if cache is not considered since it has
expired", info.isRefreshNeeded(true));
assertTrue(info.refresh(false));
+ assertFalse("Was just refreshed so refresh is not needed even considering
cache", info.isRefreshNeeded(true));
+ assertTrue(info.isRegistrationChecked());
assertFalse(info.refresh(false));
assertTrue(info.refresh(true));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
assertEquals(5, behavior.getCallCount());
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-03
16:49:07 UTC (rev 7185)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-03
21:09:53 UTC (rev 7186)
@@ -78,18 +78,23 @@
{
// before refresh registration status is undetermined
assertNull(info.isRegistrationRequired());
+ assertFalse(info.isRegistrationValid());
ServiceDescription sd = createServiceDescription(false, 0);
- RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(sd, producerId, true);
+ RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(sd, producerId, true, false);
assertNotNull(result);
assertTrue(result.isValid());
assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
assertTrue(info.isRegistrationValid());
- result = info.refreshRegistrationRequirementsFor(sd, producerId, false);
+ result = info.refreshRegistrationRequirementsFor(sd, producerId, false, false);
assertNotNull(result);
assertTrue(result.isValid());
assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
assertTrue(info.isRegistrationValid());
}
@@ -97,12 +102,15 @@
{
// before refresh registration status is undetermined
assertNull(info.isRegistrationRequired());
+ assertFalse(info.isRegistrationValid());
RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(
- createServiceDescription(true, 0), producerId, true);
+ createServiceDescription(true, 0), producerId, true, false);
assertNotNull(result);
assertTrue(result.isValid());
assertTrue(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
assertFalse(info.isRegistrationValid());
}
@@ -112,7 +120,7 @@
info.setRegistrationPropertyValue("foo", "bar");
RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(
- createServiceDescription(true, 0), producerId, false);
+ createServiceDescription(true, 0), producerId, false, false);
assertNotNull(result);
assertFalse(result.isValid());
String status = result.getStatus();
@@ -126,6 +134,7 @@
assertNotNull(prop);
assertEquals("bar", prop.getValue());
assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
}
public void testRefreshRegistrationRegistrationNoLocalInfo()
@@ -133,31 +142,77 @@
// producer requests 2 registration properties
ServiceDescription sd = createServiceDescription(true, 2);
- RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(sd, producerId, false);
+ RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(sd, producerId, false, false);
assertNotNull(result);
assertFalse(result.isValid());
String status = result.getStatus();
assertNotNull(status);
assertTrue(status.indexOf("prop0") != -1 &&
status.indexOf("prop1") != -1);
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
}
- public void testRefreshRegistrationRegistrationEraseLocalInfo()
+ public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
{
+ info.setRegistrationPropertyValue("foo", "bar");
+
RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(createServiceDescription(true, 2),
- producerId, true);
+ producerId, true, false);
assertNotNull(result);
assertFalse(result.isValid());
+
RegistrationProperty prop = info.getRegistrationProperty("prop0");
assertNotNull(prop);
assertNull(prop.getValue());
assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
+
prop = info.getRegistrationProperty("prop1");
assertNotNull(prop);
assertNull(prop.getValue());
assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
assertEquals(2, info.getRegistrationProperties().size());
+
+ assertNull(info.getRegistrationProperty("foo"));
}
+ public void testForceRefreshRegistration()
+ {
+ RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(
+ createServiceDescription(true, 0), producerId, false, false);
+ assertNotNull(result);
+ assertTrue(result.isValid());
+ assertFalse(info.isRegistrationValid());
+
+ // Modifying a property renders the info dirty and hence should be refreshed
+ info.setRegistrationPropertyValue("foo", "bar");
+ result = info.refreshRegistrationRequirementsFor(createServiceDescription(true, 0),
producerId, false, false);
+ assertFalse(result.isValid());
+ assertFalse(info.isRegistrationValid());
+
+ info.removeRegistrationProperty("foo");
+ result = info.refreshRegistrationRequirementsFor(createServiceDescription(true, 0),
producerId, false, false);
+ assertTrue(result.isValid());
+ assertFalse(info.isRegistrationValid());
+
+ // producer has changed but we're not forcing refresh so registration should
still be invalid
+ result = info.refreshRegistrationRequirementsFor(createServiceDescription(false,
0), producerId, false, false);
+ assertTrue(result.isValid());
+ assertFalse(info.isRegistrationValid());
+
+ // force refresh
+ result = info.refreshRegistrationRequirementsFor(createServiceDescription(false,
0), producerId, false, true);
+ assertTrue(result.isValid());
+ assertTrue(info.isRegistrationValid());
+ }
+
private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
{
ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-03
16:49:07 UTC (rev 7185)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-03
21:09:53 UTC (rev 7186)
@@ -169,14 +169,17 @@
public boolean isRegistrationRequired()
{
return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationDeterminedRequired();
+ }
+ public boolean isRegistrationChecked()
+ {
+ return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationRequired() != null;
}
/**
* Determines whether the associated consumer is active.
*
* @return
- * @since 2.6
*/
public boolean isActive()
{
@@ -188,7 +191,6 @@
* handle activation.
*
* @param active
- * @since 2.6
*/
public void setActive(boolean active)
{
@@ -231,9 +233,10 @@
ServiceDescription serviceDescription;
// might neeed a different cache value: right now, we cache the whole producer info
but we might want to cache
// POPs and rest of producer info separetely...
- if (forceRefresh || isCacheExpired())
+ if (forceRefresh || isRefreshNeeded(true))
{
log.debug("ProducerInfo refresh needed for producer '" +
persistentId + "'");
+ persistentEndpointInfo.refresh();
serviceDescription = getServiceDescription(false);
// do we need to call initCookie or not?
@@ -256,7 +259,7 @@
else
{
log.debug("Registration not required");
-// setRegistrationInfo(registry.getDefaultRegistrationInfo());
+ persistentRegistrationInfo = new RegistrationInfo(this, false);
setServiceDescriptionRequest(getUnregisteredServiceDescriptionRequest());
extractOfferedPortlets(serviceDescription);
return true;
@@ -679,29 +682,25 @@
}
- public RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException
+ public RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
mergeWithLocalInfo) throws PortletInvokerException
{
if (persistentRegistrationInfo == null)
{
persistentRegistrationInfo = new RegistrationInfo(this);
}
- // if we want to erase the local data, we need to deregister
- if (eraseLocalData)
- {
- deregister();
- }
-
RegistrationInfo.RegistrationRefreshResult result =
-
persistentRegistrationInfo.refreshRegistrationRequirementsFor(getServiceDescription(true),
persistentId, eraseLocalData);
+
persistentRegistrationInfo.refreshRegistrationRequirementsFor(getServiceDescription(true),
persistentId, mergeWithLocalInfo, true);
registry.updateProducerInfo(this);
log.info("Refreshed registration information for consumer with id '"
+ persistentId + "'");
return result;
}
- /*public boolean isRefreshNeeded()
+ public boolean isRefreshNeeded(boolean considerCache)
{
- return persistentEndpointInfo.isRefreshNeeded();
- }*/
+ return (considerCache && isCacheExpired())
+ || (persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRefreshNeeded())
+ || persistentEndpointInfo.isRefreshNeeded();
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-03
16:49:07 UTC (rev 7185)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-03
21:09:53 UTC (rev 7186)
@@ -65,6 +65,7 @@
private transient Boolean requiresRegistration;
private transient RegistrationData registrationData;
+ private boolean dirty;
public RegistrationInfo(ProducerInfo producerInfo)
{
@@ -73,6 +74,12 @@
producerInfo.setRegistrationInfo(this);
}
+ public RegistrationInfo(ProducerInfo producerInfo, boolean requiresRegistration)
+ {
+ this(producerInfo);
+ this.requiresRegistration = Boolean.valueOf(requiresRegistration);
+ }
+
public RegistrationInfo()
{
persistentConsumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
@@ -96,7 +103,7 @@
public void setRegistrationHandle(String registrationHandle)
{
- this.persistentRegistrationHandle = registrationHandle;
+ this.persistentRegistrationHandle =
modifyIfNeeded(this.persistentRegistrationHandle, registrationHandle);
}
public byte[] getRegistrationState()
@@ -109,11 +116,6 @@
this.persistentRegistrationState = registrationState;
}
- public void setRequiresRegistration(Boolean requiresRegistration)
- {
- this.requiresRegistration = requiresRegistration;
- }
-
/**
* Determines whether the associated Producer requires registration.
*
@@ -206,6 +208,7 @@
RegistrationProperty prop =
(RegistrationProperty)getOrCreateRegistrationPropertiesMap(true).get(name);
if (prop != null)
{
+ value = modifyIfNeeded(prop.getValue(), value);
prop.setValue(value);
}
else
@@ -213,6 +216,7 @@
// todo: deal with language more appropriately
prop = new RegistrationProperty(name, value,
LocaleInfo.getRFC3066LanguageTagFor(Locale.getDefault()));
getOrCreateRegistrationPropertiesMap(false).put(name, prop);
+ dirty = true;
}
return prop;
@@ -226,6 +230,7 @@
{
throw new IllegalArgumentException("Cannot remove inexistent registration
property '" + name + "'");
}
+ dirty = true;
}
private Map getOrCreateRegistrationPropertiesMap(boolean forceCreate)
@@ -270,108 +275,120 @@
*/
boolean initialize(ServiceDescription serviceDescription, String producerId)
{
- return refreshRegistrationRequirementsFor(serviceDescription, producerId,
false).isValid();
+ return refreshRegistrationRequirementsFor(serviceDescription, producerId, false,
false).isValid();
}
/**
* @param serviceDescription
* @param producerId
- * @param discardLocalInfo
+ * @param mergeWithLocalInfo
+ * @param forceRefresh
* @return
*/
- public RegistrationRefreshResult refreshRegistrationRequirementsFor(ServiceDescription
serviceDescription, String producerId, boolean discardLocalInfo)
+ public RegistrationRefreshResult refreshRegistrationRequirementsFor(ServiceDescription
serviceDescription,
+ String producerId,
boolean mergeWithLocalInfo,
+ boolean
forceRefresh)
{
- log.debug("RegistrationInfo initialization requested");
- RegistrationRefreshResult result = new RegistrationRefreshResult();
+ log.debug("RegistrationInfo refresh requested");
- if (serviceDescription.isRequiresRegistration())
+ if (forceRefresh || isRefreshNeeded())
{
- requiresRegistration = Boolean.TRUE;
- StringBuffer message = new StringBuffer("Producer
'").append(producerId).append("' requires registration.");
- result.appendToStatus(message.toString());
- log.debug(message);
+ RegistrationRefreshResult result = new RegistrationRefreshResult();
+ dirty = false;
- // check if the configured registration properties match the producer
expectations
- ModelDescription regPropDescs =
serviceDescription.getRegistrationPropertyDescription();
- if (regPropDescs != null)
+ if (serviceDescription.isRequiresRegistration())
{
- result.setValid(true);
- PropertyDescription[] propertyDescriptions =
regPropDescs.getPropertyDescriptions();
- if (propertyDescriptions != null && propertyDescriptions.length >
0)
+ requiresRegistration = Boolean.TRUE;
+ StringBuffer message = new StringBuffer("Producer
'").append(producerId).append("' requires registration.");
+ result.appendToStatus(message.toString());
+ log.debug(message);
+
+ // check if the configured registration properties match the producer
expectations
+ ModelDescription regPropDescs =
serviceDescription.getRegistrationPropertyDescription();
+ if (regPropDescs != null)
{
- Map descriptionsMap =
getRegistrationPropertyDescriptionsFromWSRP(propertyDescriptions);
-
- if (discardLocalInfo)
+ result.setValid(true);
+ PropertyDescription[] propertyDescriptions =
regPropDescs.getPropertyDescriptions();
+ if (propertyDescriptions != null && propertyDescriptions.length
> 0)
{
- persistentRegistrationProperties =
getOrCreateRegistrationPropertiesMap(true);
+ Map descriptionsMap =
getRegistrationPropertyDescriptionsFromWSRP(propertyDescriptions);
- // Remove extra properties
- Set unexpected = new
HashSet(persistentRegistrationProperties.keySet());
- unexpected.removeAll(descriptionsMap.keySet());
- if (!unexpected.isEmpty())
+ if (mergeWithLocalInfo)
{
- for (Iterator invalidProps = unexpected.iterator();
invalidProps.hasNext();)
+ persistentRegistrationProperties =
getOrCreateRegistrationPropertiesMap(true);
+
+ // Remove extra properties
+ Set unexpected = new
HashSet(persistentRegistrationProperties.keySet());
+ unexpected.removeAll(descriptionsMap.keySet());
+ if (!unexpected.isEmpty())
{
- persistentRegistrationProperties.remove(invalidProps.next());
+ for (Iterator invalidProps = unexpected.iterator();
invalidProps.hasNext();)
+ {
+ persistentRegistrationProperties.remove(invalidProps.next());
+ }
}
- }
- // Resets existing properties
- for (Iterator props = descriptionsMap.values().iterator();
props.hasNext();)
- {
- RegistrationProperty prop = (RegistrationProperty)props.next();
- String name = prop.getName();
- RegistrationProperty existing = getRegistrationProperty(name);
- if (existing != null)
+ // Merge existing properties
+ for (Iterator props = descriptionsMap.values().iterator();
props.hasNext();)
{
- existing.setValue(null);
- existing.setDescription(prop.getDescription());
+ RegistrationProperty prop = (RegistrationProperty)props.next();
+ String name = prop.getName();
+ RegistrationProperty existing = getRegistrationProperty(name);
+ if (existing != null)
+ {
+ existing.setDescription(prop.getDescription());
+ }
+ else
+ {
+ persistentRegistrationProperties.put(name, prop);
+ }
}
- else
- {
- persistentRegistrationProperties.put(name, prop);
- }
+
+ resetRegistration();
+ result.setValid(false);
}
+ else
+ {
+ persistentRegistrationProperties =
getOrCreateRegistrationPropertiesMap(true);
- resetRegistration();
- result.setValid(false);
- }
- else
- {
- persistentRegistrationProperties =
getOrCreateRegistrationPropertiesMap(true);
+ // check that we don't have unexpected registration properties
and if so, mark them as invalid
+ Set expectedNames = descriptionsMap.keySet();
+ checkForExtraProperties(producerId, result, expectedNames,
persistentRegistrationProperties);
- // check that we don't have unexpected registration properties and
if so, mark them as invalid
- Set expectedNames = descriptionsMap.keySet();
- checkForExtraProperties(producerId, result, expectedNames,
persistentRegistrationProperties);
-
- // now check for missing properties, add the missing ones with a null
value
- StringBuffer missingProps = new StringBuffer();
- for (Iterator descriptionNames = expectedNames.iterator();
descriptionNames.hasNext();)
- {
- String name = (String)descriptionNames.next();
- RegistrationProperty prop =
(RegistrationProperty)persistentRegistrationProperties.get(name);
- RegistrationProperty producerProp =
(RegistrationProperty)descriptionsMap.get(name);
- if (prop == null)
+ // now check for missing properties, add the missing ones with a
null value
+ StringBuffer missingProps = new StringBuffer();
+ for (Iterator descriptionNames = expectedNames.iterator();
descriptionNames.hasNext();)
{
- persistentRegistrationProperties.put(name, producerProp);
- missingProps.append("Missing value for property
'").append(name).append("'\n");
+ String name = (String)descriptionNames.next();
+ RegistrationProperty prop =
(RegistrationProperty)persistentRegistrationProperties.get(name);
+ RegistrationProperty producerProp =
(RegistrationProperty)descriptionsMap.get(name);
+ if (prop == null)
+ {
+ producerProp.setStatus(RegistrationProperty.MISSING_STATUS);
+ persistentRegistrationProperties.put(name, producerProp);
+ missingProps.append("Missing value for property
'").append(name).append("'\n");
+ }
+ else
+ {
+ // take the opportunity to add the property description...
^_^
+ prop.setDescription(producerProp.getDescription());
+ }
}
- else
+
+ if (missingProps.length() > 0)
{
- // take the opportunity to add the property description... ^_^
- prop.setDescription(producerProp.getDescription());
+ log.debug(missingProps);
+ result.appendToStatus(missingProps.toString());
+ resetRegistration();
+ result.setValid(false);
}
}
-
- if (missingProps.length() > 0)
- {
- log.debug(missingProps);
- result.appendToStatus(missingProps.toString());
- resetRegistration();
- result.setValid(false);
- }
}
+ else
+ {
+ handleNoRequiredRegistrationProperties(producerId, result);
+ }
}
else
{
@@ -380,23 +397,26 @@
}
else
{
- handleNoRequiredRegistrationProperties(producerId, result);
+ String msg = "Producer '" + producerId + "'
doesn't require registration.";
+ log.debug(msg);
+ result.appendToStatus(msg);
+ requiresRegistration = Boolean.FALSE;
+ result.setValid(true);
}
+
+ result.setRegistrationProperties(persistentRegistrationProperties);
+ String msg = "Registration configuration is " + (result.isValid() ?
"" : "NOT") + " valid";
+ result.appendToStatus(msg);
+ log.debug(msg);
+ return result;
}
else
{
- String msg = "Producer '" + producerId + "' doesn't
require registration.";
- log.debug(msg);
- result.appendToStatus(msg);
- requiresRegistration = Boolean.FALSE;
- result.setValid(true);
+ RegistrationRefreshResult result = new RegistrationRefreshResult();
+ result.valid = true;
+ result.registrationProperties = persistentRegistrationProperties;
+ return result;
}
-
- result.setRegistrationProperties(persistentRegistrationProperties);
- String msg = "Registration configuration is " + (result.isValid() ?
"" : "NOT") + " valid";
- result.appendToStatus(msg);
- log.debug(msg);
- return result;
}
private void handleNoRequiredRegistrationProperties(String producerId,
RegistrationRefreshResult result)
@@ -437,7 +457,9 @@
{
String name = (String)invalidProps.next();
message.append("\t- ").append(name).append("\n");
- ((RegistrationProperty)properties.get(name)).setInvalid(true);
+ RegistrationProperty prop = (RegistrationProperty)properties.get(name);
+ prop.setInvalid(true);
+ prop.setStatus(RegistrationProperty.INEXISTENT_STATUS);
}
log.info(message);
result.appendToStatus(message.toString());
@@ -462,6 +484,7 @@
RegistrationPropertyDescription desc =
WSRPUtils.convertToRegistrationPropertyDescription(description);
RegistrationProperty prop = new RegistrationProperty(name, null,
LocaleInfo.getRFC3066LanguageTagFor(desc.getLang()));
prop.setDescription(desc);
+ prop.setStatus(RegistrationProperty.MISSING_VALUE_STATUS);
result.put(name, prop);
}
@@ -478,6 +501,7 @@
registrationData = null;
persistentRegistrationHandle = null;
persistentRegistrationState = null;
+ requiresRegistration = null;
}
public boolean isRegistrationValid()
@@ -509,6 +533,11 @@
}
}
+ public boolean isRefreshNeeded()
+ {
+ return dirty || requiresRegistration == null;
+ }
+
public class RegistrationRefreshResult
{
private Map registrationProperties;
@@ -558,9 +587,14 @@
}
}
- class RegistrationPropertyHolder
+ private String modifyIfNeeded(String oldValue, String newValue)
{
- RegistrationProperty property;
- String status;
+ if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null
&& newValue != null))
+ {
+ oldValue = newValue;
+ dirty = true;
+ }
+
+ return oldValue;
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-05-03
16:49:07 UTC (rev 7185)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationProperty.java 2007-05-03
21:09:53 UTC (rev 7186)
@@ -33,13 +33,17 @@
*/
public class RegistrationProperty
{
- private Long key;
- private RegistrationPropertyDescription description;
- private boolean invalid;
- private String lang;
- private String name;
- private String value;
+ private Long persistentId;
+ private RegistrationPropertyDescription persistentDescription;
+ private boolean persistentInvalid;
+ private String persistentLang;
+ private String persistentName;
+ private String persistentValue;
+ private transient String status;
+ public static final String INEXISTENT_STATUS = "Inexistent on Producer";
+ public static final String MISSING_STATUS = "Missing";
+ public static final String MISSING_VALUE_STATUS = "Missing value";
public RegistrationProperty()
{
@@ -49,13 +53,12 @@
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Name",
"RegistrationProperty");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "Lang",
"RegistrationProperty");
- this.name = name;
- this.value = stringValue;
- this.lang = lang;
- invalid = (stringValue == null);
+ this.persistentName = name;
+ this.persistentValue = stringValue;
+ this.persistentLang = lang;
+ persistentInvalid = (stringValue == null);
}
-
public boolean equals(Object o)
{
if (this == o)
@@ -69,27 +72,27 @@
RegistrationProperty that = (RegistrationProperty)o;
- if (!name.equals(that.name))
+ if (!persistentName.equals(that.persistentName))
{
return false;
}
- if (!lang.equals(that.lang))
+ if (!persistentLang.equals(that.persistentLang))
{
return false;
}
- if (invalid != that.invalid)
+ if (persistentInvalid != that.persistentInvalid)
{
return false;
}
- if (description != null ? !description.equals(that.description) : that.description
!= null)
+ if (persistentDescription != null ?
!persistentDescription.equals(that.persistentDescription) : that.persistentDescription !=
null)
{
return false;
}
- if (key != null ? !key.equals(that.key) : that.key != null)
+ if (persistentId != null ? !persistentId.equals(that.persistentId) :
that.persistentId != null)
{
return false;
}
- if (value != null ? !value.equals(that.value) : that.value != null)
+ if (persistentValue != null ? !persistentValue.equals(that.persistentValue) :
that.persistentValue != null)
{
return false;
}
@@ -100,78 +103,86 @@
public int hashCode()
{
int result;
- result = (key != null ? key.hashCode() : 0);
- result = 31 * result + name.hashCode();
- result = 31 * result + lang.hashCode();
- result = 31 * result + (description != null ? description.hashCode() : 0);
- result = 31 * result + (invalid ? 1 : 0);
- result = 31 * result + (value != null ? value.hashCode() : 0);
+ result = (persistentId != null ? persistentId.hashCode() : 0);
+ result = 31 * result + persistentName.hashCode();
+ result = 31 * result + persistentLang.hashCode();
+ result = 31 * result + (persistentDescription != null ?
persistentDescription.hashCode() : 0);
+ result = 31 * result + (persistentInvalid ? 1 : 0);
+ result = 31 * result + (persistentValue != null ? persistentValue.hashCode() : 0);
return result;
}
public Long getKey()
{
- return key;
+ return persistentId;
}
public void setKey(Long key)
{
- this.key = key;
+ this.persistentId = key;
}
public String getName()
{
- return name;
+ return persistentName;
}
public void setName(String name)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Name",
"RegistrationProperty");
- this.name = name;
+ this.persistentName = name;
}
public String getValue()
{
- return value;
+ return persistentValue;
}
public RegistrationPropertyDescription getDescription()
{
- return description;
+ return persistentDescription;
}
public void setDescription(RegistrationPropertyDescription description)
{
- this.description = description;
+ this.persistentDescription = description;
}
public boolean isInvalid()
{
- return invalid;
+ return persistentInvalid;
}
public void setInvalid(boolean invalid)
{
- this.invalid = invalid;
+ this.persistentInvalid = invalid;
}
public void setValue(String stringValue)
{
- value = stringValue;
- if (value == null)
- {
- invalid = true;
- }
+ persistentValue = stringValue;
+ persistentInvalid = (persistentValue == null);
+ status = (persistentValue == null ? MISSING_VALUE_STATUS : null);
}
public String getLang()
{
- return lang;
+ return persistentLang;
}
public void setLang(String lang)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "Lang",
"RegistrationProperty");
- this.lang = lang;
+ this.persistentLang = lang;
}
+
+ public String getStatus()
+ {
+ return status;
+ }
+
+ public void setStatus(String status)
+ {
+ this.status = status;
+ }
}