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