1 /*
2 * $Id: TestDbTilesContainerFactory.java 891411 2009-12-16 20:06:48Z apetrelli $
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 package org.apache.tiles.test.db;
23
24 import java.util.Locale;
25
26 import javax.sql.DataSource;
27
28 import org.apache.tiles.definition.LocaleDefinitionsFactory;
29 import org.apache.tiles.definition.dao.DefinitionDAO;
30 import org.apache.tiles.factory.BasicTilesContainerFactory;
31 import org.apache.tiles.locale.LocaleResolver;
32 import org.apache.tiles.request.ApplicationContext;
33
34
35 /**
36 * Test alternate Tiles container factory that uses a DB to store definitions.
37 *
38 * @version $Rev: 891411 $ $Date: 2009-12-17 07:06:48 +1100 (Thu, 17 Dec 2009) $
39 */
40 public class TestDbTilesContainerFactory extends BasicTilesContainerFactory {
41
42 /** {@inheritDoc} */
43 @Override
44 protected DefinitionDAO<Locale> createLocaleDefinitionDao(ApplicationContext applicationContext,
45 LocaleResolver resolver) {
46 LocaleDbDefinitionDAO definitionDao = new LocaleDbDefinitionDAO();
47 definitionDao.setDataSource((DataSource) applicationContext
48 .getApplicationScope().get("dataSource"));
49 return definitionDao;
50 }
51
52 /** {@inheritDoc} */
53 @Override
54 protected LocaleDefinitionsFactory instantiateDefinitionsFactory(
55 ApplicationContext applicationContext, LocaleResolver resolver) {
56 return new LocaleDefinitionsFactory();
57 }
58 }