Coverage Report - org.apache.tiles.request.velocity.render.ApplicationContextJeeConfig
 
Classes in this File Line Coverage Branch Coverage Complexity
ApplicationContextJeeConfig
100%
9/9
N/A
1
 
 1  
 /*
 2  
  * $Id: ApplicationContextJeeConfig.java 1306435 2012-03-28 15:39:11Z 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.request.velocity.render;
 22  
 
 23  
 import java.util.Collections;
 24  
 import java.util.Enumeration;
 25  
 import java.util.HashMap;
 26  
 import java.util.Map;
 27  
 
 28  
 import javax.servlet.ServletContext;
 29  
 
 30  
 import org.apache.tiles.request.ApplicationContext;
 31  
 import org.apache.tiles.request.servlet.ServletUtil;
 32  
 import org.apache.velocity.tools.view.JeeConfig;
 33  
 
 34  
 /**
 35  
  * Implements JeeConfig to use parameters set through
 36  
  * {@link VelocityRenderer#setParameter(String, String)}.
 37  
  *
 38  
  * @version $Rev: 1306435 $ $Date: 2012-03-29 02:39:11 +1100 (Thu, 29 Mar 2012) $
 39  
  */
 40  
 public class ApplicationContextJeeConfig implements JeeConfig {
 41  
 
 42  
     /**
 43  
      * The application context.
 44  
      */
 45  
     private ApplicationContext applicationContext;
 46  
 
 47  
     /**
 48  
      * The initialization parameters for VelocityView.
 49  
      */
 50  
     private Map<String, String> params;
 51  
 
 52  
     /**
 53  
      * Constructor.
 54  
      *
 55  
      * @param applicationContext The application context.
 56  
      * @param params Configuration parameters.
 57  
      */
 58  5
     public ApplicationContextJeeConfig(ApplicationContext applicationContext, Map<String, String> params) {
 59  5
         this.applicationContext = applicationContext;
 60  5
         this.params = new HashMap<String, String>(params);
 61  5
     }
 62  
 
 63  
     /** {@inheritDoc} */
 64  
     public String getInitParameter(String name) {
 65  1
         return params.get(name);
 66  
     }
 67  
 
 68  
     /** {@inheritDoc} */
 69  
     public String findInitParameter(String key) {
 70  1
         return params.get(key);
 71  
     }
 72  
 
 73  
     /** {@inheritDoc} */
 74  
     public Enumeration<String> getInitParameterNames() {
 75  1
         return Collections.enumeration(params.keySet());
 76  
     }
 77  
 
 78  
     /** {@inheritDoc} */
 79  
     public String getName() {
 80  1
         return "Application Context JEE Config";
 81  
     }
 82  
 
 83  
     /** {@inheritDoc} */
 84  
     public ServletContext getServletContext() {
 85  1
         return ServletUtil.getServletContext(applicationContext);
 86  
     }
 87  
 }