Author: chris.laprun(a)jboss.com
Date: 2007-03-29 17:31:22 -0400 (Thu, 29 Mar 2007)
New Revision: 6873
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Use register method in internalRefresh.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-29
20:04:41 UTC (rev 6872)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-29
21:31:22 UTC (rev 6873)
@@ -232,65 +232,22 @@
log.debug("ProducerInfo refresh needed for producer '" +
persistentId + "'");
serviceDescription = getServiceDescription();
- // todo: use register() here!
-
// do we need to call initCookie or not?
requiresInitCookie = serviceDescription.getRequiresInitCookie();
// do we need to register?
if (serviceDescription.isRequiresRegistration())
{
- // only process service description if consumer is not already registered
- if (!persistentRegistrationInfo.isRegistrationValid())
+ // attempt to register and determine if the current service description can
be used to extract POPs
+ if (register(serviceDescription))
{
- // if this producer info was set up without any registration information,
create one
- if
(registry.getDefaultRegistrationInfo().equals(persistentRegistrationInfo))
- {
- persistentRegistrationInfo = new RegistrationInfo(this);
- }
-
- // check if the configured registration information is correct and if we
can get the service description
- if (persistentRegistrationInfo.initialize(serviceDescription, getId()))
- {
- try
- {
- log.debug("Attempting registration");
- RegistrationContext registrationContext =
persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
-
- if (registrationContext == null)
- {
- setActive(false);
- throw new PortletInvokerException("Received null response
after registration from producer '" + persistentId + "'");
- }
-
-
persistentRegistrationInfo.setRegistrationContext(registrationContext);
- log.info("Successfully registered with handle: '" +
registrationContext.getRegistrationHandle() + "'");
- }
- catch (Exception e)
- {
- persistentRegistrationInfo.resetRegistration();
- setActive(false);
- throw new PortletInvokerException("Couldn't register with
producer '" + persistentId + "'", e);
- }
-
- log.debug("Requesting service description after
registration");
- extractOfferedPortlets(getServiceDescription());
- return true;
- }
- else
- {
- log.info("Consumer is not ready to be registered with producer
because of missing or invalid registration information.");
- setActive(false);
- throw new PortletInvokerException("Consumer is not ready to be
registered with producer because of missing or invalid registration information.");
- }
+ // registration occurred, so we should ask for a new service description
+ serviceDescription = getServiceDescription();
}
- else
- {
- // registration is valid: just refresh the offered portlets
- extractOfferedPortlets(serviceDescription);
- return true;
- }
+
+ // extract the POPs
+ extractOfferedPortlets(serviceDescription);
+ return true;
}
else
{
@@ -625,7 +582,16 @@
registry.updateProducerInfo(this);
}
- private void register(ServiceDescription serviceDescription) throws
PortletInvokerException
+ /**
+ * Attempts to register with the producer.
+ *
+ * @param serviceDescription
+ * @return <code>true</code> if the client code should ask for a new
service description, <code>false</code> if the
+ * specified description is good to be further processed
+ * @throws PortletInvokerException
+ * @since 2.6
+ */
+ private boolean register(ServiceDescription serviceDescription) throws
PortletInvokerException
{
if (persistentRegistrationInfo == null)
{
@@ -640,38 +606,44 @@
serviceDescription = getServiceDescription();
}
- // check if the configured registration information is correct and if we can get
the service description
- if (persistentRegistrationInfo.initialize(serviceDescription, getId()))
+ if (serviceDescription.isRequiresRegistration())
{
- try
+ // check if the configured registration information is correct and if we can
get the service description
+ if (persistentRegistrationInfo.initialize(serviceDescription, getId()))
{
- log.debug("Attempting registration");
- RegistrationContext registrationContext =
persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
+ try
+ {
+ log.debug("Attempting registration");
+ RegistrationContext registrationContext =
persistentEndpointInfo.getRegistrationService()
+ .register(persistentRegistrationInfo.getRegistrationData());
- if (registrationContext == null)
+ if (registrationContext == null)
+ {
+ setActive(false);
+ throw new PortletInvokerException("Received null response after
registration from producer '" + persistentId + "'");
+ }
+
+
persistentRegistrationInfo.setRegistrationContext(registrationContext);
+ log.info("Successfully registered with handle: '" +
registrationContext.getRegistrationHandle() + "'");
+ return true;
+ }
+ catch (Exception e)
{
+ persistentRegistrationInfo.resetRegistration();
setActive(false);
- throw new PortletInvokerException("Received null response after
registration from producer '" + persistentId + "'");
+ throw new PortletInvokerException("Couldn't register with
producer '" + persistentId + "'", e);
}
-
- persistentRegistrationInfo.setRegistrationContext(registrationContext);
- log.info("Successfully registered with handle: '" +
registrationContext.getRegistrationHandle() + "'");
}
- catch (Exception e)
+ else
{
- persistentRegistrationInfo.resetRegistration();
+ log.info("Consumer is not ready to be registered with producer
because of missing or invalid registration information.");
setActive(false);
- throw new PortletInvokerException("Couldn't register with
producer '" + persistentId + "'", e);
+ throw new PortletInvokerException("Consumer is not ready to be
registered with producer because of missing or invalid registration information.");
}
}
- else
- {
- log.info("Consumer is not ready to be registered with producer because
of missing or invalid registration information.");
- setActive(false);
- throw new PortletInvokerException("Consumer is not ready to be
registered with producer because of missing or invalid registration information.");
- }
}
+
+ return false;
}
public void deregister() throws PortletInvokerException