View Javadoc

1   /*
2    * $Id: JDBCResourcesFactory.java 349025 2005-11-25 21:09:54Z niallp $
3    * $Revision: 349025 $
4    * $Date: 2005-11-25 21:09:54 +0000 (Fri, 25 Nov 2005) $
5    *
6    * ====================================================================
7    *
8    *  Copyright 2003-2005 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   *
22   */
23  
24  package org.apache.commons.resources.impl;
25  
26  import org.apache.commons.resources.Resources;
27  import org.apache.commons.resources.ResourcesException;
28  
29  /**
30   * <p>Concrete implementation of 
31   * {@link org.apache.commons.resources.ResourcesFactory} that creates
32   * {@link org.apache.commons.resources.Resources} instances that wraps 
33   * a JDBC database connection and retrieves values for the given 
34   * <code>Locale</code> and have name suffixes reflecting the 
35   * <code>Locale</code> for which the document's messages apply.
36   * For this specific implementation, resources are looked up in 
37   * a hierarchy of database values in a manner identical to that 
38   * performed by <code>java.util.ResourceBundle.getBundle().</code>.
39   *
40   * @author James Mitchell
41   * @version $Revision: 349025 $
42   */
43  public class JDBCResourcesFactory extends ResourcesFactoryBase {
44  
45  
46      // ------------------------------------------------------ Protected Methods
47  
48  
49      /**
50       * <p>Create and return a new {@link org.apache.commons.resources.Resources} 
51       * instance with the specified logical name, after calling its <code>init()</code>
52       * method and delegating the relevant properties.</p>
53       *
54       * @param name Logical name of the {@link org.apache.commons.resources.Resources} 
55       * instance to create
56       * 
57       * @param config Configuration string for this resource (if any)
58       * @return The new Resources instance.
59       *
60       * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} 
61       * instance of the specified logical name cannot be created.
62       */
63      protected Resources createResources(String name, String config) {
64  
65          Resources res = new JDBCResources(name, config);
66          res.setReturnNull(isReturnNull());
67          res.init();
68          return (res);
69  
70      }
71  
72  
73  }