From jbosscache-commits at lists.jboss.org Mon Feb 23 07:38:59 2009 Content-Type: multipart/mixed; boundary="===============1313415149099295531==" MIME-Version: 1.0 From: jbosscache-commits at lists.jboss.org To: jbosscache-commits at lists.jboss.org Subject: [jbosscache-commits] JBoss Cache SVN: r7755 - core/tags/3.0.3.GA/src/main/java/org/jboss/cache. Date: Mon, 23 Feb 2009 07:38:59 -0500 Message-ID: --===============1313415149099295531== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/DefaultCacheFact= ory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.ja= va 2009-02-23 12:38:05 UTC (rev 7754) +++ core/tags/3.0.3.GA/src/main/java/org/jboss/cache/DefaultCacheFactory.ja= va 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} inte= rface. *

- * 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}. *

* * @author Manik Surtani (manik = AT jboss DOT org) * @see org.jboss.cache.factories.ComponentFactory */ -public class DefaultCacheFactory extends ComponentFactory implements= CacheFactory -{ +public class DefaultCacheFactory extends ComponentFactory implements= CacheFactory { private ClassLoader defaultClassLoader; = = @@ -57,38 +55,37 @@ @SuppressWarnings("unchecked") @Deprecated @Compat - public static CacheFactory getInstance() - { + public static CacheFactory getInstance() { return new DefaultCacheFactory(); } = - public Cache createCache() throws ConfigurationException - { + public Cache createCache() throws ConfigurationException { return createCache(true); } = - public Cache createCache(boolean start) throws ConfigurationExcep= tion - { + public Cache createCache(boolean start) throws ConfigurationExcep= tion { return createCache(new Configuration(), start); } = - public Cache createCache(String configFileName) throws Configurat= ionException - { + public Cache createCache(String configFileName) throws Configurat= ionException { return createCache(configFileName, true); } = - public Cache createCache(String configFileName, boolean start) th= rows ConfigurationException - { + public Cache createCache(String configFileName, boolean start) th= rows ConfigurationException { XmlConfigurationParser parser =3D new XmlConfigurationParser(); Configuration c; - try - { + try { c =3D 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 =3D new XmlConfigurationParser= 2x(); c =3D oldParser.parseFile(configFileName); + if (c !=3D null && log.isInfoEnabled()) + log.info("Detected legacy configuration file format when parsi= ng configuration file. Migrating to the new (3.x) file format is recommend= ed. 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 createCache(Configuration configuration) throws Conf= igurationException - { + public Cache createCache(Configuration configuration) throws Conf= igurationException { return createCache(configuration, true); } = @@ -113,30 +109,24 @@ * @return a cache * @throws ConfigurationException if there are problems with the cfg */ - public Cache createCache(Configuration configuration, boolean sta= rt) throws ConfigurationException - { - try - { + public Cache createCache(Configuration configuration, boolean sta= rt) throws ConfigurationException { + try { CacheSPI cache =3D 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 createAndWire(Configuration configuration) thr= ows Exception - { + protected CacheSPI createAndWire(Configuration configuration) thr= ows Exception { CacheSPI spi =3D new CacheInvocationDelegate(); 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 =3D 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 =3D loader; } = - public Cache createCache(InputStream is) throws ConfigurationExce= ption - { + public Cache createCache(InputStream is) throws ConfigurationExce= ption { XmlConfigurationParser parser =3D new XmlConfigurationParser(); Configuration c =3D null; - try - { + try { c =3D 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 =3D new XmlConfigurationParser= 2x(); c =3D oldParser.parseStream(is); if (c !=3D null && log.isInfoEnabled()) @@ -184,16 +173,14 @@ return createCache(c); } = - public Cache createCache(InputStream is, boolean start) throws Co= nfigurationException - { + public Cache createCache(InputStream is, boolean start) throws Co= nfigurationException { XmlConfigurationParser parser =3D new XmlConfigurationParser(); Configuration c =3D parser.parseStream(is); return createCache(c, start); } = @Override - protected T construct(Class componentType) - { + protected T construct(Class componentType) { throw new UnsupportedOperationException("Should never be invoked - t= his is a bootstrap factory."); } } --===============1313415149099295531==--