Author: chris.laprun(a)jboss.com
Date: 2009-01-28 14:18:03 -0500 (Wed, 28 Jan 2009)
New Revision: 12686
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_7/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.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28
11:21:15 UTC (rev 12685)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ConsumerRegistryTestCase.java 2009-01-28
19:18:03 UTC (rev 12686)
@@ -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_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28
11:21:15 UTC (rev 12685)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2009-01-28
19:18:03 UTC (rev 12686)
@@ -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_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28
11:21:15 UTC (rev 12685)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2009-01-28
19:18:03 UTC (rev 12686)
@@ -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()
@@ -345,7 +346,8 @@
try
{
// if we don't yet have registration information, get an unregistered
service description
- serviceDescription =
getUnmanagedServiceDescription(persistentRegistrationInfo == null);
+ boolean unmanaged = persistentRegistrationInfo == null ||
persistentRegistrationInfo.isUndetermined();
+ serviceDescription = getUnmanagedServiceDescription(unmanaged);
result.setServiceDescription(serviceDescription);
}
catch (OperationFailedFault operationFailedFault)
@@ -409,7 +411,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 +544,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 +618,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 +688,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 +767,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 +789,7 @@
public RegistrationContext getRegistrationContext() throws PortletInvokerException
{
- if (persistentRegistrationInfo == null)
+ if (persistentRegistrationInfo == null ||
persistentRegistrationInfo.isUndetermined())
{
refresh(false);
}
@@ -835,7 +837,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)
{
@@ -887,7 +889,7 @@
{
log.debug("Attempting registration");
RegistrationContext registrationContext =
persistentEndpointInfo.getRegistrationService()
- .register(persistentRegistrationInfo.getRegistrationData());
+ .register(persistentRegistrationInfo.getRegistrationData());
if (registrationContext == null)
{
@@ -897,7 +899,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);
@@ -963,7 +965,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 +995,7 @@
else
{
throw new IllegalStateException("Cannot modify registration for producer
'" + persistentId
- + "' as it's not registered");
+ + "' as it's not registered");
}
}
@@ -1013,7 +1015,7 @@
}
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 +1025,9 @@
public boolean isRefreshNeeded(boolean considerCache)
{
boolean result = (considerCache && isCacheExpired())
- || persistentRegistrationInfo == null
- || persistentRegistrationInfo.isRefreshNeeded()
- || persistentEndpointInfo.isRefreshNeeded();
+ || persistentRegistrationInfo == null
+ || persistentRegistrationInfo.isRefreshNeeded()
+ || persistentEndpointInfo.isRefreshNeeded();
if (result)
{
log.debug("Refresh needed for producer '" + persistentId +
"'");
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28
11:21:15 UTC (rev 12685)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2009-01-28
19:18:03 UTC (rev 12686)
@@ -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. *
@@ -68,6 +68,12 @@
private transient boolean modifyRegistrationNeeded;
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();
@@ -76,6 +82,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);
@@ -379,6 +397,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)
{