[jboss-cvs] JBossAS SVN: r107129 - projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 27 21:34:16 EDT 2010
Author: pferraro
Date: 2010-07-27 21:34:15 -0400 (Tue, 27 Jul 2010)
New Revision: 107129
Removed:
projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManagerFactoryFactory.java
projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/TestDistributedCacheManagerFactoryFactory.java
Log:
Replace DistributedCacheManagerFactoryFactory w/service loader mechanism
Deleted: projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManagerFactoryFactory.java
===================================================================
--- projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManagerFactoryFactory.java 2010-07-28 01:33:21 UTC (rev 107128)
+++ projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManagerFactoryFactory.java 2010-07-28 01:34:15 UTC (rev 107129)
@@ -1,144 +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.web.tomcat.service.session.distributedcache.spi;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Factory for obtaining a DistributedCacheManagerFactory.
- *
- * @author Brian Stansberry
- */
-public class DistributedCacheManagerFactoryFactory
-{
- /**
- * Default name of the class that {@link #getDistributedCacheManagerFactory()}
- * will try to instantiate if no factory is injected.
- */
- public static final String DEFAULT_CLASS_NAME = "org.jboss.web.tomcat.service.session.distributedcache.impl.DistributedCacheManagerFactoryImpl";
-
- /** Singleton */
- private static final DistributedCacheManagerFactoryFactory instance = new DistributedCacheManagerFactoryFactory();
-
- /** Gets the singleton instance. */
- public static final DistributedCacheManagerFactoryFactory getInstance()
- {
- return instance;
- }
-
- private DistributedCacheManagerFactory distributedCacheManagerFactory;
- private String factoryClassName = DEFAULT_CLASS_NAME;
-
- /**
- * Returns the factory, creating one if necessary by loading
- * {@link #getFactoryClassName() the factory class} and invoking
- * {@link Class#newInstance()}.
- *
- * @return the factory. Will not return <code>null</code>.
- * @throws ClusteringNotSupportedException if there is a problem instantiating a factory
- */
- public synchronized DistributedCacheManagerFactory getDistributedCacheManagerFactory()
- throws ClusteringNotSupportedException
- {
- if (distributedCacheManagerFactory == null)
- {
- distributedCacheManagerFactory = instantiateFactory();
- factoryClassName = distributedCacheManagerFactory.getClass().getName();
- }
- return distributedCacheManagerFactory;
- }
-
- /**
- * Allows injection of the DistributedCacheManagerFactory.
- *
- * @param distributedCacheManagerFactory the factory.
- */
- public synchronized void setDistributedCacheManagerFactory(DistributedCacheManagerFactory distributedCacheManagerFactory)
- {
- this.distributedCacheManagerFactory = distributedCacheManagerFactory;
- }
-
- /**
- * Gets the class name of the factory; either the name of any existing
- * factory, a class name injected via this property's setter, or
- * {@link #DEFAULT_CLASS_NAME}.
- *
- * @return the factory class name; will not return <code>null</code>
- */
- public synchronized String getFactoryClassName()
- {
- return factoryClassName;
- }
-
- /**
- * Allows injection of the factory class name.
- *
- * @param factoryClassName Fully qualified name of a class that implements
- * {@link DistributedCacheManagerFactory} and exposes
- * a public no-arg constructor.
- */
- public synchronized void setFactoryClassName(String factoryClassName)
- {
- this.factoryClassName = factoryClassName == null ? DEFAULT_CLASS_NAME : factoryClassName;
- }
-
- /**
- * Loads the factory class and instantiates it.
- *
- * @throws ClusteringNotSupportedException
- */
- private DistributedCacheManagerFactory instantiateFactory() throws ClusteringNotSupportedException
- {
- String className = factoryClassName == null ? DEFAULT_CLASS_NAME : factoryClassName;
- ClassLoader cl = getTCCL();
- try
- {
- return (DistributedCacheManagerFactory) cl.loadClass(className).newInstance();
- }
- catch (Exception e)
- {
- throw new ClusteringNotSupportedException("Cannot create " + DistributedCacheManagerFactory.class.getSimpleName(), e);
- }
- }
-
- private ClassLoader getTCCL()
- {
- if (System.getSecurityManager() == null)
- {
- return Thread.currentThread().getContextClassLoader();
- }
- else
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
-
- public ClassLoader run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
- }
-
- private DistributedCacheManagerFactoryFactory() {}
-}
\ No newline at end of file
Deleted: projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/TestDistributedCacheManagerFactoryFactory.java
===================================================================
--- projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/TestDistributedCacheManagerFactoryFactory.java 2010-07-28 01:33:21 UTC (rev 107128)
+++ projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/TestDistributedCacheManagerFactoryFactory.java 2010-07-28 01:34:15 UTC (rev 107129)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc. 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.spi;
-
-/**
- *
- *
- * @author Brian Stansberry
- *
- * @version $Revision$
- */
-public class TestDistributedCacheManagerFactoryFactory
-{
- /**
- * Default name of the class that {@link #getDistributedCacheManagerFactory()}
- * will try to instantiate if no factory is injected.
- */
- public static final String DEFAULT_CLASS_NAME = "org.jboss.web.tomcat.service.session.distributedcache.impl.TestDistributedCacheManagerFactoryImpl";
-
- private final DistributedCacheManagerFactoryFactory delegate = DistributedCacheManagerFactoryFactory.getInstance();
-
- private String factoryClassName = DEFAULT_CLASS_NAME;
-
- /**
- * Gets the class name of the factory; either the name of any existing
- * factory, a class name injected via this property's setter, or
- * {@link #DEFAULT_CLASS_NAME}.
- *
- * @return the factory class name; will not return <code>null</code>
- */
- public synchronized String getFactoryClassName()
- {
- return factoryClassName;
- }
-
- /**
- * Allows injection of the factory class name.
- *
- * @param factoryClassName Fully qualified name of a class that implements
- * {@link DistributedCacheManagerFactory} and exposes
- * a public no-arg constructor.
- */
- public synchronized void setFactoryClassName(String factoryClassName)
- {
- this.factoryClassName = factoryClassName == null ? DEFAULT_CLASS_NAME : factoryClassName;
- }
-
- /**
- * Returns the factory, creating one if necessary by loading
- * {@link #getFactoryClassName() the factory class} and invoking
- * {@link Class#newInstance()}.
- *
- * @return the factory. Will not return <code>null</code>.
- * @throws ClusteringNotSupportedException if there is a problem instantiating a factory
- */
- public synchronized TestDistributedCacheManagerFactory getDistributedCacheManagerFactory(boolean local, String passivationDir,
- boolean totalReplication, boolean marshalling, boolean purgeCacheLoader)
- throws ClusteringNotSupportedException
- {
- String existingClassName = delegate.getFactoryClassName();
- DistributedCacheManagerFactory existing = null;
- try
- {
- try
- {
- // Set the factory class name to something that won't work
- // if it's used to create a factory, and then get the factory.
- // Effect is we only get a factory if it already existed
- delegate.setFactoryClassName("+++Illegal+++");
- existing = delegate.getDistributedCacheManagerFactory();
- delegate.setDistributedCacheManagerFactory(null);
- }
- catch (Throwable ignored) {}
-
- delegate.setFactoryClassName(factoryClassName);
- TestDistributedCacheManagerFactory fact = (TestDistributedCacheManagerFactory) delegate.getDistributedCacheManagerFactory();
- fact.configure(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
- return fact;
- }
- finally
- {
- if (existing != null)
- {
- delegate.setDistributedCacheManagerFactory(existing);
- }
- delegate.setFactoryClassName(existingClassName);
- }
- }
-}
More information about the jboss-cvs-commits
mailing list