KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfox > test > User2


1 /*
2  * JFox - The most lightweight Java EE Application Server!
3  * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
4  *
5  * JFox is licenced and re-distributable under GNU LGPL.
6  */

7 package jfox.test;
8
9 import org.jfox.framework.annotation.Constant;
10 import org.jfox.framework.annotation.Inject;
11 import org.jfox.framework.annotation.Service;
12 import org.jfox.framework.component.ComponentContext;
13 import org.jfox.framework.component.ComponentUnregistration;
14 import org.jfox.framework.event.ModuleListener;
15 import org.jfox.framework.event.ModuleEvent;
16
17 /**
18  *
19  * @author <a HREF="mailto:jfox.young@gmail.com">Yang Yong</a>
20  */

21 @Service(id="User2")
22 public class User2 implements IUser2, ComponentUnregistration, ModuleListener {
23
24     @Inject(id = "UserManager")
25     IUserManager userMgr;
26
27     @Constant("Yang Yong")
28     private String JavaDoc name = "User1";
29
30     private String JavaDoc password = "*****";
31
32     public User2() {
33     }
34
35     /**
36      * Component 实例化之å?Žçš„回调方法
37      * å?¯ä»¥å?šå®žä¾‹åŒ–之å?Žï¼Œset Property 之å‰?的准备工作
38      *
39      * @param componentContext Component context
40      */

41     public void postContruct(ComponentContext componentContext) {
42         System.out.println("instantiated");
43     }
44
45     /**
46      * Component 属性设置完毕之å?Žçš„回调方法
47      * è´Ÿè´£å?šProperties Set 之å?Žçš„检查工作,以å?Šå?š init æ“?作
48      */

49     public void postInject() {
50         System.out.println("postPropertiesSet");
51         userMgr.addUser(this);
52     }
53
54
55     public boolean preUnregister(ComponentContext context) {
56         userMgr.removeUser(this);
57         return true;
58     }
59
60     public void postUnregister() {
61     }
62
63     public String JavaDoc getName() {
64         return name;
65     }
66
67     public String JavaDoc getPassword() {
68         return password;
69     }
70
71     public void setPassword(String JavaDoc password) {
72         this.password = password;
73     }
74
75     public void moduleChanged(ModuleEvent moduleEvent) {
76         System.out.println("moduleChanged: " + moduleEvent);
77     }
78
79     public static void main(String JavaDoc[] args) {
80
81     }
82 }
83
Popular Tags