KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > spring > Component2FactoryBean


1 package jfun.yan.spring;
2
3 import jfun.yan.Component;
4 import jfun.yan.Container;
5
6 import org.springframework.beans.factory.FactoryBean;
7
8 /**
9  * This class adapts a yan Component to Spring's FactoryBean.
10  * <p>
11  * @author Ben Yu
12  * Nov 16, 2005 11:38:31 PM
13  */

14 public class Component2FactoryBean implements FactoryBean {
15   private final Container yan;
16   private final Component cc;
17   
18   /**
19    * Create a Component2FactoryBean object.
20    * @param cc the component.
21    * @param yan the yan Container object.
22    */

23   Component2FactoryBean(Component cc, Container yan) {
24     this.cc = cc;
25     this.yan = yan;
26   }
27
28   /**
29    * Instantiate the component.
30    */

31   public Object JavaDoc getObject() throws Exception JavaDoc {
32     return yan.instantiateComponent(cc);
33   }
34
35   /**
36    * Get the static type of the component.
37    */

38   public Class JavaDoc getObjectType() {
39     return cc.getType();
40   }
41
42   public boolean isSingleton() {
43     return cc.isSingleton();
44   }
45
46   /**
47    * Get the component in this object.
48    */

49   public Component getComponent() {
50     return cc;
51   }
52
53   /**
54    * Get the container in this object.
55    */

56   public Container getContainer() {
57     return yan;
58   }
59   
60 }
61
Popular Tags