Coverage Report - org.kuali.rice.student.core.web.context.RiceWebApplicationContextProxy
 
Classes in this File Line Coverage Branch Coverage Complexity
RiceWebApplicationContextProxy
0%
0/45
0%
0/4
1.054
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.rice.student.core.web.context;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.lang.annotation.Annotation;
 20  
 import java.util.LinkedHashMap;
 21  
 import java.util.Locale;
 22  
 import java.util.Map;
 23  
 
 24  
 import javax.servlet.ServletContext;
 25  
 
 26  
 import org.springframework.beans.BeansException;
 27  
 import org.springframework.beans.factory.BeanFactory;
 28  
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 29  
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 30  
 import org.springframework.context.ApplicationContext;
 31  
 import org.springframework.context.ApplicationEvent;
 32  
 import org.springframework.context.MessageSourceResolvable;
 33  
 import org.springframework.context.NoSuchMessageException;
 34  
 import org.springframework.core.annotation.AnnotationUtils;
 35  
 import org.springframework.core.env.Environment;
 36  
 import org.springframework.core.io.Resource;
 37  
 import org.springframework.web.context.WebApplicationContext;
 38  
 
 39  0
 public class RiceWebApplicationContextProxy implements WebApplicationContext {
 40  
     
 41  
     private ApplicationContext applicationContext;
 42  
     private ServletContext servletContext;
 43  
 
 44  
 
 45  
     public void setApplicationContext(ApplicationContext applicationContext) {
 46  0
         this.applicationContext = applicationContext;
 47  0
     }
 48  
     
 49  
     public void setServletContext(ServletContext servletContext) {
 50  0
         this.servletContext = servletContext;
 51  0
     }
 52  
     
 53  
     @Override
 54  
     public boolean containsBean(String name) {
 55  0
         return applicationContext.containsBean(name);
 56  
     }
 57  
 
 58  
     @Override
 59  
     public boolean containsBeanDefinition(String beanName) {
 60  0
         return applicationContext.containsBeanDefinition(beanName);
 61  
     }
 62  
 
 63  
     @Override
 64  
     public boolean containsLocalBean(String name) {
 65  0
         return applicationContext.containsLocalBean(name);
 66  
     }
 67  
 
 68  
     @Override
 69  
     public String[] getAliases(String name) {
 70  0
         return applicationContext.getAliases(name);
 71  
     }
 72  
 
 73  
     @Override
 74  
     public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
 75  0
         return applicationContext.getAutowireCapableBeanFactory();
 76  
     }
 77  
 
 78  
     @Override
 79  
     public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
 80  0
         return applicationContext.getBean(name, requiredType);
 81  
     }
 82  
 
 83  
     @Override
 84  
     public Object getBean(String name, Object[] args) throws BeansException {
 85  0
         return applicationContext.getBean(name, args);
 86  
     }
 87  
 
 88  
     @Override
 89  
     public Object getBean(String name) throws BeansException {
 90  0
         return applicationContext.getBean(name);
 91  
     }
 92  
 
 93  
     @Override
 94  
     public int getBeanDefinitionCount() {
 95  0
         return applicationContext.getBeanDefinitionCount();
 96  
     }
 97  
 
 98  
     @Override
 99  
     public String[] getBeanDefinitionNames() {
 100  0
         return applicationContext.getBeanDefinitionNames();
 101  
     }
 102  
 
 103  
     @Override
 104  
     public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) {
 105  0
         return applicationContext.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
 106  
     }
 107  
 
 108  
     @Override
 109  
     public String[] getBeanNamesForType(Class type) {
 110  0
         return applicationContext.getBeanNamesForType(type);
 111  
     }
 112  
 
 113  
     @Override
 114  
     public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException {
 115  0
         return applicationContext.getBeansOfType(type, includeNonSingletons, allowEagerInit);
 116  
     }
 117  
 
 118  
     @Override
 119  
     public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException {
 120  0
         return applicationContext.getBeansOfType(type);
 121  
     }
 122  
 
 123  
     @Override
 124  
     public ClassLoader getClassLoader() {
 125  0
         return applicationContext.getClassLoader();
 126  
     }
 127  
 
 128  
     @Override
 129  
     public String getDisplayName() {
 130  0
         return applicationContext.getDisplayName();
 131  
     }
 132  
 
 133  
     @Override
 134  
     public String getId() {
 135  0
         return applicationContext.getId();
 136  
     }
 137  
 
 138  
     @Override
 139  
     public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
 140  0
         return applicationContext.getMessage(resolvable, locale);
 141  
     }
 142  
 
 143  
     @Override
 144  
     public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
 145  0
         return applicationContext.getMessage(code, args, locale);
 146  
     }
 147  
 
 148  
     @Override
 149  
     public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
 150  0
         return applicationContext.getMessage(code, args, defaultMessage, locale);
 151  
     }
 152  
 
 153  
     @Override
 154  
     public ApplicationContext getParent() {
 155  0
         return applicationContext.getParent();
 156  
     }
 157  
 
 158  
     @Override
 159  
     public BeanFactory getParentBeanFactory() {
 160  0
         return applicationContext.getParentBeanFactory();
 161  
     }
 162  
 
 163  
     @Override
 164  
     public Resource getResource(String location) {
 165  0
         return applicationContext.getResource(location);
 166  
     }
 167  
 
 168  
     @Override
 169  
     public Resource[] getResources(String locationPattern) throws IOException {
 170  0
         return applicationContext.getResources(locationPattern);
 171  
     }
 172  
 
 173  
     @Override
 174  
     public ServletContext getServletContext() {
 175  0
         return this.servletContext;
 176  
     }
 177  
 
 178  
     @Override
 179  
     public long getStartupDate() {
 180  0
         return applicationContext.getStartupDate();
 181  
     }
 182  
 
 183  
     @Override
 184  
     public Class getType(String name) throws NoSuchBeanDefinitionException {
 185  0
         return applicationContext.getType(name);
 186  
     }
 187  
 
 188  
     @Override
 189  
     public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
 190  0
         return applicationContext.isPrototype(name);
 191  
     }
 192  
 
 193  
     @Override
 194  
     public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
 195  0
         return applicationContext.isSingleton(name);
 196  
     }
 197  
 
 198  
     @Override
 199  
     public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException {
 200  0
         return applicationContext.isTypeMatch(name, targetType);
 201  
     }
 202  
 
 203  
     @Override
 204  
     public void publishEvent(ApplicationEvent event) {
 205  0
         applicationContext.publishEvent(event);
 206  0
     }
 207  
 
 208  
     /*
 209  
      * Stolen from SimpleJndiBeanFactory
 210  
      * TODO - is there a refactor candidacy here?
 211  
      */
 212  
         @Override
 213  
         public <T> T getBean(Class<T> requiredType) throws BeansException {
 214  0
                 return getBean(requiredType.getSimpleName(), requiredType);
 215  
         }
 216  
         
 217  
     /*
 218  
      * Adapted from StaticListableBeanFactory
 219  
      * TODO - is there a refactor candidacy here?
 220  
      */
 221  
         @Override
 222  
         public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws BeansException {
 223  
 
 224  0
                 Map<String, Object> results = new LinkedHashMap<String, Object>();
 225  0
                 for (String beanName : this.applicationContext.getBeanDefinitionNames()) {
 226  0
                         if (findAnnotationOnBean(beanName, annotationType) != null) {
 227  0
                                 results.put(beanName, getBean(beanName));
 228  
                         }
 229  
                 }
 230  0
                 return results;
 231  
         }
 232  
         
 233  
     /*
 234  
      * Stolen from StaticListableBeanFactory
 235  
      * TODO - is there a refactor candidacy here?
 236  
      */
 237  
         @Override
 238  
         public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
 239  0
                 return AnnotationUtils.findAnnotation(getType(beanName), annotationType);
 240  
         }
 241  
 
 242  
     @Override
 243  
     public Environment getEnvironment() {
 244  0
         return applicationContext.getEnvironment();
 245  
     }
 246  
 }