1 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 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 name = "User1"; 29 30 private String password = "*****"; 31 32 public User2() { 33 } 34 35 41 public void postContruct(ComponentContext componentContext) { 42 System.out.println("instantiated"); 43 } 44 45 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 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 } 83 | Popular Tags |