001 /*
002 * $Id: XMLResourcesFactory.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 family (one per Locale) of
032 * XML documents that share a base URL and have name suffices reflecting
033 * the Locale for which the document's messages apply. Resources are
034 * looked up in a hierarchy of documents in a manner identical to that
035 * performed by <code>java.util.ResourceBundle.getBundle()</code>.</p>
036 *
037 * <p>The configuration variable passed to the <code>createResources()</code>
038 * method must be the URL of the base name of the XML document family.
039 * For example, if the configuration URL is passed as
040 * <code>http://localhost/foo/Bar</code>, the resources for the
041 * <code>en_US</code> Locale would be stored under URL
042 * <code>http://localhost/foo/Bar_en_US.xml</code>, and the default
043 * resources would be stored in
044 * <code>http://localhost/foo/Bar.xml</code>.</p>
045 */
046 public class XMLResourcesFactory extends ResourcesFactoryBase {
047
048 /**
049 * <p>Create and return a new {@link org.apache.commons.resources.Resources} instance with the
050 * specified logical name, after calling its <code>init()</code>
051 * method and delegating the relevant properties.</p>
052 *
053 * @param name Logical name of the {@link org.apache.commons.resources.Resources} instance to create
054 * @param config Configuration string for this resource (if any)
055 * @return The new Resources instance.
056 *
057 * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} instance
058 * of the specified logical name cannot be created.
059 */
060 protected Resources createResources(String name, String config) {
061
062 Resources res = new XMLResources(name, config);
063 res.setReturnNull(isReturnNull());
064 res.init();
065 return (res);
066
067 }
068
069
070 }