| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BeanFactoryResourceLoader |
|
| 2.0;2 |
| 1 | /* | |
| 2 | * Copyright 2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.core.resourceloader; | |
| 17 | ||
| 18 | import javax.xml.namespace.QName; | |
| 19 | ||
| 20 | import org.kuali.rice.core.resourceloader.ResourceLoader; | |
| 21 | import org.springframework.beans.factory.BeanFactory; | |
| 22 | ||
| 23 | ||
| 24 | /** | |
| 25 | * Wraps a {@link BeanFactory} as a {@link ResourceLoader}. | |
| 26 | * | |
| 27 | * Does not start or stop the {@link BeanFactory}. Assumes this is being done | |
| 28 | * by the application that started it. | |
| 29 | * | |
| 30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 31 | * | |
| 32 | */ | |
| 33 | public class BeanFactoryResourceLoader extends BaseResourceLoader { | |
| 34 | ||
| 35 | private BeanFactory beanFactory; | |
| 36 | ||
| 37 | public BeanFactoryResourceLoader(QName name, BeanFactory beanFactory) { | |
| 38 | 0 | super(name); |
| 39 | 0 | this.beanFactory = beanFactory; |
| 40 | 0 | } |
| 41 | ||
| 42 | @Override | |
| 43 | public Object getService(QName serviceName) { | |
| 44 | 0 | if (this.beanFactory.containsBean(serviceName.toString())) { |
| 45 | 0 | Object service = this.beanFactory.getBean(serviceName.toString()); |
| 46 | 0 | return wrap(serviceName, service); |
| 47 | } | |
| 48 | 0 | return super.getService(serviceName); |
| 49 | } | |
| 50 | ||
| 51 | } |