1 package com.huahang.tj.app;
2
3 import com.huahang.tj.app.common.*;
4 import com.huahang.tj.app.utils.IteratorUtils;
5
6 import java.util.Date;
7
8
9 public abstract class MenuFactory {
10 private static MenuFactory factory = null;
11 private static Object initLock = new Object();
12 private static String className = "com.huahang.tj.app.database.DbMenuFactory";
13
14 public static MenuFactory getInstance(Authorization authorization) {
15 if (authorization == null) {
16 return null;
17 }
18
19 if (factory == null) {
20 synchronized (initLock) {
21 if (factory == null) {
22 if (className != null) {
23 try {
24 //Load the class and create an instance.
25 Class c = Class.forName(className);
26 factory = (MenuFactory) c.newInstance();
27
28 return factory;
29 } catch (Exception e) {
30 System.err.println("Failed to load Menu class " +
31 className +
32 ". Rotor cannot function normally.");
33 e.printStackTrace();
34
35 return null;
36 }
37 } else {
38 System.err.println("Error: could not create Menu " +
39 "because the Menu classname has not been set. ");
40
41 return null;
42 }
43 }
44 }
45 }
46
47 return factory;
48 }
49
50 public static MenuFactory getInstance() {
51 if (factory == null) {
52 synchronized (initLock) {
53 if (factory == null) {
54 if (className != null) {
55 try {
56 //Load the class and create an instance.
57 Class c = Class.forName(className);
58 factory = (MenuFactory) c.newInstance();
59
60 return factory;
61 } catch (Exception e) {
62 System.err.println("Failed to load Menu class " +
63 className +
64 ". Rotor cannot function normally.");
65 e.printStackTrace();
66
67 return null;
68 }
69 } else {
70 System.err.println("Error: could not create Menu " +
71 "because the Menu classname has not been set. ");
72
73 return null;
74 }
75 }
76 }
77 }
78
79 return factory;
80 }
81
82 /**
83 * 删除 菜单
84 * @param menu_id
85 */
86 public abstract void deleteMenu(long menu_id) throws Exception;
87
88 /**
89 * 添加 菜单
90 * @param menu_name 菜单名称
91 * @param menu_desc 菜单描述
92 * @param menu_link 菜单的连接
93 * @param seq 菜单显示的顺序
94 */
95 public abstract Menu createMenu(String menu_name, String menu_desc,
96 String menu_link, long seq)
97 throws Exception;
98
99 /**
100 * 修改 菜单
101 * @param menu_id 菜单编号
102 * @param menu_name 菜单名称
103 * @param menu_desc 菜单描述
104 * @param menu_link 菜单的连接
105 * @param seq 菜单显示的顺序
106 */
107 public abstract Menu editMenu(long menu_id, String menu_name,
108 String menu_desc, String menu_link, long seq)
109 throws Exception;
110
111 /**
112 * 查询 菜单
113 * @param menu_id
114 */
115 public abstract Menu getMenu(long menu_id) throws Exception;
116
117 /**
118 * 查询多条 菜单
119 */
120 public abstract IteratorUtils queryMenu() throws Exception;
121
122 /**
123 * 查询多条 菜单
124 * @param startIndex 开始位置
125 * @param numResults 返回记录条数
126 */
127 public abstract IteratorUtils queryMenu(int startIndex, int numResults)
128 throws Exception;
129 }