2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.examples.mailreaderjpa;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import javax.faces.model.SelectItem;
23 import org.apache.mailreaderjpa.Protocol;
24 import org.apache.mailreaderjpa.Subscription;
25 import org.apache.mailreaderjpa.User;
26 import org.apache.shale.view.AbstractApplicationBean;
27
28 /***
29 * <p>Application scope bean containing cached domain lists and other
30 * application wide information. In addition, it includes code to bootstrap
31 * the database contents if this is the very first time that newly created
32 * database tables are accessed.</p>
33 */
34 public class Domains extends AbstractApplicationBean {
35
36
37
38
39
40 /***
41 * <p>The business {@link Logic} for this application. This value
42 * will be injected, based on the managed bean configuration.</p>
43 */
44 private Logic logic = null;
45
46
47 /***
48 * <p>Return the business {@link Logic} for this application.</p>
49 */
50 public Logic getLogic() {
51 return this.logic;
52 }
53
54
55 /***
56 * <p>Set the business {@link Logic} for this application.</p>
57 *
58 * @param logic The new business logic instance
59 */
60 public void setLogic(Logic logic) {
61 this.logic = logic;
62 }
63
64
65 /***
66 * <p>The array of <code>SelectItem</code> instances identifying the valid
67 * mail protocols for this application.</p>
68 */
69 private SelectItem[] protocols;
70
71
72 /***
73 * <p>Return an array of select items for valid protocols.</p>
74 */
75 public SelectItem[] getProtocols() {
76
77 return this.protocols;
78
79 }
80
81
82
83
84
85 /***
86 * <p>Initialize the <code>profiles</codes> list from the database. If
87 * necessary, bootstrap the database content if it is completely empty.</p>
88 */
89 public void init() {
90
91 log("Caching application wide static data");
92 try {
93
94
95 getLogic().bootstrap();
96
97
98 List<Protocol> items = getLogic().getProtocols();
99 protocols = new SelectItem[items.size()];
100 int n = 0;
101 for (Protocol item : items) {
102 protocols[n++] = new SelectItem(item, item.getDescription());
103 }
104
105 } catch (Exception e) {
106
107 log("Exception acquiring domain data", e);
108 error("Exception acquiring domain data: " + e);
109 getFacesContext().responseComplete();
110
111 }
112
113
114 }
115
116
117 }