KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > factory > impl > SpringFactory


1 package com.coldcore.coloradoftp.factory.impl;
2
3 import com.coldcore.coloradoftp.factory.InternalFactory;
4 import org.springframework.beans.factory.BeanFactory;
5 import org.springframework.beans.factory.xml.XmlBeanFactory;
6 import org.springframework.core.io.ByteArrayResource;
7 import org.springframework.core.io.InputStreamResource;
8 import org.springframework.core.io.Resource;
9
10 import java.io.InputStream JavaDoc;
11
12 /**
13  * Object factory based on the Spring framework.
14  * @see com.coldcore.coloradoftp.factory.ObjectFactory
15  */

16 public class SpringFactory implements InternalFactory {
17
18   protected BeanFactory beanFactory;
19
20
21   public SpringFactory(Resource resource) {
22     beanFactory = new XmlBeanFactory(resource);
23   }
24
25
26   public SpringFactory(BeanFactory beanFactory) {
27     if (beanFactory == null) throw new IllegalArgumentException JavaDoc("Bean factory is not set");
28     this.beanFactory = beanFactory;
29   }
30
31
32   public Object JavaDoc getBean(String JavaDoc name) {
33     return beanFactory.getBean(name);
34   }
35 }
36
Popular Tags