Author: manik.surtani(a)jboss.com
Date: 2009-02-23 07:38:59 -0500 (Mon, 23 Feb 2009)
New Revision: 7755
Modified:
core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.java
Log:
Log messages
Modified: core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2009-02-23
12:38:05 UTC (rev 7754)
+++ core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2009-02-23
12:38:59 UTC (rev 7755)
@@ -24,7 +24,6 @@
import org.jboss.cache.annotations.Compat;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.LegacyConfigurationException;
import org.jboss.cache.config.parsing.XmlConfigurationParser;
import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.factories.ComponentFactory;
@@ -37,15 +36,14 @@
/**
* Default implementation of the {@link org.jboss.cache.CacheFactory} interface.
* <p/>
- * This is a special instance of a {@link ComponentFactory} which contains bootstrap
information for the
- * {@link org.jboss.cache.factories.ComponentRegistry}.
+ * This is a special instance of a {@link ComponentFactory} which contains bootstrap
information for the {@link
+ * org.jboss.cache.factories.ComponentRegistry}.
* <p/>
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik
AT jboss DOT org)</a>
* @see org.jboss.cache.factories.ComponentFactory
*/
-public class DefaultCacheFactory<K, V> extends ComponentFactory implements
CacheFactory<K, V>
-{
+public class DefaultCacheFactory<K, V> extends ComponentFactory implements
CacheFactory<K, V> {
private ClassLoader defaultClassLoader;
@@ -57,38 +55,37 @@
@SuppressWarnings("unchecked")
@Deprecated
@Compat
- public static CacheFactory getInstance()
- {
+ public static CacheFactory getInstance() {
return new DefaultCacheFactory();
}
- public Cache<K, V> createCache() throws ConfigurationException
- {
+ public Cache<K, V> createCache() throws ConfigurationException {
return createCache(true);
}
- public Cache<K, V> createCache(boolean start) throws ConfigurationException
- {
+ public Cache<K, V> createCache(boolean start) throws ConfigurationException {
return createCache(new Configuration(), start);
}
- public Cache<K, V> createCache(String configFileName) throws
ConfigurationException
- {
+ public Cache<K, V> createCache(String configFileName) throws
ConfigurationException {
return createCache(configFileName, true);
}
- public Cache<K, V> createCache(String configFileName, boolean start) throws
ConfigurationException
- {
+ public Cache<K, V> createCache(String configFileName, boolean start) throws
ConfigurationException {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c;
- try
- {
+ try {
c = parser.parseFile(configFileName);
}
- catch (ConfigurationException e)
- {
+ catch (ConfigurationException e) {
+ if (log.isTraceEnabled()) {
+ log.trace("Had problems parsing configuration file.", e);
+ log.trace("Attempting to use a legacy parser.");
+ }
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
c = oldParser.parseFile(configFileName);
+ if (c != null && log.isInfoEnabled())
+ log.info("Detected legacy configuration file format when parsing
configuration file. Migrating to the new (3.x) file format is recommended. See FAQs for
details.");
}
return createCache(c, start);
}
@@ -100,8 +97,7 @@
* @return a cache
* @throws ConfigurationException if there are problems with the cfg
*/
- public Cache<K, V> createCache(Configuration configuration) throws
ConfigurationException
- {
+ public Cache<K, V> createCache(Configuration configuration) throws
ConfigurationException {
return createCache(configuration, true);
}
@@ -113,30 +109,24 @@
* @return a cache
* @throws ConfigurationException if there are problems with the cfg
*/
- public Cache<K, V> createCache(Configuration configuration, boolean start)
throws ConfigurationException
- {
- try
- {
+ public Cache<K, V> createCache(Configuration configuration, boolean start)
throws ConfigurationException {
+ try {
CacheSPI<K, V> cache = createAndWire(configuration);
if (start) cache.start();
return cache;
}
- catch (ConfigurationException ce)
- {
+ catch (ConfigurationException ce) {
throw ce;
}
- catch (RuntimeException re)
- {
+ catch (RuntimeException re) {
throw re;
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw new RuntimeException(e);
}
}
- protected CacheSPI<K, V> createAndWire(Configuration configuration) throws
Exception
- {
+ protected CacheSPI<K, V> createAndWire(Configuration configuration) throws
Exception {
CacheSPI<K, V> spi = new CacheInvocationDelegate<K, V>();
bootstrap(spi, configuration);
return spi;
@@ -145,8 +135,7 @@
/**
* Bootstraps this factory with a Configuration and a ComponentRegistry.
*/
- private void bootstrap(CacheSPI spi, Configuration configuration)
- {
+ private void bootstrap(CacheSPI spi, Configuration configuration) {
// injection bootstrap stuff
componentRegistry = new ComponentRegistry(configuration, spi);
componentRegistry.registerDefaultClassLoader(defaultClassLoader);
@@ -161,21 +150,21 @@
*
* @param loader class loader to use as a default.
*/
- public void setDefaultClassLoader(ClassLoader loader)
- {
+ public void setDefaultClassLoader(ClassLoader loader) {
this.defaultClassLoader = loader;
}
- public Cache<K, V> createCache(InputStream is) throws ConfigurationException
- {
+ public Cache<K, V> createCache(InputStream is) throws ConfigurationException {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = null;
- try
- {
+ try {
c = parser.parseStream(is);
}
- catch (ConfigurationException e)
- {
+ catch (ConfigurationException e) {
+ if (log.isTraceEnabled()) {
+ log.trace("Had problems parsing configuration file.", e);
+ log.trace("Attempting to use a legacy parser.");
+ }
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
c = oldParser.parseStream(is);
if (c != null && log.isInfoEnabled())
@@ -184,16 +173,14 @@
return createCache(c);
}
- public Cache<K, V> createCache(InputStream is, boolean start) throws
ConfigurationException
- {
+ public Cache<K, V> createCache(InputStream is, boolean start) throws
ConfigurationException {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = parser.parseStream(is);
return createCache(c, start);
}
@Override
- protected <T> T construct(Class<T> componentType)
- {
+ protected <T> T construct(Class<T> componentType) {
throw new UnsupportedOperationException("Should never be invoked - this is a
bootstrap factory.");
}
}