Author: chris.laprun(a)jboss.com
Date: 2007-03-30 22:00:07 -0400 (Fri, 30 Mar 2007)
New Revision: 6891
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml
Log:
- Removed use of ConsumerRegistry.getDefaultRegistration as ProducerInfo should now
properly deal with not having a RegistrationInfo.
- RegistrationInfo is now again a one-to-one association to ProducerInfo.
- JBPORTAL-715: better handling of RegistrationInfo makes destroyConsumer work :)
- Minimize reliance on external visibility of RegistrationInfo by having
getRegistrationContext method public on ProducerInfo.
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-03-30
23:58:02 UTC (rev 6890)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -128,7 +128,7 @@
assertEquals(1, regBehavior.getCallCount());
assertTrue(info.isRegistered());
assertNotNull(info.getRegistrationInfo());
- assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
info.getRegistrationInfo().getRegistrationContext().getRegistrationHandle());
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
info.getRegistrationContext().getRegistrationHandle());
assertTrue(info.refresh(true));
assertEquals(1, regBehavior.getCallCount());
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-03-30
23:58:02 UTC (rev 6890)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -147,7 +147,7 @@
public boolean isRequiresRegistration()
{
- return getProducerInfo().getRegistrationInfo().isRequiresRegistration();
+ return getProducerInfo().requiresRegistration();
}
public ProducerInfo getProducerInfo()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-03-30
23:58:02 UTC (rev 6890)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -55,8 +55,6 @@
void updateProducerInfo(ProducerInfo producerInfo);
- RegistrationInfo getDefaultRegistrationInfo();
-
void deactivateConsumerWith(String id) throws ConsumerException;
void registerOrDeregisterConsumerWith(String id, boolean register);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-30
23:58:02 UTC (rev 6890)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -58,7 +58,6 @@
private String sessionFactoryJNDIName;
- private RegistrationInfo nullRegistration;
private static final String CONSUMER_WITH_ID = "Consumer with id '";
public FederatingPortletInvoker getFederatingPortletInvoker()
@@ -79,15 +78,12 @@
ProducerInfo info = new ProducerInfo();
info.setId(id);
info.setRegistry(this);
- info.setRegistrationInfo(nullRegistration);
info.setExpirationCacheSeconds(expirationCacheSeconds);
try
{
Session session = sessionFactory.getCurrentSession();
- // make sure we re-attach nullRegistration
- session.refresh(nullRegistration);
session.persist(info);
}
catch (HibernateException e)
@@ -179,14 +175,6 @@
activateConsumerWith(producerInfo.getId());
}
}
-
- nullRegistration = (RegistrationInfo)session.createQuery("from
RegistrationInfo where key = (select min(key) from
RegistrationInfo)").uniqueResult();
- if (nullRegistration == null)
- {
- nullRegistration = new RegistrationInfo();
- nullRegistration.setRequiresRegistration(false);
- session.persist(nullRegistration);
- }
}
private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
@@ -267,11 +255,6 @@
return (WSRPConsumer)consumers.get(id);
}
- public RegistrationInfo getDefaultRegistrationInfo()
- {
- return nullRegistration;
- }
-
public void registerOrDeregisterConsumerWith(String id, boolean register)
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "registerConsumerWith");
@@ -288,14 +271,10 @@
if (register)
{
consumer.getProducerInfo().register();
-
- log.info(CONSUMER_WITH_ID + id + "' registered");
}
else
{
consumer.getProducerInfo().deregister();
-
- log.info(CONSUMER_WITH_ID + id + "' deregistered");
}
}
catch (PortletInvokerException e)
@@ -319,13 +298,12 @@
throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "'
doesn't exist!");
}
+ // todo: remove WSRPConsumerService
WSRPConsumerService service = new WSRPConsumerService();
service.setConsumer(consumer);
service.setFederatingPortletInvoker(federatingPortletInvoker);
service.start();
consumer.activate();
-
- log.info(CONSUMER_WITH_ID + id + "' activated");
}
else
{
@@ -338,8 +316,6 @@
consumer = (WSRPConsumer)invoker;
federatingPortletInvoker.unregisterInvoker(id);
consumer.deactivate();
-
- log.info(CONSUMER_WITH_ID + id + "' deactivated");
}
else
{
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-30
23:58:02 UTC (rev 6890)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -166,6 +166,12 @@
return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationValid();
}
+ public boolean requiresRegistration()
+ {
+ return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRequiresRegistration();
+
+ }
+
/**
* Determines whether the associated consumer is active.
*
@@ -250,7 +256,7 @@
else
{
log.debug("Registration not required");
- setRegistrationInfo(registry.getDefaultRegistrationInfo());
+// setRegistrationInfo(registry.getDefaultRegistrationInfo());
setServiceDescriptionRequest(getUnregisteredServiceDescriptionRequest());
extractOfferedPortlets(serviceDescription);
return true;
@@ -522,7 +528,7 @@
return gsd;
}
- private RegistrationContext getRegistrationContext()
+ public RegistrationContext getRegistrationContext()
{
return persistentRegistrationInfo == null ? null :
persistentRegistrationInfo.getRegistrationContext();
}
@@ -623,7 +629,8 @@
}
persistentRegistrationInfo.setRegistrationContext(registrationContext);
- log.info("Successfully registered with handle: '" +
registrationContext.getRegistrationHandle() + "'");
+ log.info("Conusmer with id '" + persistentId +
"' successfully registered with handle: '"
+ + registrationContext.getRegistrationHandle() + "'");
return true;
}
catch (Exception e)
@@ -654,6 +661,7 @@
persistentEndpointInfo.getRegistrationService().deregister(getRegistrationContext());
persistentRegistrationInfo.resetRegistration();
registry.updateProducerInfo(this);
+ log.info("Consumer with id '" + persistentId + "'
deregistered.");
}
catch (Exception e)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-30
23:58:02 UTC (rev 6890)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -443,7 +443,7 @@
RegistrationContext getRegistrationContext()
{
- return producerInfo.getRegistrationInfo().getRegistrationContext();
+ return producerInfo.getRegistrationContext();
}
// Session information access
***************************************************************************************
@@ -464,6 +464,7 @@
if (!started)
{
startService();
+ log.info("Consumer with id '" + getProducerId() + "'
activated");
}
producerInfo.setActive(getServiceFactory().isAvailable());
}
@@ -474,6 +475,7 @@
if (started)
{
stopService();
+ log.info("Consumer with id '" + getProducerId() + "'
deactivated");
}
}
@@ -540,8 +542,7 @@
public void releaseSessions(String[] sessionIds) throws PortletInvokerException
{
//todo: move to SessionHandler?
- ReleaseSessions releaseSessions =
-
WSRPTypeFactory.createReleaseSessions(producerInfo.getRegistrationInfo().getRegistrationContext(),
sessionIds);
+ ReleaseSessions releaseSessions =
WSRPTypeFactory.createReleaseSessions(getRegistrationContext(), sessionIds);
try
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java 2007-03-30
23:58:02 UTC (rev 6890)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPConsumerService.java 2007-03-31
02:00:07 UTC (rev 6891)
@@ -28,6 +28,8 @@
import org.jboss.portal.wsrp.WSRPConsumer;
/**
+ * todo: Remove, since it shouldn't be needed anymore now that we can register to a
FederatingPortletInvoker directly
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
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-03-30
23:58:02 UTC (rev 6890)
+++
trunk/wsrp/src/resources/portal-wsrp-sar/conf/consumer/hibernate/domain.hbm.xml 2007-03-31
02:00:07 UTC (rev 6891)
@@ -43,6 +43,7 @@
<many-to-one name="registrationInfo"
column="REGISTRATION_ID"
class="org.jboss.portal.wsrp.consumer.RegistrationInfo"
+ unique="true"
not-null="false"
cascade="all"
lazy="false"/>