KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > authorization > AuthorizationTreeUpdateDataBean


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.authorization;
15
16 import javax.ejb.CreateException JavaDoc;
17
18 import org.ejbca.core.ejb.BaseEntityBean;
19
20
21 /** Entity bean should not be used directly, use though Session beans.
22  *
23  * Entity Bean representing accessrules in EJBCA authorization module
24  * Information stored:
25  * <pre>
26  * Access rule
27  * rule (accept of decline)
28  * isrecursive
29  *
30  * </pre>
31  *
32  * @ejb.bean
33  * description="This enterprise bean entity represents an access rule"
34  * display-name="AuthorizationTreeUpdateDataEB"
35  * name="AuthorizationTreeUpdateData"
36  * jndi-name="AuthorizationTreeUpdateData"
37  * view-type="local"
38  * type="CMP"
39  * reentrant="False"
40  * cmp-version="2.x"
41  * transaction-type="Container"
42  * schema="AuthorizationTreeUpdateDataBean"
43  * primkey-field="primKey"
44  *
45  * @ejb.pk
46  * generate="false"
47  * class="java.lang.Integer"
48  *
49  * @ejb.persistence table-name = "AuthorizationTreeUpdateData"
50  *
51  * @ejb.transaction type="Required"
52  *
53  * @ejb.home
54  * generate="local"
55  * local-extends="javax.ejb.EJBLocalHome"
56  * local-class="org.ejbca.core.ejb.authorization.AuthorizationTreeUpdateDataLocalHome"
57  *
58  * @ejb.interface
59  * generate="local"
60  * local-extends="javax.ejb.EJBLocalObject"
61  * local-class="org.ejbca.core.ejb.authorization.AuthorizationTreeUpdateDataLocal"
62  *
63  */

64 public abstract class AuthorizationTreeUpdateDataBean extends BaseEntityBean
65 {
66     public static final Integer JavaDoc AUTHORIZATIONTREEUPDATEDATA = new Integer JavaDoc(1);
67
68     /**
69      * @ejb.persistence column-name="pK"
70      * @ejb.pk-field
71      */

72     public abstract Integer JavaDoc getPrimKey();
73     public abstract void setPrimKey(Integer JavaDoc primKey);
74
75     /**
76      * Method returning the newest authorizationtreeupdatenumber. Should be used after each
77      * time the authorization tree is built.
78      *
79      * @return the newest accessruleset number.
80      * @ejb.persistence column-name="authorizationTreeUpdateNumber"
81      * @ejb.interface-method
82      */

83     public abstract int getAuthorizationTreeUpdateNumber();
84
85     /**
86      */

87     public abstract void setAuthorizationTreeUpdateNumber(int authorizationtreeupdatenumber);
88
89     /**
90      * @ejb.create-method
91      */

92     public Integer JavaDoc ejbCreate() throws CreateException JavaDoc {
93       setPrimKey(AUTHORIZATIONTREEUPDATEDATA);
94       setAuthorizationTreeUpdateNumber(0);
95       return null;
96     }
97
98     public void ejbPostCreate() {
99         // Do nothing. Required method.
100
}
101
102      /**
103      * Method used check if a reconstruction of authorization tree is needed in the
104      * authorization beans. It is used to avoid desyncronisation of authorization structures
105      * in a distibuted environment.
106      *
107      * @param currentauthorizationtreeupdatenumber indicates which authorizationtreeupdatenumber is currently used.
108      * @return true if update is needed.
109      * @ejb.interface-method
110      */

111     public boolean updateNeccessary(int currentauthorizationtreeupdatenumber){
112       return getAuthorizationTreeUpdateNumber() != currentauthorizationtreeupdatenumber;
113     } // updateNeccessary
114

115
116      /**
117      * Method incrementing the authorizationtreeupdatenumber and thereby signaling
118      * to other beans that they should reconstruct their accesstrees.
119      * @ejb.interface-method
120      */

121     public void incrementAuthorizationTreeUpdateNumber(){
122       setAuthorizationTreeUpdateNumber(getAuthorizationTreeUpdateNumber() +1);
123     } // incrementAuthorizationTreeUpdateNumber
124

125 }
126
Popular Tags