01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package jfox.test;
08:
09: 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,
23: ModuleListener {
24:
25: @Inject(id="UserManager")
26: IUserManager userMgr;
27:
28: @Constant("Yang Yong")
29: private String name = "User1";
30:
31: private String password = "*****";
32:
33: public User2() {
34: }
35:
36: /**
37: * Component 实例化之�的回调方法
38: * �以�实例化之�,set Property 之�的准备工作
39: *
40: * @param componentContext Component context
41: */
42: public void postContruct(ComponentContext componentContext) {
43: System.out.println("instantiated");
44: }
45:
46: /**
47: * Component 属性设置完毕之�的回调方法
48: * 负责�Properties Set 之�的检查工作,以�� init �作
49: */
50: public void postInject() {
51: System.out.println("postPropertiesSet");
52: userMgr.addUser(this );
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 getName() {
64: return name;
65: }
66:
67: public String getPassword() {
68: return password;
69: }
70:
71: public void setPassword(String 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[] args) {
80:
81: }
82: }
|