Author: chris.laprun(a)jboss.com
Date: 2009-10-02 12:33:19 -0400 (Fri, 02 Oct 2009)
New Revision: 236
Modified:
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEvent.java
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventBroadcaster.java
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventListener.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/SessionHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
Log:
- Improved integration API:
+ Changed SessionEventBroadcaster to an interface.
+ Added event type on SessionEvent.
+ Streamlined SessionEventListener interface.
- Adapted SessionHandler and WSRPConsumerImpl to changes in integration interface.
Modified: components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEvent.java
===================================================================
---
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEvent.java 2009-10-02
16:30:12 UTC (rev 235)
+++
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEvent.java 2009-10-02
16:33:19 UTC (rev 236)
@@ -31,5 +31,12 @@
*/
public interface SessionEvent
{
+ enum SessionEventType
+ {
+ SESSION_CREATED, SESSION_DESTROYED
+ }
+
+ SessionEventType getType();
+
HttpSession getSession();
}
Modified:
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventBroadcaster.java
===================================================================
---
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventBroadcaster.java 2009-10-02
16:30:12 UTC (rev 235)
+++
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventBroadcaster.java 2009-10-02
16:33:19 UTC (rev 236)
@@ -24,20 +24,14 @@
package org.gatein.wsrp.api;
/**
- * TODO: Implement
- *
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
*/
-public class SessionEventBroadcaster
+public interface SessionEventBroadcaster
{
- public void registerListener(String listenerId, SessionEventListener listener)
- {
- throw new UnsupportedOperationException("registerListener");
- }
+ public void registerListener(String listenerId, SessionEventListener listener);
- public void unregisterListener(String listenerId)
- {
- throw new UnsupportedOperationException("unregisterListener");
- }
+ public void unregisterListener(String listenerId);
+
+ public void notifyListenersOf(SessionEvent event);
}
Modified:
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventListener.java
===================================================================
---
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventListener.java 2009-10-02
16:30:12 UTC (rev 235)
+++
components/wsrp/trunk/api/src/main/java/org/gatein/wsrp/api/SessionEventListener.java 2009-10-02
16:33:19 UTC (rev 236)
@@ -29,7 +29,5 @@
*/
public interface SessionEventListener
{
- void sessionCreated(SessionEvent event);
-
- void sessionDestroyed(SessionEvent event);
+ void onSessionEvent(SessionEvent event);
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/SessionHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/SessionHandler.java 2009-10-02
16:30:12 UTC (rev 235)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/SessionHandler.java 2009-10-02
16:33:19 UTC (rev 236)
@@ -390,30 +390,28 @@
// SessionEventListener implementation
- public void sessionCreated(SessionEvent event)
+ public void onSessionEvent(SessionEvent event)
{
- // nothing to do
- }
-
- public void sessionDestroyed(SessionEvent event)
- {
- String id = event.getSession().getId();
-
- // check if the session being destroyed is the one associated with this thread
- ProducerSessionInformation info =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
- if (info != null)
+ if (SessionEvent.SessionEventType.SESSION_DESTROYED.equals(event.getType()))
{
- if (id != null && id.equals(info.getParentSessionId()))
+ String id = event.getSession().getId();
+
+ // check if the session being destroyed is the one associated with this thread
+ ProducerSessionInformation info =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ if (info != null)
{
- try
+ if (id != null && id.equals(info.getParentSessionId()))
{
- internalReleaseSessions(info.removeSessions());
+ try
+ {
+ internalReleaseSessions(info.removeSessions());
+ }
+ catch (PortletInvokerException e)
+ {
+ // already logged...
+ }
+ log.debug("Released session '" + id + "' after
session was destroyed by Portal.");
}
- catch (PortletInvokerException e)
- {
- // already logged...
- }
- log.debug("Released session '" + id + "' after session
was destroyed by Portal.");
}
}
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2009-10-02
16:30:12 UTC (rev 235)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2009-10-02
16:33:19 UTC (rev 236)
@@ -683,13 +683,8 @@
return getHttpRequest(invocation).getSession();
}
- public void sessionCreated(SessionEvent event)
+ public void onSessionEvent(SessionEvent event)
{
- sessionHandler.sessionCreated(event);
+ sessionHandler.onSessionEvent(event);
}
-
- public void sessionDestroyed(SessionEvent event)
- {
- sessionHandler.sessionDestroyed(event);
- }
}
Show replies by date