2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A *
2N/A * ident "%Z%%M% %I% %E% SMI"
2N/A */
2N/Apackage org.opensolaris.os.dtrace;
2N/A
2N/Aimport java.io.*;
2N/Aimport java.util.EventObject;
2N/A
2N/A/**
2N/A * Notification that the state of a target process designated by {@link
2N/A * Consumer#createProcess(String command)} or {@link
2N/A * Consumer#grabProcess(int pid)} has changed.
2N/A *
2N/A * @see ConsumerListener#processStateChanged(ProcessEvent e)
2N/A *
2N/A * @author Tom Erickson
2N/A */
2N/Apublic class ProcessEvent extends EventObject {
2N/A static final long serialVersionUID = -3779443761929558702L;
2N/A
2N/A /** @serial */
2N/A private ProcessState processState;
2N/A
2N/A /**
2N/A * Creates a {@link ConsumerListener#processStateChanged(ProcessEvent e)
2N/A * processStateChanged()} event to notify listeners of a process
2N/A * state change.
2N/A *
2N/A * @param source the {@link Consumer} that is the source of this event
2N/A * @throws NullPointerException if the given process state is {@code
2N/A * null}
2N/A */
2N/A public
2N/A ProcessEvent(Object source, ProcessState p)
2N/A {
2N/A super(source);
2N/A processState = p;
2N/A validate();
2N/A }
2N/A
2N/A private final void
2N/A validate()
2N/A {
2N/A if (processState == null) {
2N/A throw new NullPointerException("process state is null");
2N/A }
2N/A }
2N/A
2N/A /**
2N/A * Gets the process state.
2N/A *
2N/A * @return non-null process state
2N/A */
2N/A public ProcessState
2N/A getProcessState()
2N/A {
2N/A return processState;
2N/A }
2N/A
2N/A private void
2N/A readObject(ObjectInputStream s)
2N/A throws IOException, ClassNotFoundException
2N/A {
2N/A s.defaultReadObject();
2N/A // check invariants
2N/A try {
2N/A validate();
2N/A } catch (Exception e) {
2N/A InvalidObjectException x = new InvalidObjectException(
2N/A e.getMessage());
2N/A x.initCause(e);
2N/A throw x;
2N/A }
2N/A }
2N/A
2N/A /**
2N/A * Gets a string representation of this event useful for logging and
2N/A * not intended for display. The exact details of the
2N/A * representation are unspecified and subject to change, but the
2N/A * following format may be regarded as typical:
2N/A * <pre><code>
2N/A * class-name[property1 = value1, property2 = value2]
2N/A * </code></pre>
2N/A */
2N/A public String
2N/A toString()
2N/A {
2N/A StringBuilder buf = new StringBuilder();
2N/A buf.append(ProcessEvent.class.getName());
2N/A buf.append("[source = ");
2N/A buf.append(getSource());
2N/A buf.append(", processState = ");
2N/A buf.append(processState);
2N/A buf.append(']');
2N/A return buf.toString();
2N/A }
2N/A}