[seam-commits] Seam SVN: r11422 - branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Aug 25 07:00:41 EDT 2009
Author: manaRH
Date: 2009-08-25 07:00:41 -0400 (Tue, 25 Aug 2009)
New Revision: 11422
Added:
branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java
Modified:
branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
Log:
JBPAPP-2362
Modified: branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-08-25 08:16:50 UTC (rev 11421)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/SubscriptionRegistry.java 2009-08-25 11:00:41 UTC (rev 11422)
@@ -153,30 +153,35 @@
}
}
- /**
- *
- * @return Set
- */
- public Set getUserTokens()
+ public UserTokens getUserTokens()
{
- Context session = Contexts.getSessionContext();
- if (session.get(CONTEXT_USER_TOKENS) == null)
- {
- synchronized(session)
- {
- if (session.get(CONTEXT_USER_TOKENS) == null)
- session.set(CONTEXT_USER_TOKENS, new HashSet<String> ());
- }
- }
- return (Set) session.get(CONTEXT_USER_TOKENS);
+ return (UserTokens) Component.getInstance(UserTokens.class);
}
public RemoteSubscriber getSubscription(String token)
{
- if (!getUserTokens().contains(token))
- throw new IllegalArgumentException(
- "Invalid token argument - token not found in Session Context.");
-
+ if (!getUserTokens().contains(token)) {
+ throw new IllegalArgumentException("Invalid token argument - token not found in Session Context.");
+ }
+
return subscriptions.get(token);
}
+
+ public Set<String> getAllTokens() {
+ return subscriptions.keySet();
+ }
+
+ public void cleanupTokens(Set<String> tokens)
+ {
+ for (String token: tokens) {
+ RemoteSubscriber subscriber = subscriptions.remove(token);
+ if (subscriber!=null) {
+ try {
+ subscriber.unsubscribe();
+ } catch (Exception e) {
+ log.debug("problem cleaning up subcription", e);
+ }
+ }
+ }
+ }
}
Added: branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java (rev 0)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/messaging/UserTokens.java 2009-08-25 11:00:41 UTC (rev 11422)
@@ -0,0 +1,33 @@
+package org.jboss.seam.remoting.messaging;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+ at Name("org.jboss.seam.remoting.messaging.SubscriptionRegistry.userTokens")
+ at Scope(ScopeType.SESSION)
+public class UserTokens
+{
+ Set<String> tokens = new HashSet<String>();
+
+ public void add(String token) {
+ tokens.add(token);
+ }
+
+ public boolean contains(String token) {
+ return tokens.contains(token);
+ }
+
+ public void remove(String token) {
+ tokens.remove(token);
+ }
+
+ @Destroy
+ public void cleanUp() {
+ SubscriptionRegistry.instance().cleanupTokens(tokens);
+ }
+}
More information about the seam-commits
mailing list