Author: chris.laprun(a)jboss.com
Date: 2007-05-02 14:42:13 -0400 (Wed, 02 May 2007)
New Revision: 7176
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.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/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
Log:
- Improved handling of registration status.
- Renamed fields in RegistrationInfo to clearly show which ones are persistent.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-05-02
13:07:29 UTC (rev 7175)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2007-05-02
18:42:13 UTC (rev 7176)
@@ -111,7 +111,7 @@
assertEquals("http://wsrp.bea.com:7001/producer/producer?WSDL",
endInfo.getWsdlDefinitionURL());
RegistrationInfo regInfo = info.getRegistrationInfo();
assertNotNull(regInfo);
- assertTrue(regInfo.isRequiresRegistration());
+ assertNull(regInfo.isRegistrationRequired());
RegistrationData registrationData = regInfo.getRegistrationData();
assertNotNull(registrationData);
assertEquals("JBoss Portal 2.4 Test",
registrationData.getConsumerName());
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-02
13:07:29 UTC (rev 7175)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-02
18:42:13 UTC (rev 7176)
@@ -76,27 +76,33 @@
public void testRefreshNoRegistration()
{
+ // before refresh registration status is undetermined
+ assertNull(info.isRegistrationRequired());
+
ServiceDescription sd = createServiceDescription(false, 0);
RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(sd, producerId, true);
assertNotNull(result);
assertTrue(result.isValid());
- assertFalse(info.isRequiresRegistration());
+ assertFalse(info.isRegistrationRequired().booleanValue());
assertTrue(info.isRegistrationValid());
result = info.refreshRegistrationRequirementsFor(sd, producerId, false);
assertNotNull(result);
assertTrue(result.isValid());
- assertFalse(info.isRequiresRegistration());
+ assertFalse(info.isRegistrationRequired().booleanValue());
assertTrue(info.isRegistrationValid());
}
public void testRefreshRegistrationDefaultRegistrationNoLocalInfo()
{
+ // before refresh registration status is undetermined
+ assertNull(info.isRegistrationRequired());
+
RegistrationInfo.RegistrationRefreshResult result =
info.refreshRegistrationRequirementsFor(
createServiceDescription(true, 0), producerId, true);
assertNotNull(result);
assertTrue(result.isValid());
- assertTrue(info.isRequiresRegistration());
+ assertTrue(info.isRegistrationRequired().booleanValue());
assertFalse(info.isRegistrationValid());
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-02
13:07:29 UTC (rev 7175)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-02
18:42:13 UTC (rev 7176)
@@ -70,6 +70,7 @@
private final static int PM = 2;
private final static int R = 3;
+ // todo: public for tests
public EndpointConfigurationInfo()
{
}
@@ -190,7 +191,7 @@
this.wsdlDefinitionURL = wsdlDefinitionURL;
// WSDL url is optional so can be null (and in particular, it is when loaded from
Hibernate most of the time)
- if (wsdlDefinitionURL != null && serviceFactory != null)
+ if (wsdlDefinitionURL != null)
{
if (!(serviceFactory instanceof RemoteSOAPInvokerServiceFactory))
{
@@ -262,17 +263,14 @@
getServiceFactory().stop();
}
+ // todo: public for tests
public ServiceFactory getServiceFactory()
{
initServiceFactoryIfNeeded();
return serviceFactory;
}
- /**
- * Only public for tests...
- *
- * @param serviceFactory
- */
+ // todo: public for tests
public void setServiceFactory(ServiceFactory serviceFactory)
{
ParameterValidation.throwIllegalArgExceptionIfNull(serviceFactory,
"ServiceFactory");
@@ -290,21 +288,25 @@
}
+ // todo: public for tests
public WSRP_v1_ServiceDescription_PortType getServiceDescriptionService() throws
InvokerUnavailableException
{
return (WSRP_v1_ServiceDescription_PortType)getService(SERVICE_DESCRIPTION,
WSRP_v1_ServiceDescription_PortType.class);
}
+ // todo: public for tests
public WSRP_v1_Markup_PortType getMarkupService() throws InvokerUnavailableException
{
return (WSRP_v1_Markup_PortType)getService(MARKUP, WSRP_v1_Markup_PortType.class);
}
+ // todo: public for tests
public WSRP_v1_PortletManagement_PortType getPortletManagementService() throws
InvokerUnavailableException
{
return (WSRP_v1_PortletManagement_PortType)getService(PORTLET_MANAGEMENT,
WSRP_v1_PortletManagement_PortType.class);
}
+ // todo: public for tests
public WSRP_v1_Registration_PortType getRegistrationService() throws
InvokerUnavailableException
{
return (WSRP_v1_Registration_PortType)getService(REGISTRATION,
WSRP_v1_Registration_PortType.class);
@@ -356,7 +358,7 @@
public boolean isRefreshNeeded()
{
- return areURLsDirty() || !isAvailable();
+ return !isAvailable() || areURLsDirty();
}
private boolean areURLsDirty()
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-02
13:07:29 UTC (rev 7175)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-02
18:42:13 UTC (rev 7176)
@@ -163,12 +163,12 @@
public boolean isRegistered()
{
- return isRegistrationRequired() &&
persistentRegistrationInfo.isRegistrationValid();
+ return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationValid();
}
public boolean isRegistrationRequired()
{
- return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRequiresRegistration();
+ return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationDeterminedRequired();
}
@@ -611,7 +611,7 @@
persistentRegistrationInfo = new RegistrationInfo(this);
}
- if (!persistentRegistrationInfo.isRegistrationValid())
+ if (!isRegistered())
{
if (serviceDescription == null)
@@ -662,7 +662,7 @@
public void deregister() throws PortletInvokerException
{
- if (persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationValid())
+ if (isRegistered())
{
try
{
@@ -699,4 +699,9 @@
return result;
}
+
+ /*public boolean isRefreshNeeded()
+ {
+ return 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-02
13:07:29 UTC (rev 7175)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-02
18:42:13 UTC (rev 7176)
@@ -57,27 +57,25 @@
private final Logger log = Logger.getLogger(getClass());
private Long key;
- private String consumerName;
- private String registrationHandle;
- private byte[] registrationState;
- private boolean requiresRegistration; // todo: remove
- private Map registrationProperties;
+ private String persistentConsumerName;
+ private String persistentRegistrationHandle;
+ private byte[] persistentRegistrationState;
+ private Map persistentRegistrationProperties;
+ private transient Boolean requiresRegistration;
+
private transient RegistrationData registrationData;
- private transient ProducerInfo parent;
public RegistrationInfo(ProducerInfo producerInfo)
{
this();
ParameterValidation.throwIllegalArgExceptionIfNull(producerInfo,
"ProducerInfo");
producerInfo.setRegistrationInfo(this);
- parent = producerInfo;
}
public RegistrationInfo()
{
- consumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
- requiresRegistration = true;
+ persistentConsumerName = WSRPConstants.DEFAULT_CONSUMER_NAME;
}
@@ -93,40 +91,71 @@
public String getRegistrationHandle()
{
- return registrationHandle;
+ return persistentRegistrationHandle;
}
public void setRegistrationHandle(String registrationHandle)
{
- this.registrationHandle = registrationHandle;
+ this.persistentRegistrationHandle = registrationHandle;
}
public byte[] getRegistrationState()
{
- return registrationState;
+ return persistentRegistrationState;
}
public void setRegistrationState(byte[] registrationState)
{
- this.registrationState = registrationState;
+ this.persistentRegistrationState = registrationState;
}
- public void setRequiresRegistration(boolean requiresRegistration)
+ public void setRequiresRegistration(Boolean requiresRegistration)
{
this.requiresRegistration = requiresRegistration;
}
- public boolean isRequiresRegistration()
+ /**
+ * Determines whether the associated Producer requires registration.
+ *
+ * @return <code>null</code> if this RegistrationInfo hasn't queried
the Producer yet and thus, doesn't have a
+ * definitive answer on whether or not the associated Producer requires
registration,
+ * <code>Boolean.TRUE</code> if the associated Producer requires
registration, <code>Boolean.FALSE</code>
+ * otherwise.
+ */
+ public Boolean isRegistrationRequired()
{
return requiresRegistration;
}
+ /**
+ * Determines whether it has been determined after querying the associated Producer
that it requires registration.
+ *
+ * @return <code>true</code> if and only if the associated Producer has
been queried and mandates registration,
+ * <code>false</code> otherwise.
+ */
+ public boolean isRegistrationDeterminedRequired()
+ {
+ return requiresRegistration != null &&
requiresRegistration.booleanValue();
+ }
+
+ /**
+ * Determines whether it has been determined after querying the associated Producer
that it does <strong>NOT</strong>
+ * require registration.
+ *
+ * @return <code>true</code> if and only if the associated Producer has
been queried and does NOT mandate
+ * registration, <code>false</code> otherwise.
+ */
+ public boolean isRegistrationDeterminedNotRequired()
+ {
+ return requiresRegistration != null &&
!requiresRegistration.booleanValue();
+ }
+
public RegistrationData getRegistrationData()
{
if (registrationData == null)
{
registrationData = WSRPTypeFactory.createDefaultRegistrationData();
- registrationData.setConsumerName(consumerName);
+ registrationData.setConsumerName(persistentConsumerName);
List properties = new ArrayList();
Map regProps = getRegistrationProperties();
if (!regProps.isEmpty())
@@ -150,12 +179,12 @@
public String getConsumerName()
{
- return consumerName;
+ return persistentConsumerName;
}
public void setConsumerName(String consumerName)
{
- this.consumerName = consumerName;
+ this.persistentConsumerName = consumerName;
}
public String getConsumerAgent()
@@ -202,12 +231,12 @@
private Map getOrCreateRegistrationPropertiesMap(boolean forceCreate)
{
// todo: get from registration
- if (forceCreate && registrationProperties == null)
+ if (forceCreate && persistentRegistrationProperties == null)
{
- registrationProperties = new HashMap();
+ persistentRegistrationProperties = new HashMap();
}
- return registrationProperties;
+ return persistentRegistrationProperties;
}
public Map getRegistrationProperties()
@@ -225,7 +254,7 @@
public void setRegistrationProperties(Map registrationProperties)
{
- this.registrationProperties = registrationProperties;
+ this.persistentRegistrationProperties = registrationProperties;
}
public Set getRegistrationPropertyNames()
@@ -238,7 +267,6 @@
* @param producerId
* @return <code>true</code> if the associated producer is ready to be
interacted with as far as registration is
* concerned, <code>false</code> otherwise.
- * @since 2.6
*/
boolean initialize(ServiceDescription serviceDescription, String producerId)
{
@@ -251,7 +279,6 @@
* @param producerId
* @param discardLocalInfo
* @return
- * @since 2.6
*/
public RegistrationRefreshResult refreshRegistrationRequirementsFor(ServiceDescription
serviceDescription, String producerId, boolean discardLocalInfo)
{
@@ -260,7 +287,7 @@
if (serviceDescription.isRequiresRegistration())
{
- requiresRegistration = true;
+ requiresRegistration = Boolean.TRUE;
StringBuffer message = new StringBuffer("Producer
'").append(producerId).append("' requires registration.");
result.appendToStatus(message.toString());
log.debug(message);
@@ -277,16 +304,16 @@
if (discardLocalInfo)
{
- registrationProperties = getOrCreateRegistrationPropertiesMap(true);
+ persistentRegistrationProperties =
getOrCreateRegistrationPropertiesMap(true);
// Remove extra properties
- Set unexpected = new HashSet(registrationProperties.keySet());
+ Set unexpected = new
HashSet(persistentRegistrationProperties.keySet());
unexpected.removeAll(descriptionsMap.keySet());
if (!unexpected.isEmpty())
{
for (Iterator invalidProps = unexpected.iterator();
invalidProps.hasNext();)
{
- registrationProperties.remove(invalidProps.next());
+ persistentRegistrationProperties.remove(invalidProps.next());
}
}
@@ -303,7 +330,7 @@
}
else
{
- registrationProperties.put(name, prop);
+ persistentRegistrationProperties.put(name, prop);
}
}
@@ -312,22 +339,22 @@
}
else
{
- registrationProperties = getOrCreateRegistrationPropertiesMap(true);
+ 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,
registrationProperties);
+ 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)registrationProperties.get(name);
+ RegistrationProperty prop =
(RegistrationProperty)persistentRegistrationProperties.get(name);
RegistrationProperty producerProp =
(RegistrationProperty)descriptionsMap.get(name);
if (prop == null)
{
- registrationProperties.put(name, producerProp);
+ persistentRegistrationProperties.put(name, producerProp);
missingProps.append("Missing value for property
'").append(name).append("'\n");
}
else
@@ -361,11 +388,11 @@
String msg = "Producer '" + producerId + "' doesn't
require registration.";
log.debug(msg);
result.appendToStatus(msg);
- requiresRegistration = false;
+ requiresRegistration = Boolean.FALSE;
result.setValid(true);
}
- result.setRegistrationProperties(registrationProperties);
+ result.setRegistrationProperties(persistentRegistrationProperties);
String msg = "Registration configuration is " + (result.isValid() ?
"" : "NOT") + " valid";
result.appendToStatus(msg);
log.debug(msg);
@@ -422,7 +449,6 @@
/**
* @param descriptions
* @return
- * @since 2.6
*/
private Map getRegistrationPropertyDescriptionsFromWSRP(PropertyDescription[]
descriptions)
{
@@ -447,17 +473,17 @@
}
}
- /** @since 2.6 */
void resetRegistration()
{
registrationData = null;
- registrationHandle = null;
- registrationState = null;
+ persistentRegistrationHandle = null;
+ persistentRegistrationState = null;
}
public boolean isRegistrationValid()
{
- return registrationHandle != null || !requiresRegistration;
+ return (persistentRegistrationHandle != null &&
isRegistrationDeterminedRequired()) ||
+ isRegistrationDeterminedNotRequired();
}
public void setRegistrationContext(RegistrationContext registrationContext)
@@ -465,16 +491,16 @@
ParameterValidation.throwIllegalArgExceptionIfNull(registrationContext,
"RegistrationContext");
String handle = registrationContext.getRegistrationHandle();
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(handle,
"registration handle", "RegistrationContext");
- registrationHandle = handle;
- registrationState = registrationContext.getRegistrationState();
+ persistentRegistrationHandle = handle;
+ persistentRegistrationState = registrationContext.getRegistrationState();
}
public RegistrationContext getRegistrationContext()
{
- if (registrationHandle != null)
+ if (persistentRegistrationHandle != null)
{
- RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext(registrationHandle);
- registrationContext.setRegistrationState(registrationState);
+ RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext(persistentRegistrationHandle);
+ registrationContext.setRegistrationState(persistentRegistrationState);
return registrationContext;
}
else
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
===================================================================
---
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-05-02
13:07:29 UTC (rev 7175)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-05-02
18:42:13 UTC (rev 7176)
@@ -76,7 +76,7 @@
<property name="consumerName" column="CONSUMER_NAME"
type="java.lang.String" not-null="true"/>
<property name="registrationHandle" column="HANDLE"
type="java.lang.String"/>
<property name="registrationState" column="STATE"
type="binary" length="50000000"/>
- <map name="registrationProperties"
cascade="all,delete-orphan" lazy="false" access="field">
+ <map name="persistentRegistrationProperties"
cascade="all,delete-orphan" lazy="false" access="field">
<cache usage="@portal.hibernate.cache.usage(a)"/>
<key column="REG_PK" not-null="true"/>
<map-key type="string" column="name"/>