001    /*
002     * $Id: JDBCResourcesFactory.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 
031     * {@link org.apache.commons.resources.ResourcesFactory} that creates
032     * {@link org.apache.commons.resources.Resources} instances that wraps 
033     * a JDBC database connection and retrieves values for the given 
034     * <code>Locale</code> and have name suffixes reflecting the 
035     * <code>Locale</code> for which the document's messages apply.
036     * For this specific implementation, resources are looked up in 
037     * a hierarchy of database values in a manner identical to that 
038     * performed by <code>java.util.ResourceBundle.getBundle().</code>.
039     *
040     * @author James Mitchell
041     * @version $Revision: 349025 $
042     */
043    public class JDBCResourcesFactory extends ResourcesFactoryBase {
044    
045    
046        // ------------------------------------------------------ Protected Methods
047    
048    
049        /**
050         * <p>Create and return a new {@link org.apache.commons.resources.Resources} 
051         * instance with the specified logical name, after calling its <code>init()</code>
052         * method and delegating the relevant properties.</p>
053         *
054         * @param name Logical name of the {@link org.apache.commons.resources.Resources} 
055         * instance to create
056         * 
057         * @param config Configuration string for this resource (if any)
058         * @return The new Resources instance.
059         *
060         * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} 
061         * instance of the specified logical name cannot be created.
062         */
063        protected Resources createResources(String name, String config) {
064    
065            Resources res = new JDBCResources(name, config);
066            res.setReturnNull(isReturnNull());
067            res.init();
068            return (res);
069    
070        }
071    
072    
073    }