KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > RoleReference


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment;
24
25 import com.sun.enterprise.deployment.Role;
26 import com.sun.enterprise.deployment.web.SecurityRoleReference;
27 import com.sun.enterprise.deployment.web.SecurityRole;
28
29 /**
30  * Special kind of environment property that encapsulates the primitive roles
31  * as defined by the bean developer. The name of a primitive role will appear
32  * in the bean code, the value will be mapped to the name of a Role chosen by
33  * the application assembler which is referenced by the EjbBundle being
34  * assembled.
35  * @author Danny Coward
36  */

37
38 public class RoleReference extends EnvironmentProperty implements
39         SecurityRoleReference
40 {
41     /**
42      * Default constructor.
43      */

44     public RoleReference() {
45     }
46
47     /**
48      * Construct a role reference from the given name and description.
49      */

50     public RoleReference(String JavaDoc name, String JavaDoc description) {
51     super(name, "", description);
52     }
53     
54     /**
55      * Construct the role reference with the same name and rolename the same
56      * as the environment property value.
57      * @param the environment property instance.
58      */

59     public RoleReference(EnvironmentProperty environmentProperty) {
60     super(environmentProperty.getName(),
61         environmentProperty.getDescription(), "");
62     this.setValue(environmentProperty.getValue());
63     }
64     
65     /**
66      * Set the value for the reference.
67      * @param the role
68      */

69     void setRole(Role role) {
70     super.setValue(role.getName());
71     }
72     
73     /**
74      * Return the role object from this descriptor.
75      * @return the role.
76      */

77     public Role getRole() {
78     return new Role(super.getValue());
79     }
80     
81     /**
82      * Return the rolename.
83      * @return the role name.
84      */

85     public SecurityRole getSecurityRoleLink() {
86     return new SecurityRoleDescriptor(super.getValue(), "");
87     }
88     
89     /**
90      * Sets the rolename.
91      * @param the rolename.
92      */

93     public void setSecurityRoleLink(SecurityRole securityRole) {
94     super.setValue(securityRole.getName());
95     }
96     
97     /**
98      * Return the coded name.
99      * @return the role name used in the bean code.
100      */

101     public String JavaDoc getRolename() {
102     return this.getName();
103     }
104     
105     /**
106      * Sets the coded name.
107      * @param the role name used in the bean code.
108      */

109     public void setRolename(String JavaDoc rolename) {
110     this.setName(rolename);
111     }
112     
113     /**
114      * Returns a formatted version of this object as a String.
115      */

116     public void print(StringBuffer JavaDoc toStringBuffer) {
117     toStringBuffer.append("Role-Ref-Env-Prop: ").append(super.getName()).append("@").append(
118         this.getRole()).append("@").append(super.getDescription());
119     }
120
121 }
122
123
Popular Tags