KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > log > LogConfigurationDataBean


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.core.ejb.log;
15
16 import javax.ejb.CreateException JavaDoc;
17
18 import org.ejbca.core.ejb.BaseEntityBean;
19 import org.ejbca.core.model.log.LogConfiguration;
20 import org.ejbca.core.model.log.LogEntry;
21
22
23
24
25 /**
26  * Entity bean should not be used directly, use though Session beans. Entity Bean representing the
27  * log configuration data. Information stored:
28  * <pre>
29  * Id (Should always be 0)
30  * logConfiguration is the actual log configuration
31  * logentryrownumber is the number of the last row number in the log entry database.
32  * </pre>
33  *
34  * @version $Id: LogConfigurationDataBean.java,v 1.9 2006/11/10 09:29:11 anatom Exp $
35  *
36  * @ejb.bean
37  * description="This enterprise bean entity represents a Log Entry with accompanying data"
38  * display-name="LogConfigurationDataEB"
39  * name="LogConfigurationData"
40  * jndi-name="LogConfigurationData"
41  * view-type="local"
42  * type="CMP"
43  * reentrant="False"
44  * cmp-version="2.x"
45  * transaction-type="Container"
46  * schema="LogConfigurationDataBean"
47  * primkey-field="id"
48  *
49  * @ejb.pk
50  * generate="false"
51  * class="java.lang.Integer"
52  *
53  * @ejb.persistence table-name = "LogConfigurationData"
54  *
55  * @ejb.home
56  * generate="local"
57  * local-extends="javax.ejb.EJBLocalHome"
58  * local-class="org.ejbca.core.ejb.log.LogConfigurationDataLocalHome"
59  *
60  * @ejb.interface
61  * generate="local"
62  * local-extends="javax.ejb.EJBLocalObject"
63  * local-class="org.ejbca.core.ejb.log.LogConfigurationDataLocal"
64  *
65  * @ejb.transaction type="Required"
66  *
67  * @jonas.jdbc-mapping
68  * jndi-name="${datasource.jndi-name}"
69  */

70 public abstract class LogConfigurationDataBean extends BaseEntityBean {
71
72     /**
73      * @ejb.pk-field
74      * @ejb.persistence column-name="id"
75      * @ejb.interface-method view-type="local"
76      */

77     public abstract Integer JavaDoc getId();
78
79     /**
80      */

81     public abstract void setId(Integer JavaDoc id);
82
83     /**
84      * @ejb.persistence column-name="logConfiguration"
85      * @weblogic.ora.columntyp@
86      */

87     public abstract LogConfiguration getLogConfiguration();
88
89     /**
90      */

91     public abstract void setLogConfiguration(LogConfiguration logConfiguration);
92
93     /**
94      * @ejb.persistence column-name="logEntryRowNumber"
95      * @jboss.persistence row-locking="true"
96      */

97     public abstract int getLogEntryRowNumber();
98
99     /**
100      * @ejb.interface-method view-type="local"
101      */

102     public abstract void setLogEntryRowNumber(int logEntryRowNumber);
103
104     /**
105      * DOCUMENT ME!
106      *
107      * @ejb.interface-method view-type="local"
108      */

109     public LogConfiguration loadLogConfiguration() {
110         LogConfiguration logconfiguration = getLogConfiguration();
111
112         // Fill in new information from LogEntry constants.
113
for (int i = 0; i < LogEntry.EVENTNAMES_INFO.length; i++) {
114             if (logconfiguration.getLogEvent(i) == null) {
115                 logconfiguration.setLogEvent(i, true);
116             }
117         }
118
119         for (int i = 0; i < LogEntry.EVENTNAMES_ERROR.length; i++) {
120             int index = i + LogEntry.EVENT_ERROR_BOUNDRARY;
121
122             if (logconfiguration.getLogEvent(index) == null) {
123                 logconfiguration.setLogEvent(index, true);
124             }
125         }
126
127         return logconfiguration;
128     }
129
130     /**
131      * DOCUMENT ME!
132      *
133      * @ejb.interface-method view-type="local"
134      */

135     public void saveLogConfiguration(LogConfiguration logConfiguration) {
136         setLogConfiguration(logConfiguration);
137     }
138
139     /**
140      * DOCUMENT ME!
141      *
142      * @ejb.interface-method view-type="local"
143      * @ejb.transaction type="Required"
144      */

145     public Integer JavaDoc getAndIncrementRowCount() {
146         int returnval = getLogEntryRowNumber();
147         setLogEntryRowNumber(returnval + 1);
148
149         return new Integer JavaDoc(returnval);
150     }
151
152     //
153
// Fields required by Container
154
//
155

156     /**
157      * Entity Bean holding data of log configuration. Create by sending in the id.
158      *
159      * @param id the unique id of logconfiguration (should always be 0).
160      * @param logConfiguration is the serialized representation of the log configuration.
161      *
162      * @return the given id
163      *
164      * @ejb.create-method view-type="local"
165      */

166     public Integer JavaDoc ejbCreate(Integer JavaDoc id, LogConfiguration logConfiguration)
167             throws CreateException JavaDoc {
168         setId(id);
169         setLogConfiguration(logConfiguration);
170         setLogEntryRowNumber(0);
171
172         return null;
173     }
174
175     /**
176      * DOCUMENT ME!
177      *
178      * @param id DOCUMENT ME!
179      * @param logConfiguration DOCUMENT ME!
180      */

181     public void ejbPostCreate(Integer JavaDoc id, LogConfiguration logConfiguration) {
182         // Do nothing. Required.
183
}
184 }
185
Popular Tags