Author: chris.laprun(a)jboss.com
Date: 2009-01-28 19:30:45 -0500 (Wed, 28 Jan 2009)
New Revision: 12694
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
Log:
- JBPORTAL-2284: ProducerInfo are now created with a RegistrationInfo that's marked as
undetermined instead of null. (merged both 12686 and 12692).
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-29
00:03:31 UTC (rev 12693)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-29
00:30:45 UTC (rev 12694)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -31,6 +31,7 @@
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import java.util.Collection;
@@ -77,7 +78,8 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET,
endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
TransactionAssert.commitTransaction();
TransactionAssert.beginTransaction();
@@ -103,7 +105,7 @@
assertNotNull(endpoint);
assertEquals(EndpointConfigurationInfo.UNSET,
endpoint.getServiceDescriptionURL());
assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
- assertNull(info.getRegistrationInfo());
+ assertTrue(info.getRegistrationInfo().isUndetermined());
assertNull(registry.getConsumer("inexistent"));
Collection consumers = registry.getConfiguredConsumers();
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-29
00:03:31 UTC (rev 12693)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-29
00:30:45 UTC (rev 12694)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -152,7 +152,8 @@
public void testRefreshAndRegistration() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
@@ -173,7 +174,8 @@
public void testGetRegistrationContext() throws Exception
{
assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
sd.setRequiresRegistration(true);
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-29
00:03:31 UTC (rev 12693)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-29
00:30:45 UTC (rev 12694)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -123,6 +123,7 @@
public ProducerInfo()
{
persistentEndpointInfo = new EndpointConfigurationInfo(this);
+ persistentRegistrationInfo =
RegistrationInfo.createUndeterminedRegistration(this);
}
public ConsumerRegistry getRegistry()
@@ -176,10 +177,7 @@
public RegistrationInfo getRegistrationInfo()
{
// update parent since it might not be set when unfrozen from Hibernate
- if (persistentRegistrationInfo != null)
- {
- persistentRegistrationInfo.setParent(this);
- }
+ persistentRegistrationInfo.setParent(this);
return persistentRegistrationInfo;
}
@@ -190,35 +188,30 @@
public boolean isRegistered()
{
- if (persistentRegistrationInfo != null)
+ Boolean valid = persistentRegistrationInfo.isRegistrationValid();
+ if (valid == null)
{
- Boolean valid = persistentRegistrationInfo.isRegistrationValid();
- if (valid == null)
- {
- return persistentRegistrationInfo.getRegistrationHandle() != null;
- }
- else
- {
- return valid;
- }
+ return persistentRegistrationInfo.getRegistrationHandle() != null;
}
-
- return false;
+ else
+ {
+ return valid;
+ }
}
public boolean isRegistrationRequired()
{
- return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationDeterminedRequired();
+ return persistentRegistrationInfo.isRegistrationDeterminedRequired();
}
public boolean isRegistrationChecked()
{
- return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationRequired() != null;
+ return persistentRegistrationInfo.isRegistrationRequired() != null;
}
public boolean hasLocalRegistrationInfo()
{
- return persistentRegistrationInfo != null &&
persistentRegistrationInfo.hasLocalInfo();
+ return persistentRegistrationInfo.hasLocalInfo();
}
/**
@@ -250,7 +243,7 @@
public boolean isModifyRegistrationRequired()
{
- return isModifyRegistrationRequired || (persistentRegistrationInfo != null
&& persistentRegistrationInfo.isModified());
+ return isModifyRegistrationRequired || persistentRegistrationInfo.isModified();
}
// FIX-ME: remove when a better dirty management is in place at property level
@@ -308,7 +301,7 @@
{
ServiceDescription serviceDescription;
- if(isModifyRegistrationRequired)
+ if (isModifyRegistrationRequired)
{
return new RefreshResult(RefreshResult.Status.MODIFY_REGISTRATION_REQUIRED);
}
@@ -345,7 +338,7 @@
try
{
// if we don't yet have registration information, get an unregistered
service description
- serviceDescription =
getUnmanagedServiceDescription(persistentRegistrationInfo == null);
+ serviceDescription =
getUnmanagedServiceDescription(persistentRegistrationInfo.isUndetermined());
result.setServiceDescription(serviceDescription);
}
catch (OperationFailedFault operationFailedFault)
@@ -409,7 +402,7 @@
}
private RefreshResult refreshInfo(boolean forceRefresh, ServiceDescription
serviceDescription, RefreshResult result)
- throws PortletInvokerException
+ throws PortletInvokerException
{
// do we need to call initCookie or not?
requiresInitCookie = serviceDescription.getRequiresInitCookie();
@@ -542,8 +535,8 @@
if (info.isUsesMethodGet())
{
log.warn("Portlet '" + portletHandle
- + "' uses the GET method in forms. Since we don't handle
this, this portlet will be excluded from " +
- "the list of offered portlets for producer " + persistentId);
+ + "' uses the GET method in forms. Since we don't handle this,
this portlet will be excluded from " +
+ "the list of offered portlets for producer " + persistentId);
}
else
{
@@ -616,7 +609,7 @@
catch (Exception e)
{
log.debug("Couldn't get portlet via getPortletDescription for
producer '" + persistentId
- + "'. Attempting to retrieve it from the service description
as this producer might not support the PortletManagement interface.", e);
+ + "'. Attempting to retrieve it from the service description as
this producer might not support the PortletManagement interface.", e);
justRefreshed = refresh(true);
portlet = getPortletFromCaches(portletHandle, justRefreshed);
@@ -686,7 +679,7 @@
private boolean isCacheExpired()
{
boolean result = !useCache() || System.currentTimeMillis() >
expirationTimeMillis || popsMap == null
- || portletGroups == null;
+ || portletGroups == null;
if (result)
{
log.debug("Cache expired or not used");
@@ -765,7 +758,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for
producer "
- + persistentId + ", please see the logs for more information. ",
cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ", cause
== null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred)
throws PortletInvokerException
@@ -787,7 +780,7 @@
public RegistrationContext getRegistrationContext() throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
+ if (persistentRegistrationInfo.isUndetermined())
{
refresh(false);
}
@@ -797,10 +790,7 @@
public void resetRegistration() throws PortletInvokerException
{
- if (persistentRegistrationInfo != null)
- {
- persistentRegistrationInfo.resetRegistration();
- }
+ persistentRegistrationInfo.resetRegistration();
invalidateCache();
registry.updateProducerInfo(this);
@@ -835,7 +825,7 @@
throw new RuntimeException("Couldn't reset registration", e);
}
throw new IllegalArgumentException("Couldn't get property descriptions
for portlet '" + portletHandle
- + "' because the provided registration is invalid!");
+ + "' because the provided registration is invalid!");
}
catch (Exception e)
{
@@ -863,11 +853,6 @@
*/
private RefreshResult register(ServiceDescription serviceDescription, boolean
forceRefresh) throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
- {
- persistentRegistrationInfo = new RegistrationInfo(this);
- }
-
if (!isRegistered())
{
persistentEndpointInfo.refresh();
@@ -887,7 +872,7 @@
{
log.debug("Attempting registration");
RegistrationContext registrationContext =
persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
+ .register(persistentRegistrationInfo.getRegistrationData());
if (registrationContext == null)
{
@@ -897,7 +882,7 @@
persistentRegistrationInfo.setRegistrationContext(registrationContext);
String msg = "Consumer with id '" + persistentId +
"' successfully registered with handle: '"
- + registrationContext.getRegistrationHandle() +
"'";
+ + registrationContext.getRegistrationHandle() + "'";
log.debug(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
@@ -955,7 +940,7 @@
public void modifyRegistration() throws PortletInvokerException
{
- if (persistentRegistrationInfo != null &&
persistentRegistrationInfo.getRegistrationHandle() != null)
+ if (persistentRegistrationInfo.getRegistrationHandle() != null)
{
persistentEndpointInfo.refresh();
@@ -963,7 +948,7 @@
{
RegistrationContext registrationContext = getRegistrationContext();
ModifyRegistration modifyRegistration =
WSRPTypeFactory.createModifyRegistration(registrationContext,
- persistentRegistrationInfo.getRegistrationData());
+ persistentRegistrationInfo.getRegistrationData());
RegistrationState state =
persistentEndpointInfo.getRegistrationService().modifyRegistration(modifyRegistration);
// force refresh of internal RegistrationInfo state
@@ -993,7 +978,7 @@
else
{
throw new IllegalStateException("Cannot modify registration for producer
'" + persistentId
- + "' as it's not registered");
+ + "' as it's not registered");
}
}
@@ -1007,13 +992,8 @@
private RefreshResult internalRefreshRegistration(ServiceDescription
serviceDescription, boolean mergeWithLocalInfo, boolean forceRefresh, boolean
forceCheckOfExtraProps) throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
- {
- persistentRegistrationInfo = new RegistrationInfo(this);
- }
-
RefreshResult result =
- persistentRegistrationInfo.refresh(serviceDescription, persistentId,
mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
+ persistentRegistrationInfo.refresh(serviceDescription, persistentId,
mergeWithLocalInfo, forceRefresh, forceCheckOfExtraProps);
log.debug("Refreshed registration information for consumer with id '"
+ persistentId + "'");
@@ -1023,9 +1003,8 @@
public boolean isRefreshNeeded(boolean considerCache)
{
boolean result = (considerCache && isCacheExpired())
- || persistentRegistrationInfo == null
- || persistentRegistrationInfo.isRefreshNeeded()
- || persistentEndpointInfo.isRefreshNeeded();
+ || persistentRegistrationInfo.isRefreshNeeded()
+ || persistentEndpointInfo.isRefreshNeeded();
if (result)
{
log.debug("Refresh needed for producer '" + persistentId +
"'");
@@ -1042,7 +1021,7 @@
public void eraseRegistrationInfo()
{
- persistentRegistrationInfo = null;
+ persistentRegistrationInfo =
RegistrationInfo.createUndeterminedRegistration(this);
registry.updateProducerInfo(this);
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-29
00:03:31 UTC (rev 12693)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-29
00:30:45 UTC (rev 12694)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -67,6 +67,12 @@
private transient boolean dirty;
private transient ProducerInfo parent;
+ /**
+ * Marker string to identify a RegistrationInfo created for a producer that might not
require registration as a work
+ * around
https://jira.jboss.org/jira/browse/JBPORTAL-2284
+ */
+ private static final String UNDETERMINED_REGISTRATION =
"__JBP__UNDETERMINED__REGISTRATION__";
+
public RegistrationInfo(ProducerInfo producerInfo)
{
this();
@@ -75,6 +81,18 @@
parent = producerInfo;
}
+ static RegistrationInfo createUndeterminedRegistration(ProducerInfo producerInfo)
+ {
+ RegistrationInfo info = new RegistrationInfo(producerInfo);
+ info.setConsumerName(UNDETERMINED_REGISTRATION);
+ return info;
+ }
+
+ public boolean isUndetermined()
+ {
+ return UNDETERMINED_REGISTRATION.equals(persistentConsumerName);
+ }
+
public RegistrationInfo(ProducerInfo producerInfo, boolean requiresRegistration)
{
this(producerInfo);
@@ -377,6 +395,12 @@
if (forceRefresh || isRefreshNeeded())
{
+ // if we were previously undetermined, become determined! :)
+ if (isUndetermined())
+ {
+ setConsumerName(WSRPConstants.DEFAULT_CONSUMER_NAME);
+ }
+
// get a service description if we don't already have one
if (serviceDescription == null && parent != null)
{