You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by bl...@apache.org on 2001/10/31 21:46:06 UTC

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test DefaultBundleLoaderTestCase.java XmlBundleTestCase.java

bloritsch    01/10/31 12:46:06

  Modified:    src/scratchpad/org/apache/avalon/excalibur/i18n
                        BundleSelector.java
               src/scratchpad/org/apache/avalon/excalibur/i18n/test
                        DefaultBundleLoaderTestCase.java
                        XmlBundleTestCase.java
  Log:
  remove logging dependencies
  
  Revision  Changes    Path
  1.3       +16 -30    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/BundleSelector.java
  
  Index: BundleSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/BundleSelector.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BundleSelector.java	2001/10/31 19:56:47	1.2
  +++ BundleSelector.java	2001/10/31 20:46:05	1.3
  @@ -13,12 +13,11 @@
   import java.util.LinkedList;
   import java.util.Locale;
   
  -import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.excalibur.component.ExcaliburComponentSelector;
   import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.DefaultComponentSelector;
  -import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.Loggable;
  @@ -30,12 +29,11 @@
    *
    * @author <a href="mailto:neeme@one.lv">Neeme Praks</a>
    * @author <a href="mailto:mengelhart@earthtrip.com">Mike Engelhart</a>
  - * @version $Id: BundleSelector.java,v 1.2 2001/10/31 19:56:47 neeme Exp $
  + * @version $Id: BundleSelector.java,v 1.3 2001/10/31 20:46:05 bloritsch Exp $
    */
   
   public class BundleSelector
  -    extends DefaultComponentSelector
  -    implements Configurable, Loggable, ThreadSafe, Composable
  +    extends ExcaliburComponentSelector
   {
   
       /**
  @@ -62,18 +60,6 @@
       /** the default loader */
       private BundleLoader defaultLoader;
   
  -    /** The logger */
  -    protected Logger logger;
  -
  -    /**
  -     * Set the logger.
  -     *
  -     * @param logger the logger
  -     */
  -    public void setLogger(final Logger logger) {
  -        this.logger = logger;
  -    }
  -
       /**
        * Configure the component.
        *
  @@ -83,7 +69,7 @@
           Configuration[] loaderConfs = configuration.getChild("loaders").getChildren("loader");
           for (int i = 0; i < loaderConfs.length; i++) {
               BundleLoader loader = (BundleLoader) getInstance(loaderConfs[i].getAttribute("class"));
  -            if (loader instanceof Loggable) ((Loggable)loader).setLogger(logger);
  +            if (loader instanceof Loggable) ((Loggable)loader).setLogger(getLogger());
               try {
                   if (loader instanceof Composable) ((Composable)loader).compose(this.manager);
               }
  @@ -151,18 +137,18 @@
        * @exception ComponentException if a bundle is not found
        */
       private Component select(BundleInfo bundleInfo) {
  -        if (logger.isDebugEnabled()) logger.debug("_getBundle: " + bundleInfo);
  +        if (getLogger().isDebugEnabled()) getLogger().debug("_getBundle: " + bundleInfo);
           Bundle bundle = (Bundle) selectCached(bundleInfo);
           if (bundle == null && !isNotFoundBundle(bundleInfo)) {
  -            if (logger.isDebugEnabled()) logger.debug("not found in cache, loading: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("not found in cache, loading: " + bundleInfo);
               synchronized(this) {
                   bundle = (Bundle) selectCached(bundleInfo);
                   if (bundle == null && !isNotFoundBundle(bundleInfo)) {
  -                    if (logger.isDebugEnabled()) logger.debug("synchronized: not found in cache, loading: " + bundleInfo);
  +                    if (getLogger().isDebugEnabled()) getLogger().debug("synchronized: not found in cache, loading: " + bundleInfo);
                       bundle = loadBundle(bundleInfo);
                       BundleInfo parentBundleInfo = bundleInfo.getParent();
                       while (bundle == null && parentBundleInfo != null) {
  -                        if (logger.isDebugEnabled()) logger.debug("synchronized: still not found, trying parent: " + parentBundleInfo);
  +                        if (getLogger().isDebugEnabled()) getLogger().debug("synchronized: still not found, trying parent: " + parentBundleInfo);
                           bundle = loadBundle(parentBundleInfo);
                           updateCache(parentBundleInfo, bundle);
                           parentBundleInfo = parentBundleInfo.getParent();
  @@ -198,10 +184,10 @@
           Component bundle = null;
           try {
               bundle = super.select(bundleInfo);
  -            if (logger.isDebugEnabled()) logger.debug("Returning from cache: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Returning from cache: " + bundleInfo);
           }
           catch (ComponentException e) {
  -            if (logger.isDebugEnabled()) logger.debug("Not found in cache: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Not found in cache: " + bundleInfo);
           }
           return bundle;
       }
  @@ -216,10 +202,10 @@
       protected boolean isNotFoundBundle(BundleInfo bundleInfo) {
           BundleInfo result = (BundleInfo)(cacheNotFound.get(bundleInfo));
           if (result != null) {
  -            if (logger.isDebugEnabled()) logger.debug("Returning from not_found_cache: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Returning from not_found_cache: " + bundleInfo);
           }
           else {
  -            if (logger.isDebugEnabled()) logger.debug("Not found in not_found_cache: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Not found in not_found_cache: " + bundleInfo);
           }
           return result != null;
       }
  @@ -233,12 +219,12 @@
        */
       protected void updateCache(BundleInfo bundleInfo, Bundle bundle) {
           if (bundle == null) {
  -            if (logger.isDebugEnabled()) logger.debug("Updating not_found_cache: " + bundleInfo);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Updating not_found_cache: " + bundleInfo);
               cacheNotFound.put(bundleInfo, bundleInfo);
           }
           else {
  -            if (logger.isDebugEnabled()) logger.debug("Updating cache: " + bundleInfo);
  -            super.put((Object) bundleInfo, (Component) bundle);
  +            if (getLogger().isDebugEnabled()) getLogger().debug("Updating cache: " + bundleInfo);
  +            super.addComponentInstance(bundleInfo, (Component) bundle);
           }
       }
   
  
  
  
  1.2       +6 -1      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/DefaultBundleLoaderTestCase.java
  
  Index: DefaultBundleLoaderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/DefaultBundleLoaderTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultBundleLoaderTestCase.java	2001/10/31 19:56:47	1.1
  +++ DefaultBundleLoaderTestCase.java	2001/10/31 20:46:05	1.2
  @@ -19,7 +19,7 @@
   
   /**
    * @author <a href="mailto:neeme@one.lv">Neeme Praks</a>
  - * @version $Id: DefaultBundleLoaderTestCase.java,v 1.1 2001/10/31 19:56:47 neeme Exp $
  + * @version $Id: DefaultBundleLoaderTestCase.java,v 1.2 2001/10/31 20:46:05 bloritsch Exp $
    */
   public class DefaultBundleLoaderTestCase extends ExcaliburTestCase {
   
  @@ -31,6 +31,11 @@
   
       public void setUp() throws Exception {
           this.bundleSelector = (BundleSelector) manager.lookup(BundleSelector.ROLE);
  +    }
  +
  +    public void tearDown() throws Exception {
  +        manager.release(this.bundleSelector);
  +        this.bundleSelector = null;
       }
   
       public void testLoading() throws Exception {
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.java
  
  Index: XmlBundleTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/test/XmlBundleTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XmlBundleTestCase.java	2001/10/31 19:56:47	1.1
  +++ XmlBundleTestCase.java	2001/10/31 20:46:06	1.2
  @@ -16,7 +16,7 @@
   
   /**
    * @author <a href="mailto:neeme@one.lv">Neeme Praks</a>
  - * @version $Id: XmlBundleTestCase.java,v 1.1 2001/10/31 19:56:47 neeme Exp $
  + * @version $Id: XmlBundleTestCase.java,v 1.2 2001/10/31 20:46:06 bloritsch Exp $
    */
   public class XmlBundleTestCase extends ExcaliburTestCase {
   
  @@ -36,7 +36,7 @@
   
           this.bundle.setBundleInfo(new BundleInfo("test", null));
           this.bundle.setLogger(getLogger());
  -        this.bundle.compose(super.manager);
  +        this.bundle.compose(this.manager);
           this.bundle.setLoadOnInit(true);
           this.bundleWithRoot.setUseRootElement(false);
           this.bundle.init(this.getClass().getClassLoader().getResource(bundleFileName).openStream());
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>