KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > deployment > xml > JonasRunAsMapping


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  *
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or 1any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  *
22  * Initial developer: Florent Benoit
23  * --------------------------------------------------------------------------
24  * $Id: JonasRunAsMapping.java,v 1.1 2004/07/01 09:52:35 benoitf Exp $
25  * --------------------------------------------------------------------------
26  */

27 package org.objectweb.jonas_ejb.deployment.xml;
28
29 import org.objectweb.jonas_lib.deployment.xml.AbsElement;
30 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
31
32 /**
33  * This class defines the implementation of the element jonas-run-as-mapping It
34  * defines mapping between principal and list of roles
35  * @author Florent Benoit
36  */

37
38 public class JonasRunAsMapping extends AbsElement {
39
40     /**
41      * principal name
42      */

43     private String JavaDoc principalName = null;
44
45     /**
46      * role names
47      */

48     private JLinkedList roleNamesList = null;
49
50     /**
51      * Constructor
52      */

53     public JonasRunAsMapping() {
54         super();
55         roleNamesList = new JLinkedList("role-name");
56     }
57
58     /**
59      * Gets the role-name
60      * @return the role-name
61      */

62     public JLinkedList getRoleNamesList() {
63         return roleNamesList;
64     }
65
66     /**
67      * Add a new role-name element to this object
68      * @param roleName the name of the role
69      */

70     public void addRoleName(String JavaDoc roleName) {
71         roleNamesList.add(roleName);
72     }
73
74     /**
75      * @return the principal Name.
76      */

77     public String JavaDoc getPrincipalName() {
78         return principalName;
79     }
80
81     /**
82      * Sets the principal name
83      * @param principalName name of the principal to set.
84      */

85     public void setPrincipalName(String JavaDoc principalName) {
86         this.principalName = principalName;
87     }
88
89     /**
90      * Represents this element by it's XML description.
91      * @param indent use this indent for prexifing XML representation.
92      * @return the XML description of this object.
93      */

94     public String JavaDoc toXML(int indent) {
95         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
96         sb.append(indent(indent));
97         sb.append("<jonas-run-as-mapping>\n");
98
99         indent += 2;
100
101         // principal-name
102
sb.append(xmlElement(principalName, "principal-name", indent));
103
104         // role-name
105
sb.append(roleNamesList.toXML(indent));
106
107         indent -= 2;
108         sb.append(indent(indent));
109         sb.append("</jonas-run-as-mapping>\n");
110
111         return sb.toString();
112     }
113 }
Popular Tags