001    /*
002     * $Id: ResourceBundleResourcesFactory.java 349025 2005-11-25 21:09:54Z niallp $
003     * $Revision: 349025 $
004     * $Date: 2005-11-25 21:09:54 +0000 (Fri, 25 Nov 2005) $
005     *
006     * ====================================================================
007     *
008     *  Copyright 2003-2005 The Apache Software Foundation
009     *
010     *  Licensed under the Apache License, Version 2.0 (the "License");
011     *  you may not use this file except in compliance with the License.
012     *  You may obtain a copy of the License at
013     *
014     *      http://www.apache.org/licenses/LICENSE-2.0
015     *
016     *  Unless required by applicable law or agreed to in writing, software
017     *  distributed under the License is distributed on an "AS IS" BASIS,
018     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019     *  See the License for the specific language governing permissions and
020     *  limitations under the License.
021     *
022     */
023    
024    package org.apache.commons.resources.impl;
025    
026    import org.apache.commons.resources.Resources;
027    import org.apache.commons.resources.ResourcesException;
028    
029    /**
030     * <p>Concrete implementation of {@link org.apache.commons.resources.ResourcesFactory} that creates
031     * {@link org.apache.commons.resources.Resources} instances that wrap a set (one per Locale) of
032     * <code>java.util.ResourceBundle</code> instances that share a common
033     * base name.  The configuration String that is passed to the
034     * <code>getResources()</code> method must contain the fully qualified
035     * Java name of the underlying <code>ResourceBundle</code> family
036     * that is to be wrapped.</p>
037     */
038    public class ResourceBundleResourcesFactory extends ResourcesFactoryBase {
039        
040    
041        // --------------------------------------------------------- Public Methods
042    
043    
044        // ------------------------------------------------------ Protected Methods
045    
046    
047        /**
048         * <p>Create and return a new {@link org.apache.commons.resources.Resources} instance with the
049         * specified logical name, after calling its <code>init()</code>
050         * method and delegating the relevant properties.</p>
051         *
052         * @param name Logical name of the {@link org.apache.commons.resources.Resources} instance to create
053         * @param config Configuration string for this resource (if any)
054         * @return The new Resources instance.
055         *
056         * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} instance
057         *  of the specified logical name cannot be created.
058         */
059        protected Resources createResources(String name, String config) {
060    
061            Resources res = new ResourceBundleResources(name, config);
062            res.setReturnNull(isReturnNull());
063            res.init();
064            return (res);
065    
066        }
067    
068    
069    }