[jboss-cvs] JBossAS SVN: r95348 - in projects/cluster/ha-server-cache-jbc/trunk/src: main/java/org/jboss/web/tomcat/service/sso/jbc and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 21 17:43:36 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-10-21 17:43:36 -0400 (Wed, 21 Oct 2009)
New Revision: 95348
Added:
projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/FieldFqnTestCase.java
Modified:
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java
projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/sso/jbc/JBossCacheSSOClusterManager.java
Log:
[JBCLUSTER-241] Clean up Fqn creation
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java 2009-10-21 21:39:15 UTC (rev 95347)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java 2009-10-21 21:43:36 UTC (rev 95348)
@@ -91,15 +91,13 @@
public static Fqn<String> getSessionFqn(String contextHostPath, String sessionId)
{
- String[] objs = new String[]{SESSION, contextHostPath, sessionId};
- return Fqn.fromList(Arrays.asList(objs), true);
+ return Fqn.fromElements(SESSION, contextHostPath, sessionId);
}
@Deprecated
public static Fqn<String> getBuddyBackupSessionFqn(String dataOwner, String contextHostPath, String sessionId)
{
- String[] objs = new String[]{BUDDY_BACKUP, dataOwner, SESSION, contextHostPath, sessionId};
- return Fqn.fromList(Arrays.asList(objs), true);
+ return Fqn.fromElements(BUDDY_BACKUP, dataOwner, SESSION, contextHostPath, sessionId);
}
@SuppressWarnings("unchecked")
@@ -216,8 +214,7 @@
}
this.batchingManager = new BatchingManagerImpl(tm);
- String[] objs = new String[]{SESSION, combinedPath_};
- Fqn<String> pathFqn = Fqn.fromList(Arrays.asList(objs), true);
+ Fqn<String> pathFqn = Fqn.fromElements(SESSION, combinedPath_);
BuddyReplicationConfig brc = plainCache_.getConfiguration().getBuddyReplicationConfig();
this.useBuddyReplication_ = brc != null && brc.isEnabled();
@@ -276,8 +273,7 @@
plainCache_.removeCacheListener(passivationListener_);
// Construct the fqn
- String[] objs = new String[]{SESSION, combinedPath_};
- Fqn<String> pathFqn = Fqn.fromList(Arrays.asList(objs), true);
+ Fqn<String> pathFqn = Fqn.fromElements(SESSION, combinedPath_);
if(useTreeCacheMarshalling_)
{
@@ -602,8 +598,7 @@
protected Fqn<String> getWebappFqn()
{
// /SESSION/webAppPath_hostName
- String[] objs = new String[]{SESSION, combinedPath_};
- return Fqn.fromList(Arrays.asList(objs), true);
+ return Fqn.fromElements(SESSION, combinedPath_);
}
/**
@@ -723,8 +718,7 @@
{
List<Fqn<Object>> result = new ArrayList<Fqn<Object>>();
// First, just assume a non-dead tree exists
- Object[] objs = new Object[]{BUDDY_BACKUP, dataOwner, SESSION, contextHostPath, sessionId};
- result.add(Fqn.fromList(Arrays.asList(objs), true));
+ result.add(Fqn.fromElements((Object) BUDDY_BACKUP, dataOwner, SESSION, contextHostPath, sessionId));
// Now append any "dead" trees associated with this owner
String deadBuddy = dataOwner + DEAD_BUDDY_SUFFIX;
@@ -732,8 +726,7 @@
Set<Object> buddies = plainCache_.getChildrenNames(dead); // won't return null
for (Object child : buddies)
{
- objs = new Object[]{BUDDY_BACKUP, deadBuddy, child, SESSION, contextHostPath, sessionId};
- result.add(Fqn.fromList(Arrays.asList(objs), true));
+ result.add(Fqn.fromElements(BUDDY_BACKUP, deadBuddy, child, SESSION, contextHostPath, sessionId));
}
return result;
}
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java 2009-10-21 21:39:15 UTC (rev 95347)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java 2009-10-21 21:43:36 UTC (rev 95348)
@@ -50,29 +50,30 @@
public static Fqn<String> getAttributeFqn(String contextHostPath, String sessionId)
{
- String[] objs = new String[]{SESSION, contextHostPath, sessionId, ATTRIBUTE};
- return Fqn.fromList(Arrays.asList(objs), true);
+ return Fqn.fromElements(SESSION, contextHostPath, sessionId, ATTRIBUTE);
}
public static Fqn<String> getFieldFqn(String contextHostPath, String sessionId, String attributeKey)
{
- List<String> list = new ArrayList<String>(5);
- list.add(SESSION);
- list.add(contextHostPath);
- list.add(sessionId);
- list.add(ATTRIBUTE);
- // Guard against string with delimiter.
- breakKeys(attributeKey, list);
- return Fqn.fromList(list, true);
- }
-
- private static void breakKeys(String key, List<String> list)
- {
- StringTokenizer token = new StringTokenizer(key, FQN_DELIMITER);
- while(token.hasMoreTokens())
+ StringTokenizer token = new StringTokenizer(attributeKey, FQN_DELIMITER);
+ int count = token.countTokens();
+ if (count == 1)
{
- list.add(token.nextToken());
+ return Fqn.fromElements(SESSION, contextHostPath, sessionId, ATTRIBUTE, attributeKey);
}
+ else
+ {
+ String[] args = new String[4 + count];
+ args[0] = SESSION;
+ args[1] = contextHostPath;
+ args[2] = sessionId;
+ args[3] = ATTRIBUTE;
+ for (int i = 0; i < count; i++)
+ {
+ args[4 + i] = token.nextToken();
+ }
+ return Fqn.fromElements(args);
+ }
}
private final PojoCache pojoCache_;
Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/sso/jbc/JBossCacheSSOClusterManager.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/sso/jbc/JBossCacheSSOClusterManager.java 2009-10-21 21:39:15 UTC (rev 95347)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/sso/jbc/JBossCacheSSOClusterManager.java 2009-10-21 21:43:36 UTC (rev 95348)
@@ -374,7 +374,7 @@
" in clustered cache");
}
- Fqn<Serializable> fqn = getSingleSignOnFqn(ssoId);
+ Fqn<String> fqn = getSingleSignOnFqn(ssoId);
try
{
@@ -401,7 +401,7 @@
SSOCredentials credentials = null;
// Find the latest credential info from the cluster
- Fqn<Serializable> fqn = getCredentialsFqn(ssoId);
+ Fqn<String> fqn = getCredentialsFqn(ssoId);
try
{
credentials = (SSOCredentials) getFromTreeCache(fqn, KEY);
@@ -868,14 +868,14 @@
// ------------------------------------------------------- Private Methods
- private Object getFromTreeCache(Fqn<Serializable> fqn, String key) throws Exception
+ private Object getFromTreeCache(Fqn<?> fqn, String key) throws Exception
{
return cache.get(fqn, key);
}
private Set<String> getSSOIds() throws Exception
{
- Fqn<Serializable> ssoRootFqn = Fqn.fromElements(new Serializable[] {SSO});
+ Fqn<String> ssoRootFqn = Fqn.fromElements(SSO);
@SuppressWarnings("unchecked")
Node ssoRoot = cache.getRoot().getChild(ssoRootFqn);
@SuppressWarnings("unchecked")
@@ -885,22 +885,20 @@
private Set<Object> getSSOPeers(String ssoId) throws Exception
{
- Fqn<Serializable> fqn = getSessionRootFqn(ssoId);
+ Fqn<String> fqn = getSessionRootFqn(ssoId);
Node<Object, Object> ssoRoot = cache.getRoot().getChild(fqn);
Set<Object> result = ssoRoot == null ? new HashSet<Object>() : ssoRoot.getChildrenNames();
return result;
}
- private Fqn<Serializable> getCredentialsFqn(String ssoid)
+ private Fqn<String> getCredentialsFqn(String ssoid)
{
- Serializable[] objs = new Serializable[]{SSO, ssoid, CREDENTIALS};
- return Fqn.fromElements(objs);
+ return Fqn.fromElements(SSO, ssoid, CREDENTIALS);
}
- private Fqn<Serializable> getSessionRootFqn(String ssoId)
+ private Fqn<String> getSessionRootFqn(String ssoId)
{
- Serializable[] objs = new Serializable[]{SSO, ssoId, SESSIONS };
- return Fqn.fromElements(objs);
+ return Fqn.fromElements(SSO, ssoId, SESSIONS);
}
private Fqn<Serializable> getSessionsFqn(String ssoid)
@@ -910,14 +908,12 @@
private Fqn<Serializable> getSessionsFqn(String ssoid, Serializable address)
{
- Serializable[] objs = new Serializable[]{SSO, ssoid, SESSIONS, address };
- return Fqn.fromElements(objs);
+ return Fqn.fromElements(SSO, ssoid, SESSIONS, address);
}
- private Fqn<Serializable> getSingleSignOnFqn(String ssoid)
+ private Fqn<String> getSingleSignOnFqn(String ssoid)
{
- Serializable[] objs = new Serializable[]{SSO, ssoid};
- return Fqn.fromElements(objs);
+ return Fqn.fromElements(SSO, ssoid);
}
/**
@@ -1150,7 +1146,7 @@
return avail;
}
- private void putInTreeCache(Fqn<Serializable> fqn, Object key, Object data) throws Exception
+ private void putInTreeCache(Fqn<?> fqn, Object key, Object data) throws Exception
{
cache.put(fqn, key, data);
}
@@ -1237,7 +1233,7 @@
{
if (cache.getConfiguration().isUseRegionBasedMarshalling())
{
- Region region =cache.getRegion(Fqn.fromString("/" + SSO), true);
+ Region region =cache.getRegion(Fqn.fromElements(SSO), true);
try
{
region.activate();
@@ -1278,7 +1274,7 @@
}
}
- private void removeFromTreeCache(Fqn<Serializable> fqn, boolean localOnly) throws Exception
+ private void removeFromTreeCache(Fqn<?> fqn, boolean localOnly) throws Exception
{
if (localOnly)
{
Added: projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/FieldFqnTestCase.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/FieldFqnTestCase.java (rev 0)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/FieldFqnTestCase.java 2009-10-21 21:43:36 UTC (rev 95348)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.tomcat.service.session.distributedcache.impl;
+
+import org.jboss.cache.Fqn;
+import org.jboss.web.tomcat.service.session.distributedcache.impl.jbc.AbstractJBossCacheService;
+import org.jboss.web.tomcat.service.session.distributedcache.impl.jbc.FieldBasedJBossCacheService;
+
+import junit.framework.TestCase;
+
+/**
+ * Test of {@link FieldBasedJBossCacheService#getFieldFqn(String, String, String)}
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class FieldFqnTestCase extends TestCase
+{
+ public void testGetFieldFqn()
+ {
+ String contextHostPath = "webapp_localhost";
+ String sessionId = "XYZ123";
+ Fqn<String> base = Fqn.fromElements(AbstractJBossCacheService.SESSION,
+ contextHostPath, sessionId, FieldBasedJBossCacheService.ATTRIBUTE);
+
+ Fqn<String> testee = FieldBasedJBossCacheService.getFieldFqn(contextHostPath, sessionId, "a");
+ assertTrue(testee.isChildOf(base));
+ assertEquals("a", testee.getLastElement());
+
+ testee = FieldBasedJBossCacheService.getFieldFqn(contextHostPath, sessionId, "a/b/c");
+ assertTrue(testee.isChildOf(base));
+ assertEquals("a", testee.get(base.size()));
+ assertEquals("b", testee.get(base.size() + 1));
+ assertEquals("c", testee.getLastElement());
+ }
+}
Property changes on: projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/FieldFqnTestCase.java
___________________________________________________________________
Name: svn:keywords
+
More information about the jboss-cvs-commits
mailing list