@@ -0,0 +1,1200 @@
+package cc.young.contacts.model2;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport cc.young.contacts.actions.Action;%0Aimport cc.young.contacts.actions.AddContactAction;%0Aimport cc.young.contacts.actions.BootstrapAction;%0Aimport cc.young.contacts.actions.LoginAction;%0Aimport cc.young.contacts.actions.LogoutAction;%0Aimport cc.young.contacts.actions.RemoveContactAction;%0A%0A%0Apublic class ActionFactory %7B%0A%09protected Map map = defaultMap();%0A%09%0A%09public ActionFactory() %7B%0A%09%09super();%0A%09%7D%0A%09public Action create(String actionName) %7B%0A%09%09Class klass = (Class) map.get(actionName);%0A%09%09if (klass == null)%0A%09%09%09throw new RuntimeException(getClass() + %22 was unable to find an action named '%22 + actionName + %22'.%22);%0A%09%09%0A%09%09Action actionInstance = null;%0A%09%09try %7B%0A%09%09%09actionInstance = (Action) klass.newInstance();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09%09return actionInstance;%0A%09%7D%0A%09protected Map defaultMap() %7B%0A%09%09Map map = new HashMap();%0A%0A%09%09map.put(%22index%22, BootstrapAction.class);%0A%09%09map.put(%22addContactAction%22, AddContactAction.class);%0A%09%09map.put(%22removeContactAction%22, RemoveContactAction.class);%0A%09%09map.put(%22loginAction%22, LoginAction.class);%0A%09%09map.put(%22logoutAction%22, LogoutAction.class);%0A%0A%09%09return map;%0A%09%7D%0A%7D%0A

Create ActionFactory.java