1/*2 * $Id: UnresolvingLocaleDefinitionsFactory.java 822631 2009-10-07 09:21:12Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122package org.apache.tiles.definition;
2324import java.util.Locale;
25import java.util.Map;
2627import org.apache.tiles.Definition;
28import org.apache.tiles.TilesApplicationContext;
29import org.apache.tiles.awareness.TilesApplicationContextAware;
30import org.apache.tiles.context.TilesRequestContext;
31import org.apache.tiles.definition.dao.DefinitionDAO;
32import org.apache.tiles.locale.LocaleResolver;
3334/***35 * {@link DefinitionsFactory DefinitionsFactory} implementation that manages36 * Definitions configuration data from URLs, without resolving definition37 * inheritance when a definition is returned.<p/>38 * <p>39 * The Definition objects are read from the40 * {@link org.apache.tiles.definition.digester.DigesterDefinitionsReader DigesterDefinitionsReader}41 * class unless another implementation is specified.42 * </p>43 *44 * @version $Rev: 822631 $ $Date: 2009-10-07 11:21:12 +0200 (mer, 07 ott 2009) $45 * @since 2.2.146 */47publicclassUnresolvingLocaleDefinitionsFactory implements DefinitionsFactory,
48TilesApplicationContextAware {
4950/***51 * The definition DAO that extracts the definitions from the sources.52 *53 * @since 2.2.154 */55protected DefinitionDAO<Locale> definitionDao;
5657/***58 * The application context.59 *60 * @since 2.2.161 */62protected TilesApplicationContext applicationContext;
6364/***65 * The locale resolver object.66 *67 * @since 2.2.168 */69protectedLocaleResolver localeResolver;
7071/*** {@inheritDoc} */72publicvoid setApplicationContext(TilesApplicationContext applicationContext) {
73this.applicationContext = applicationContext;
74 }
7576/***77 * Sets the locale resolver to use.78 *79 * @param localeResolver The locale resolver.80 * @since 2.2.181 */82publicvoid setLocaleResolver(LocaleResolver localeResolver) {
83this.localeResolver = localeResolver;
84 }
8586/***87 * Sets the definition DAO to use. It must be locale-based.88 *89 * @param definitionDao The definition DAO.90 * @since 2.2.191 */92publicvoid setDefinitionDAO(DefinitionDAO<Locale> definitionDao) {
93this.definitionDao = definitionDao;
94 }
9596/*** {@inheritDoc} */97public Definition getDefinition(String name,
98TilesRequestContext tilesContext) {
99 Locale locale = null;
100101if (tilesContext != null) {
102 locale = localeResolver.resolveLocale(tilesContext);
103 }
104105return definitionDao.getDefinition(name, locale);
106 }
107108/*** {@inheritDoc} */109 @Deprecated
110publicvoid addSource(Object source) {
111thrownew UnsupportedOperationException(
112"The addSource method is not supported");
113 }
114115/*** {@inheritDoc} */116 @Deprecated
117publicDefinitions readDefinitions() {
118thrownew UnsupportedOperationException(
119"The readDefinitions method is not supported");
120 }
121122/*** {@inheritDoc} */123 @Deprecated
124publicvoid init(Map<String, String> params) {
125// It's here only for binary compatibility reasons.126 }
127 }