This project has retired. For details please refer to its Attic page.
TestTilesContainerFactory xref
View Javadoc

1   /*
2    * $Id: TestTilesContainerFactory.java 1297705 2012-03-06 20:44:30Z nlebas $
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  package org.apache.tiles.test.factory;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.tiles.TilesContainer;
27  import org.apache.tiles.evaluator.AttributeEvaluatorFactory;
28  import org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory;
29  import org.apache.tiles.request.ApplicationContext;
30  import org.apache.tiles.request.ApplicationResource;
31  import org.apache.tiles.request.render.BasicRendererFactory;
32  import org.apache.tiles.test.renderer.ReverseStringRenderer;
33  
34  
35  /**
36   * Test Tiles container factory to customize Tiles behaviour.
37   *
38   * @version $Rev: 1297705 $ $Date: 2012-03-07 07:44:30 +1100 (Wed, 07 Mar 2012) $
39   */
40  public class TestTilesContainerFactory extends CompleteAutoloadTilesContainerFactory {
41  
42      /** {@inheritDoc} */
43      @Override
44      protected void registerAttributeRenderers(
45              BasicRendererFactory rendererFactory,
46              ApplicationContext applicationContext,
47              TilesContainer container,
48              AttributeEvaluatorFactory attributeEvaluatorFactory) {
49          super.registerAttributeRenderers(rendererFactory, applicationContext, container,
50                  attributeEvaluatorFactory);
51          ReverseStringRenderer renderer = new ReverseStringRenderer();
52          rendererFactory.registerRenderer("reversed", renderer);
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
58          List<ApplicationResource> urls = new ArrayList<ApplicationResource>();
59          urls.addAll(applicationContext
60                  .getResources("/WEB-INF/**/tiles-defs*.xml"));
61          urls.add(applicationContext.getResource(
62                  "classpath:/org/apache/tiles/classpath-defs.xml"));
63          urls.add(applicationContext.getResource(
64                  "classpath:/org/apache/tiles/freemarker-classpath-defs.xml"));
65          urls.add(applicationContext.getResource(
66              "classpath:/org/apache/tiles/velocity-classpath-defs.xml"));
67          return urls;
68      }
69  }