Author: chris.laprun(a)jboss.com
Date: 2007-03-17 14:47:52 -0400 (Sat, 17 Mar 2007)
New Revision: 6726
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
Log:
- Properly start and stop Consumers.
- Separated starting and activation concepts since the Consumer service can be stopped but
the Consumer should stay marked as active in the DB.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-17
14:34:52 UTC (rev 6725)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-03-17
18:47:52 UTC (rev 6726)
@@ -95,6 +95,14 @@
{
}
+ public void activate() throws Exception
+ {
+ }
+
+ public void deactivate() throws Exception
+ {
+ }
+
public Set getPortlets() throws PortletInvokerException
{
return null;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-17 14:34:52 UTC
(rev 6725)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-03-17 18:47:52 UTC
(rev 6726)
@@ -105,4 +105,8 @@
* @since 2.6
*/
void releaseSession(String sessionId) throws PortletInvokerException;
+
+ void activate() throws Exception;
+
+ void deactivate() throws Exception;
}
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-17
14:34:52 UTC (rev 6725)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-03-17
18:47:52 UTC (rev 6726)
@@ -59,6 +59,7 @@
private String sessionFactoryJNDIName;
private RegistrationInfo nullRegistration;
+ private static final String CONSUMER_WITH_ID = "Consumer with id '";
public FederatingPortletInvoker getFederatingPortletInvoker()
{
@@ -71,7 +72,7 @@
if (getConsumer(id) != null)
{
- throw new ConsumerException("A Consumer with id '" + id +
"' already exists!");
+ throw new ConsumerException(CONSUMER_WITH_ID + id + "' already
exists!");
}
@@ -94,6 +95,7 @@
throw new ConsumerException("Couldn't create Consumer '" + id
+ "'", e);
}
+ log.info(CONSUMER_WITH_ID + id + "' created");
return createConsumerFrom(info);
}
@@ -211,6 +213,14 @@
protected void stopService() throws Exception
{
sessionFactory = null;
+
+ for (Iterator consumersIt = consumers.values().iterator(); consumersIt.hasNext();)
+ {
+ WSRPConsumer consumer = (WSRPConsumer)consumersIt.next();
+ federatingPortletInvoker.unregisterInvoker(consumer.getProducerId());
+ consumer.stop();
+ }
+
consumers.clear();
consumers = null;
}
@@ -239,7 +249,7 @@
if (consumer == null)
{
- throw new ConsumerException("Consumer with id '" + id +
"' doesn't exist!");
+ throw new ConsumerException(CONSUMER_WITH_ID + id + "' doesn't
exist!");
}
try
@@ -247,15 +257,19 @@
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)
{
- throw new ConsumerException("Couldn't " + (register ?
"register" : "deregister") + " Consumer '" + id +
"'", e);
+ throw new ConsumerException("Couldn't " + (register ?
"register" : "deregister") + CONSUMER_WITH_ID + id +
"'", e);
}
}
@@ -271,13 +285,16 @@
if (consumer == null)
{
- throw new IllegalArgumentException("Consumer with id '" + id
+ "' doesn't exist!");
+ throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "'
doesn't exist!");
}
WSRPConsumerService service = new WSRPConsumerService();
service.setConsumer(consumer);
service.setFederatingPortletInvoker(federatingPortletInvoker);
service.start();
+ consumer.activate();
+
+ log.info(CONSUMER_WITH_ID + id + "' activated");
}
else
{
@@ -289,7 +306,9 @@
{
consumer = (WSRPConsumer)invoker;
federatingPortletInvoker.unregisterInvoker(id);
- consumer.stop();
+ consumer.deactivate();
+
+ log.info(CONSUMER_WITH_ID + id + "' deactivated");
}
else
{
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-17
14:34:52 UTC (rev 6725)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-03-17
18:47:52 UTC (rev 6726)
@@ -116,6 +116,7 @@
/** The set of supported user scopes */
private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE; // todo: make it possible
to support different user scopes
+ private transient boolean started;
public WSRPConsumerImpl()
{
@@ -456,21 +457,41 @@
return sessionHandler.getProducerSessionInformation(session);
}
+
+ public void activate() throws Exception
+ {
+ if (!started)
+ {
+ startService();
+ }
+ producerInfo.setActive(getServiceFactory().isAvailable());
+ }
+
+ public void deactivate() throws Exception
+ {
+ producerInfo.setActive(false);
+ if (started)
+ {
+ stopService();
+ }
+ }
+
// Service implementation
*******************************************************************************************
protected void startService() throws Exception
{
super.startService();
- ServiceFactory factory = getServiceFactory();
- factory.start();
- producerInfo.setActive(factory.isAvailable());
+ getServiceFactory().start();
+ started = true;
+ log.info("Consumer with id '" + getProducerId() + "'
started");
}
protected void stopService() throws Exception
{
- producerInfo.setActive(false);
getServiceFactory().stop();
super.stopService();
+ started = false;
+ log.info("Consumer with id '" + getProducerId() + "'
stopped");
}
// Web services access
**********************************************************************************************
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2007-03-17
14:34:52 UTC (rev 6725)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/AbstractSOAPServiceFactory.java 2007-03-17
18:47:52 UTC (rev 6726)
@@ -88,7 +88,7 @@
}
}
- // Get the stub from the service, remember that the stub itself is not threasafe
+ // Get the stub from the service, remember that the stub itself is not threadsafe
// and must be customized for every request to this method.
if (service != null)
{