You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by un...@apache.org on 2003/12/25 14:53:53 UTC

cvs commit: cocoon-2.2/src/java/org/apache/cocoon/i18n BundleFactory.java XMLResourceBundleFactory.java XMLResourceBundle.java

unico       2003/12/25 05:53:53

  Modified:    src/java/org/apache/cocoon/i18n BundleFactory.java
                        XMLResourceBundleFactory.java
                        XMLResourceBundle.java
  Log:
  component -> service
  
  Revision  Changes    Path
  1.4       +12 -13    cocoon-2.2/src/java/org/apache/cocoon/i18n/BundleFactory.java
  
  Index: BundleFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/i18n/BundleFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BundleFactory.java	27 Nov 2003 02:55:50 -0000	1.3
  +++ BundleFactory.java	25 Dec 2003 13:53:53 -0000	1.4
  @@ -52,9 +52,8 @@
   
   import java.util.Locale;
   
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentSelector;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceSelector;
   
   /**
    * Bundle Factory realizations are responsible for loading and providing
  @@ -63,7 +62,7 @@
    * @author <a href="mailto:kpiroumian@apache.org">Konstantin Piroumian</a>
    * @version CVS $Id$
    */
  -public interface BundleFactory extends ComponentSelector {
  +public interface BundleFactory extends ServiceSelector {
   
       String ROLE = BundleFactory.class.getName();
   
  @@ -81,9 +80,9 @@
        * @param name    bundle name
        * @param locale  locale name
        * @return        the bundle
  -     * @exception     ComponentException if a bundle is not found
  +     * @exception     ServiceException if a bundle is not found
        */
  -    Component select(String base, String bundleName, String locale) throws ComponentException;
  +    Bundle select(String base, String bundleName, String locale) throws ServiceException;
   
       /**
        * Select a bundle based on the catalogue base location, bundle name,
  @@ -93,9 +92,9 @@
        * @param name    bundle name
        * @param locale  locale
        * @return        the bundle
  -     * @exception     ComponentException if a bundle is not found
  +     * @exception     ServiceException if a bundle is not found
        */
  -    Component select(String base, String bundleName, Locale locale) throws ComponentException;
  +    Bundle select(String base, String bundleName, Locale locale) throws ServiceException;
   
       /**
        * Select a bundle based on the bundle name and the locale name from
  @@ -104,9 +103,9 @@
        * @param name    bundle name
        * @param locale  locale name
        * @return        the bundle
  -     * @exception     ComponentException if a bundle is not found
  +     * @exception     ServiceException if a bundle is not found
        */
  -    Component select(String bundleName, String locale) throws ComponentException;
  +    Bundle select(String bundleName, String locale) throws ServiceException;
   
       /**
        * Select a bundle based on the bundle name and the locale from
  @@ -115,7 +114,7 @@
        * @param name    bundle name
        * @param locale  locale
        * @return        the bundle
  -     * @exception     ComponentException if a bundle is not found
  +     * @exception     ServiceException if a bundle is not found
        */
  -    Component select(String bundleName, Locale locale) throws ComponentException;
  +    Bundle select(String bundleName, Locale locale) throws ServiceException;
   }
  
  
  
  1.7       +25 -27    cocoon-2.2/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java
  
  Index: XMLResourceBundleFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/i18n/XMLResourceBundleFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLResourceBundleFactory.java	6 Dec 2003 21:22:09 -0000	1.6
  +++ XMLResourceBundleFactory.java	25 Dec 2003 13:53:53 -0000	1.7
  @@ -57,19 +57,17 @@
   import java.util.Map;
   
   import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  -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.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.service.DefaultServiceSelector;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.excalibur.source.SourceNotFoundException;
  -
   import org.xml.sax.SAXParseException;
   
   /**
  @@ -82,8 +80,8 @@
    * @author <a href="mailto:kpiroumian@apache.org">Konstantin Piroumian</a>
    * @version CVS $Id$
    */
  -public class XMLResourceBundleFactory extends DefaultComponentSelector
  -        implements BundleFactory, Composable, Configurable, Disposable, ThreadSafe, LogEnabled {
  +public class XMLResourceBundleFactory extends DefaultServiceSelector
  +        implements BundleFactory, Serviceable, Configurable, Disposable, ThreadSafe, LogEnabled {
   
       /** Should we load bundles to cache on startup or not? */
       protected boolean cacheAtStartup = false;
  @@ -97,8 +95,8 @@
       /** The logger */
       private Logger logger;
   
  -    /** Component Manager */
  -    protected ComponentManager manager = null;
  +    /** Service Manager */
  +    protected ServiceManager manager = null;
   
   
       /** Default constructor. */
  @@ -116,12 +114,12 @@
           return this.logger;
       }
   
  -    public void compose(ComponentManager manager) {
  +    public void service(ServiceManager manager) {
           this.manager = manager;
       }
   
       public void dispose() {
  -        Iterator i = getComponentMap().values().iterator();
  +        Iterator i = getObjectMap().values().iterator();
           while (i.hasNext()) {
               Object bundle = i.next();
               if (bundle instanceof Disposable) {
  @@ -183,7 +181,7 @@
        * @return        the bundle
        * @exception     ComponentException if a bundle is not found
        */
  -    public Component select(String name, String locale) throws ComponentException {
  +    public Bundle select(String name, String locale) throws ServiceException {
           return select(getDirectory(), name, locale);
       }
   
  @@ -195,7 +193,7 @@
        * @return        the bundle
        * @exception     ComponentException if a bundle is not found
        */
  -    public Component select(String name, Locale locale) throws ComponentException {
  +    public Bundle select(String name, Locale locale) throws ServiceException {
           return select(getDirectory(), name, locale);
       }
   
  @@ -209,7 +207,7 @@
        * @return        the bundle
        * @exception     ComponentException if a bundle is not found
        */
  -    public Component select(String directory, String name, String localeName) throws ComponentException {
  +    public Bundle select(String directory, String name, String localeName) throws ServiceException {
           return select(directory, name, new Locale(localeName, localeName));
       }
   
  @@ -223,10 +221,10 @@
        * @return        the bundle
        * @exception     ComponentException if a bundle is not found
        */
  -    public Component select(String directory, String name, Locale locale) throws ComponentException {
  -        Component bundle = _select(directory, name, locale, this.cacheAtStartup);
  +    public Bundle select(String directory, String name, Locale locale) throws ServiceException {
  +        Bundle bundle = _select(directory, name, locale, this.cacheAtStartup);
           if (bundle == null) {
  -            throw new ComponentException(name, "Unable to locate resource: " + name);
  +            throw new ServiceException(name, "Unable to locate resource: " + name);
           }
           return bundle;
       }
  @@ -239,7 +237,7 @@
        * @param locale            locale
        * @return                  the bundle
        */
  -    protected Component selectParent(String name, Locale locale) {
  +    protected Object selectParent(String name, Locale locale) {
           return _select(getDirectory(), name, getParentLocale(locale), this.cacheAtStartup);
       }
   
  @@ -252,7 +250,7 @@
        * @param cacheAtStartup    cache all the keys when constructing?
        * @return                  the bundle
        */
  -    private Component _select(String base, String name, Locale locale, boolean cacheAtStartup) {
  +    private Bundle _select(String base, String name, Locale locale, boolean cacheAtStartup) {
           String fileName = getFileName(base, name, locale);
           XMLResourceBundle bundle = (XMLResourceBundle)selectCached(fileName);
           if (bundle == null && !isNotFoundBundle(fileName)) {
  @@ -301,7 +299,7 @@
               }
               bundle = new XMLResourceBundle();
               bundle.enableLogging(logger);
  -            bundle.compose(this.manager);
  +            bundle.service(this.manager);
               bundle.init(name, fileName, locale, parentBundle, cacheAtStartup);
               return bundle;
           } catch (FileNotFoundException fe) {
  @@ -319,7 +317,7 @@
           return null;
       }
   
  -    public void release(Component component) {
  +    public void release(Object component) {
           // Do nothing
       }
   
  @@ -391,14 +389,14 @@
        * @param fileName          file name of the bundle
        * @return                  the cached bundle; null, if not found
        */
  -    protected Component selectCached(String fileName) {
  -        Component bundle = null;
  +    protected Object selectCached(String fileName) {
  +        Object bundle = null;
           try {
  -            bundle = super.select(fileName);
  +            bundle = select(fileName);
               if (getLogger().isDebugEnabled()) {
                   getLogger().debug("Returning from cache: " + fileName);
               }
  -        } catch (ComponentException e) {
  +        } catch (ServiceException e) {
               if (getLogger().isDebugEnabled()) {
                   getLogger().debug("Not found in cache: " + fileName);
               }
  
  
  
  1.4       +6 -10     cocoon-2.2/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
  
  Index: XMLResourceBundle.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLResourceBundle.java	27 Nov 2003 02:51:58 -0000	1.3
  +++ XMLResourceBundle.java	25 Dec 2003 13:53:53 -0000	1.4
  @@ -62,20 +62,16 @@
   import javax.xml.parsers.DocumentBuilderFactory;
   import javax.xml.parsers.ParserConfigurationException;
   
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.logger.Logger;
  -
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.xml.xpath.XPathProcessor;
  -
   import org.w3c.dom.Document;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  -
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  @@ -117,7 +113,7 @@
       protected XMLResourceBundle parent = null;
   
       /** Component Manager */
  -    protected ComponentManager manager = null;
  +    protected ServiceManager manager = null;
   
       /** XPath Processor */
       private XPathProcessor processor = null;
  @@ -129,7 +125,7 @@
        * @param manager The <code>ComponentManager</code> instance
        * @throws ComponentException if XPath processor is not found
        */
  -    public void compose(ComponentManager manager) throws ComponentException {
  +    public void service(ServiceManager manager) throws ServiceException {
           this.manager = manager;
           this.processor = (XPathProcessor) this.manager.lookup(XPathProcessor.ROLE);
       }
  @@ -138,7 +134,7 @@
        * Implements Disposable interface for this class.
        */
       public void dispose() {
  -        this.manager.release((Component) this.processor);
  +        this.manager.release(this.processor);
           this.processor = null;
       }