KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > dozer > util > mapping > ApplicationBeanFactory


1 /*
2  * Copyright 2005-2007 the original author or authors.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 net.sf.dozer.util.mapping;
17
18 import net.sf.dozer.util.mapping.util.MapperConstants;
19
20 import org.springframework.beans.factory.BeanFactory;
21 import org.springframework.beans.factory.access.BeanFactoryLocator;
22 import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
23
24 /**
25  * @author garsombke.franz
26  * @author sullins.ben
27  * @author tierney.matt
28  *
29  */

30 public class ApplicationBeanFactory {
31
32   private static BeanFactoryLocator bfl = ContextSingletonBeanFactoryLocator.getInstance();
33   private static BeanFactory beanFactory = bfl.useBeanFactory(MapperConstants.DEFAULT_BEAN_FACTORY).getFactory();
34   
35   private ApplicationBeanFactory() {}
36
37   public static Object JavaDoc getBean(Class JavaDoc beanClass) {
38     return beanFactory.getBean(beanClass.getName());
39   }
40
41   public static Object JavaDoc getBean(String JavaDoc beanName) {
42     return beanFactory.getBean(beanName);
43   }
44
45
46 }
47
Popular Tags