1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 * 26 * ident "%Z%%M% %I% %E% SMI" 27 */ 28 package org.opensolaris.os.dtrace; 29 30 import java.io.Serializable; 31 import java.beans.*; 32 33 /** 34 * A record indicating that the DTrace {@code exit()} action is about to 35 * stop the source {@link Consumer}. The exit status is whatever value 36 * was passed to the {@code exit()} action in the D program. 37 * <p> 38 * Immutable. Supports persistence using {@link java.beans.XMLEncoder}. 39 * 40 * @author Tom Erickson 41 */ 42 public final class ExitRecord implements Record, Serializable { 43 static final long serialVersionUID = -2062716683135961493L; 44 45 static { 46 try { 47 BeanInfo info = Introspector.getBeanInfo(ExitRecord.class); 48 PersistenceDelegate persistenceDelegate = 49 new DefaultPersistenceDelegate( 50 new String[] {"status"}); 51 BeanDescriptor d = info.getBeanDescriptor(); 52 d.setValue("persistenceDelegate", persistenceDelegate); 53 } catch (IntrospectionException e) { 54 System.out.println(e); 55 } 56 } 57 58 /** @serial */ 59 private final int status; 60 61 /** 62 * Creates an exit record with the given status. 63 * 64 * @param exitStatus value passed to the D {@code exit()} action 65 */ 66 public 67 ExitRecord(int exitStatus) 68 { 69 status = exitStatus; 70 } 71 72 /** 73 * Gets the exit status of a DTrace {@link Consumer}. 74 * 75 * @return the value passed to the D {@code exit()} action 76 */ 77 public int 78 getStatus() 79 { 80 return status; 81 } 82 83 /** 84 * Gets a string representation of the exit status. 85 * 86 * @return the string form of {@link #getStatus()} returned by 87 * {@link Integer#toString(int i)} 88 */ 89 public String 90 toString() 91 { 92 return Integer.toString(status); 93 } 94 } 95