[jboss-cvs] JBossAS SVN: r72695 - in trunk: testsuite/src/main/org/jboss/test/cluster/web and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 24 15:35:34 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-04-24 15:35:34 -0400 (Thu, 24 Apr 2008)
New Revision: 72695
Removed:
trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManagerLocator.java
trunk/cluster/src/main/org/jboss/ha/cachemanager/PojoCacheManager.java
Modified:
trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManager.java
trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
trunk/tomcat/.classpath
trunk/tomcat/build.xml
trunk/tomcat/pom.xml
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
Log:
[JBAS-5377] Manage clustered caches using a JBC CacheManager
Modified: trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManager.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManager.java 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManager.java 2008-04-24 19:35:34 UTC (rev 72695)
@@ -53,6 +53,9 @@
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapper;
+import org.jboss.ha.framework.server.CacheManagerLocator;
+import org.jboss.ha.framework.server.PojoCacheManager;
+import org.jboss.ha.framework.server.PojoCacheManagerLocator;
import org.jboss.logging.Logger;
import org.jboss.naming.NonSerializableFactory;
import org.jgroups.ChannelFactory;
@@ -67,7 +70,7 @@
*/
public class CacheManager
extends org.jboss.cache.CacheManagerImpl
- implements MBeanRegistration, PojoCacheManager, CacheManagerMBean
+ implements org.jboss.cache.CacheManager, PojoCacheManager, MBeanRegistration, CacheManagerMBean
{
private static final Logger log = Logger.getLogger(CacheManager.class);
@@ -216,7 +219,14 @@
synchronized (pojoCaches)
{
if (create && pojoCaches.containsKey(configName))
- throw new IllegalStateException("Cannot create PojoCache: plain cache already created for config " + configName);
+ {
+ log.debug("Plain cache requested for config " + configName +
+ " but a PojoCache is already registered; returning " +
+ " the PojoCache's underlying plain cache");
+ PojoCache pc = getPojoCache(configName, false);
+ if (pc != null)
+ return pc.getCache();
+ }
return super.getCache(configName, create);
}
@@ -300,6 +310,10 @@
if (locator.getDirectlyRegisteredManager() == null)
locator.registerCacheManager(this);
+ PojoCacheManagerLocator pclocator = PojoCacheManagerLocator.getCacheManagerLocator();
+ if (pclocator.getDirectlyRegisteredManager() == null)
+ pclocator.registerCacheManager(this);
+
// Bind ourself in the public JNDI space if configured to do so
if (jndiName != null)
{
@@ -371,6 +385,10 @@
CacheManagerLocator locator = CacheManagerLocator.getCacheManagerLocator();
if (locator.getDirectlyRegisteredManager() == this)
locator.deregisterCacheManager();
+
+ PojoCacheManagerLocator pclocator = PojoCacheManagerLocator.getCacheManagerLocator();
+ if (pclocator.getDirectlyRegisteredManager() == this)
+ pclocator.deregisterCacheManager();
started = false;
}
Deleted: trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManagerLocator.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManagerLocator.java 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/cluster/src/main/org/jboss/ha/cachemanager/CacheManagerLocator.java 2008-04-24 19:35:34 UTC (rev 72695)
@@ -1,185 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.ha.cachemanager;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jboss.ha.framework.interfaces.HAPartition;
-import org.jboss.logging.Logger;
-
-/**
- * Service Locator utility for locating a {@link PojoCacheManager}. Maintains
- * an internal ref to a manager, and if it that is null,
- * will attempt to find it in JNDI using a standard naming pattern.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class CacheManagerLocator
-{
- private static final Logger log = Logger.getLogger(CacheManagerLocator.class);
-
- private static CacheManagerLocator sharedInstance = new CacheManagerLocator();
-
- /** Name of the standard JNDI context under which HAPartitions are bound */
- public static final String STANDARD_JNDI_NAME = "java:CacheManager";
-
- private PojoCacheManager registeredManager;
-
- /**
- * Gets the
- * @return the shared CacheManagerLocator; will not be <code>null</code>
- */
- public static CacheManagerLocator getCacheManagerLocator()
- {
- return sharedInstance;
- }
-
- /**
- * Appends the partition name to {@link #STANDARD_JNDI_NAME}; e.g.
- * <code>/HAPartition/DefaultPartition</code>.
- *
- * @param partitionName the name of the partition
- * @return a string representing the standard name under which a
- * partition is bound in JNDI.
- */
- public static final String getStandardJndiBinding()
- {
- return STANDARD_JNDI_NAME;
- }
-
- /**
- * Allows replacement of the default implementation.
- *
- * @param shared the locator to use. Cannot be <code>null</code>.
- */
- protected static void setSharedInstance(CacheManagerLocator shared)
- {
- if (shared == null)
- throw new IllegalArgumentException("shared cannot be null");
-
- sharedInstance = shared;
- }
-
- /**
- * Allow subclasses to create a new HAPartitionLocator.
- */
- protected CacheManagerLocator()
- {
- }
-
- /**
- * Locates and returns the {@link HAPartition} whose partition name matches
- * the given <code>partitionName</code>.
- *
- * @param jndiProperties any naming properties to pass to new InitialContext()
- * if JNDI lookup is needed.
- * @return the partition. Will not return <code>null</code>
- *
- * @throws IllegalStateException if no cache manager can be found
- */
- public PojoCacheManager getCacheManager(Hashtable jndiProperties)
- {
- PojoCacheManager manager = registeredManager;
- if (manager == null)
- {
- try
- {
- manager = findInJndi(jndiProperties);
- }
- catch (NamingException e)
- {
- log.error("Problem finding CacheManager in JNDI", e);
- }
- }
-
- if (manager == null)
- throw new IllegalStateException("CacheManager not found");
-
- return manager;
- }
-
- /**
- * Register a CacheManager with this locator.
- *
- * @param partition the partition
- */
- public void registerCacheManager(PojoCacheManager manager)
- {
- if (manager != null)
- {
- if (registeredManager != null && manager != registeredManager)
- throw new IllegalStateException("CacheManager already registered");
- registeredManager = manager;
- }
- }
-
- public PojoCacheManager getDirectlyRegisteredManager()
- {
- return registeredManager;
- }
-
- /**
- * Deregister a partition from this locator.
- *
- * @param partition the partition
- */
- public void deregisterCacheManager()
- {
- registeredManager = null;
- }
-
- /**
- * Find the given CacheManager in JNDI under a
- * {@link #getStandardJndiBinding() standard binding}.
- *
- * @param jndiProperties any naming properties to pass to new InitialContext()
- *
- * @return the CacheManager, or <code>null</code>
- *
- * @throws NamingException if there is a problem with the naming context. Will
- * not throw NameNotFoundException; if not found, will
- * return <code>null</code>.
- *
- * @see #getStandardJndiBinding(String)
- */
- protected PojoCacheManager findInJndi(Hashtable jndiProperties) throws NamingException
- {
- try
- {
- Context ctx = new InitialContext(jndiProperties);
- return (PojoCacheManager) ctx.lookup(getStandardJndiBinding());
- }
- catch (NameNotFoundException e)
- {
- // just not there
- return null;
- }
-
- }
-}
Deleted: trunk/cluster/src/main/org/jboss/ha/cachemanager/PojoCacheManager.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/cachemanager/PojoCacheManager.java 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/cluster/src/main/org/jboss/ha/cachemanager/PojoCacheManager.java 2008-04-24 19:35:34 UTC (rev 72695)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ha.cachemanager;
-
-import java.util.Set;
-
-import org.jboss.cache.CacheManager;
-import org.jboss.cache.pojo.PojoCache;
-
-/**
- * {@link CacheManager} extension that also handles {@link PojoCache}s.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public interface PojoCacheManager extends CacheManager
-{
- Set<String> getPojoCacheNames();
-
- PojoCache getPojoCache(String configName, boolean create) throws Exception;
-
- void registerPojoCache(PojoCache cache, String configName);
-}
\ No newline at end of file
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java 2008-04-24 19:35:34 UTC (rev 72695)
@@ -34,8 +34,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.ha.cachemanager.CacheManagerLocator;
-import org.jboss.ha.cachemanager.PojoCacheManager;
+import org.jboss.ha.framework.server.CacheManagerLocator;
+import org.jboss.ha.framework.server.PojoCacheManager;
+import org.jboss.ha.framework.server.PojoCacheManagerLocator;
import org.jboss.mx.util.ObjectNameFactory;
import org.jboss.system.ServiceMBeanSupport;
@@ -74,7 +75,7 @@
{
if (usePojoCache)
{
- PojoCacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ PojoCacheManager cm = PojoCacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
return cm.getPojoCache(cacheConfig, true).getCache();
}
else
@@ -248,7 +249,7 @@
{
if (usePojoCache)
{
- PojoCacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ PojoCacheManager cm = PojoCacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
cm.releaseCache(cacheConfigName);
}
else
Modified: trunk/tomcat/.classpath
===================================================================
--- trunk/tomcat/.classpath 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/tomcat/.classpath 2008-04-24 19:35:34 UTC (rev 72695)
@@ -6,13 +6,13 @@
<classpathentry exported="true" kind="src" path="/aspects"/>
<classpathentry exported="true" kind="src" path="/connector"/>
<classpathentry exported="true" kind="src" path="/iiop"/>
- <classpathentry exported="true" kind="src" path="/cluster"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/sun-servlet/lib/jsp-api.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/apache-logging/lib/commons-logging.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/cache/jbosscache-core/lib/jbosscache-core.jar" sourcepath="/thirdparty/jboss/cache/jbosscache-core/lib/jbosscache-core-sources.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/cache/jbosscache-pojo/lib/jbosscache-pojo.jar" sourcepath="/thirdparty/jboss/cache/jbosscache-pojo/lib/jbosscache-pojo-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="/thirdparty/jgroups/lib/jgroups.jar"/>
+ <classpathentry exported="true" kind="lib" path="/thirdparty/jboss/jboss-ha-server-api/lib/jboss-ha-server-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="/thirdparty/jgroups/lib/jgroups.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/sun-jsf/lib/jsf-api.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/sun-jsf/lib/jsf-impl.jar"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/jboss/web/lib/el-api.jar"/>
Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/tomcat/build.xml 2008-04-24 19:35:34 UTC (rev 72695)
@@ -73,6 +73,7 @@
<path refid="jboss.integration.classpath"/>
<path refid="jboss.jboss.ejb3.core.classpath" />
<path refid="jboss.jboss.ejb3.interceptors.classpath" />
+ <path refid="jboss.jboss.ha.server.api.classpath"/>
</path>
<!-- ======= -->
@@ -92,7 +93,6 @@
<path refid="jboss.security.int.classpath"/>
<path refid="jboss.server.classpath"/>
<path refid="jboss.j2se.classpath"/>
- <path refid="jboss.cluster.classpath"/>
<path refid="jboss.cache.jbosscache.core.classpath"/>
<path refid="jboss.cache.jbosscache.pojo.classpath"/>
<path refid="jboss.aop.classpath"/>
Modified: trunk/tomcat/pom.xml
===================================================================
--- trunk/tomcat/pom.xml 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/tomcat/pom.xml 2008-04-24 19:35:34 UTC (rev 72695)
@@ -196,8 +196,8 @@
<artifactId>jboss-persistence-api</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-cluster</artifactId>
+ <groupId>org.jboss.cluster</groupId>
+ <artifactId>jboss-ha-server-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-04-24 19:31:27 UTC (rev 72694)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/Util.java 2008-04-24 19:35:34 UTC (rev 72695)
@@ -33,9 +33,11 @@
import org.jboss.aop.Advised;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheManager;
import org.jboss.cache.pojo.PojoCache;
-import org.jboss.ha.cachemanager.CacheManagerLocator;
-import org.jboss.ha.cachemanager.PojoCacheManager;
+import org.jboss.ha.framework.server.CacheManagerLocator;
+import org.jboss.ha.framework.server.PojoCacheManager;
+import org.jboss.ha.framework.server.PojoCacheManagerLocator;
/**
* Utility methods related to JBoss distributed sessions.
@@ -68,7 +70,7 @@
public static PojoCache findPojoCache(String cacheConfigName) throws ClusteringNotSupportedException
{
- PojoCacheManager pcm = getManagerForCache(cacheConfigName);
+ PojoCacheManager pcm = getManagerForPojoCache(cacheConfigName);
try
{
@@ -86,7 +88,7 @@
public static Cache findPlainCache(String cacheConfigName) throws ClusteringNotSupportedException
{
- PojoCacheManager pcm = getManagerForCache(cacheConfigName);
+ CacheManager pcm = getManagerForCache(cacheConfigName);
try
{
@@ -102,25 +104,44 @@
}
}
- private static PojoCacheManager getManagerForCache(String cacheConfigName)
+ private static PojoCacheManager getManagerForPojoCache(String cacheConfigName)
throws ClusteringNotSupportedException
{
PojoCacheManager pcm = null;
try
{
- pcm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ pcm = PojoCacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
}
catch (Throwable t)
{
- throw new ClusteringNotSupportedException("Could not access CacheManager for JBossWeb clustering", t);
+ throw new ClusteringNotSupportedException("Could not access PojoCacheManager for JBossWeb clustering", t);
}
if (!pcm.getConfigurationNames().contains(cacheConfigName))
- throw new IllegalStateException("CacheManager does not recognize config " + cacheConfigName);
+ throw new IllegalStateException("PojoCacheManager does not recognize config " + cacheConfigName);
return pcm;
}
+ private static CacheManager getManagerForCache(String cacheConfigName)
+ throws ClusteringNotSupportedException
+ {
+ CacheManager cm = null;
+ try
+ {
+ cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
+ }
+ catch (Throwable t)
+ {
+ throw new ClusteringNotSupportedException("Could not access CacheManager for JBossWeb clustering", t);
+ }
+
+ if (!cm.getConfigurationNames().contains(cacheConfigName))
+ throw new IllegalStateException("CacheManager does not recognize config " + cacheConfigName);
+
+ return cm;
+ }
+
/**
* Returns a session id with any trailing jvmRoute removed.
*
More information about the jboss-cvs-commits
mailing list