001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management.relation;
023:
024: import java.io.IOException;
025: import java.io.ObjectInputStream;
026: import java.io.ObjectOutputStream;
027: import java.io.ObjectStreamField;
028: import java.io.Serializable;
029:
030: import org.jboss.mx.util.Serialization;
031:
032: /**
033: * Represents the result of multiple access to roles.
034: *
035: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
036: * @version $Revision: 57200 $
037: *
038: * <p><b>Revisions:</b>
039: * <p><b>20020716 Adrian Brock:</b>
040: * <ul>
041: * <li> Serialization
042: * </ul>
043: */
044: public class RoleResult implements Serializable {
045: // Attributes ----------------------------------------------------
046:
047: /**
048: * The successful roles
049: */
050: private RoleList roleList;
051:
052: /**
053: * The unresolved roles.
054: */
055: private RoleUnresolvedList unresolvedRoleList;
056:
057: // Static --------------------------------------------------------
058:
059: private static final long serialVersionUID;
060: private static final ObjectStreamField[] serialPersistentFields;
061:
062: static {
063: switch (Serialization.version) {
064: case Serialization.V1R0:
065: serialVersionUID = 3786616013762091099L;
066: serialPersistentFields = new ObjectStreamField[] {
067: new ObjectStreamField("myRoleList", RoleList.class),
068: new ObjectStreamField("myRoleUnresList",
069: RoleUnresolvedList.class) };
070: break;
071: default:
072: serialVersionUID = -6304063118040985512L;
073: serialPersistentFields = new ObjectStreamField[] {
074: new ObjectStreamField("roleList", RoleList.class),
075: new ObjectStreamField("unresolvedRoleList",
076: RoleUnresolvedList.class) };
077: }
078: }
079:
080: // Constructors --------------------------------------------------
081:
082: /**
083: * Construct a new role result.
084: *
085: * @param roleList the successful roles
086: * @param roleUnresolvedList the roles not accessed
087: */
088: public RoleResult(RoleList roleList,
089: RoleUnresolvedList roleUnresolvedList) {
090: this .roleList = roleList;
091: this .unresolvedRoleList = roleUnresolvedList;
092: }
093:
094: // Public ---------------------------------------------------------
095:
096: /**
097: * Retrieve the successful roles.
098: *
099: * @return the successful roles.
100: */
101: public RoleList getRoles() {
102: return roleList;
103: }
104:
105: /**
106: * Retrieve the unsuccessful roles.
107: *
108: * @return the unsuccessful roles.
109: */
110: public RoleUnresolvedList getRolesUnresolved() {
111: return unresolvedRoleList;
112: }
113:
114: /**
115: * Set the successful roles.
116: *
117: * @param roleList the successful roles.
118: */
119: public void setRoles(RoleList roleList) {
120: this .roleList = roleList;
121: }
122:
123: /**
124: * Set the unsuccessful roles.
125: *
126: * @param roleUnresolvedList the unsuccessful roles.
127: */
128: public void setRolesUnresolved(RoleUnresolvedList roleUnresolvedList) {
129: this .unresolvedRoleList = roleUnresolvedList;
130: }
131:
132: // Object overrides --------------------------------------------
133:
134: public String toString() {
135: StringBuffer buffer = new StringBuffer("Resolved Roles:\n");
136: buffer.append(roleList);
137: buffer.append("\nUnresolved Roles\n");
138: buffer.append(unresolvedRoleList);
139: return buffer.toString();
140: }
141:
142: // Private -----------------------------------------------------
143:
144: private void readObject(ObjectInputStream ois) throws IOException,
145: ClassNotFoundException {
146: switch (Serialization.version) {
147: case Serialization.V1R0:
148: ObjectInputStream.GetField getField = ois.readFields();
149: roleList = (RoleList) getField.get("myRoleList", null);
150: unresolvedRoleList = (RoleUnresolvedList) getField.get(
151: "myRoleUnresList", null);
152: break;
153: default:
154: ois.defaultReadObject();
155: }
156: }
157:
158: private void writeObject(ObjectOutputStream oos) throws IOException {
159: switch (Serialization.version) {
160: case Serialization.V1R0:
161: ObjectOutputStream.PutField putField = oos.putFields();
162: putField.put("myRoleList", roleList);
163: putField.put("myRoleUnresList", unresolvedRoleList);
164: oos.writeFields();
165: break;
166: default:
167: oos.defaultWriteObject();
168: }
169: }
170: }
|