1 /* 2 * JBoss, Home of Professional Open Source 3 * Copyright 2005, JBoss Inc., and individual contributors as indicated 4 * by the @authors tag. See the copyright.txt in the distribution for a 5 * full listing of individual contributors. 6 * 7 * This is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation; either version 2.1 of 10 * the License, or (at your option) any later version. 11 * 12 * This software 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 software; if not, write to the Free 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 21 */ 22 package javax.enterprise.deploy.spi.status; 23 24 import java.util.EventObject; 25 import java.io.ObjectStreamField; 26 import java.io.ObjectOutputStream; 27 import java.io.IOException; 28 import java.io.ObjectInputStream; 29 30 import javax.enterprise.deploy.spi.TargetModuleID; 31 32 import org.jboss.util.id.SerialVersion; 33 34 /** 35 * An event describing the progress of a deployment 36 */ 37 public class ProgressEvent extends EventObject 38 { 39 /** @since 4.0.2 */ 40 static final long serialVersionUID; 41 42 // Constants ----------------------------------------------------- 43 /** 44 * These field names match the j2ee 1.4.1 ri version names 45 */ 46 private static final ObjectStreamField[] serialPersistentFields; 47 private static final int STATUS_IDX = 0; 48 private static final int MODULE_ID_IDX = 1; 49 50 static 51 { 52 if (SerialVersion.version == SerialVersion.LEGACY) 53 { 54 serialVersionUID = 3097551795061550569L; 55 serialPersistentFields = new ObjectStreamField[] { 56 /** @serialField statuscode DeploymentStatus current deployment status */ 57 new ObjectStreamField("status", DeploymentStatus.class), 58 /** @serialField targetModuleID TargetModuleID id of the event target */ 59 new ObjectStreamField("moduleID", TargetModuleID.class) 60 }; 61 } 62 else 63 { 64 // j2ee 1.4.1 RI values 65 serialVersionUID = 7815118532096485937L; 66 serialPersistentFields = new ObjectStreamField[] { 67 /** @serialField statuscode DeploymentStatus current deployment status */ 68 new ObjectStreamField("statuscode", DeploymentStatus.class), 69 /** @serialField targetModuleID TargetModuleID id of the event target */ 70 new ObjectStreamField("targetModuleID", TargetModuleID.class) 71 }; 72 } 73 } 74 75 // Attributes ---------------------------------------------------- 76 77 /** The deployment status */ 78 private DeploymentStatus status; 79 /** The module id */ 80 private TargetModuleID moduleID; 81 82 // Static -------------------------------------------------------- 83 84 // Constructors -------------------------------------------------- 85 86 /** 87 * Create a new progress event 88 * 89 * @param source the source 90 * @param status the deployment status 91 * @param moduleID the module id 92 */ 93 public ProgressEvent(Object source, TargetModuleID moduleID, DeploymentStatus status) 94 { 95 super(source); 96 this.status = status; 97 this.moduleID = moduleID; 98 } 99 100 // Public -------------------------------------------------------- 101 102 /** 103 * Get the target module id 104 * 105 * @return the module id 106 */ 107 public TargetModuleID getTargetModuleID() 108 { 109 return moduleID; 110 } 111 112 /** 113 * Get the deployment status 114 * 115 * @return the deployment status 116 */ 117 public DeploymentStatus getDeploymentStatus() 118 { 119 return status; 120 } 121 122 // Package protected --------------------------------------------- 123 124 // Protected ----------------------------------------------------- 125 126 // Private ------------------------------------------------------- 127 private void readObject(ObjectInputStream ois) 128 throws ClassNotFoundException, IOException 129 { 130 ObjectInputStream.GetField fields = ois.readFields(); 131 String name = serialPersistentFields[STATUS_IDX].getName(); 132 this.status = (DeploymentStatus) fields.get(name, null); 133 name = serialPersistentFields[MODULE_ID_IDX].getName(); 134 this.moduleID = (TargetModuleID) fields.get(name, null); 135 } 136 137 private void writeObject(ObjectOutputStream oos) 138 throws IOException 139 { 140 // Write j2ee 1.4.1 RI field names 141 ObjectOutputStream.PutField fields = oos.putFields(); 142 String name = serialPersistentFields[STATUS_IDX].getName(); 143 fields.put(name, status); 144 name = serialPersistentFields[MODULE_ID_IDX].getName(); 145 fields.put(name, moduleID); 146 oos.writeFields(); 147 } 148 149 // Inner classes ------------------------------------------------- 150 }