fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee/*
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * CDDL HEADER START
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * The contents of this file are subject to the terms of the
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Common Development and Distribution License (the "License").
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * You may not use this file except in compliance with the License.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * or http://www.opensolaris.org/os/licensing.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * See the License for the specific language governing permissions
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * and limitations under the License.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * When distributing Covered Code, include this CDDL HEADER in each
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * If applicable, add the following below this CDDL HEADER, with the
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * fields enclosed by brackets "[]" replaced with your own identifying
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * information: Portions Copyright [yyyy] [name of copyright owner]
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * CDDL HEADER END
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee/*
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Use is subject to license terms.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ident "%Z%%M% %I% %E% SMI"
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomeepackage org.opensolaris.os.dtrace;
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee/**
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Exception thrown by a {@link ConsumerListener} to terminate a running
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * {@link Consumer}.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @author Tom Erickson
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomeepublic class ConsumerException extends Exception {
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee static final long serialVersionUID = -2125855097525822644L;
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee /** @serial */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee private Object notificationObject;
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee /**
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Creates a consumer exception with the given message.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @see #ConsumerException(String message, Object
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * dtraceNotificationObject)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee public
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee ConsumerException(String message)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee {
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee super(message);
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee }
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee /**
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Creates an exception thrown by a {@link ConsumerListener}
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * implementation to terminate a running {@link Consumer}, usually
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * in response to a drop or an error reported by the native DTrace
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * library. Optionally includes the object reported by the native
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * DTrace library so it can be used by an {@link ExceptionHandler}
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * to display details about why the consumer terminated.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @param message default display message explaining why the
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * consumer was terminated.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @param notification usually the object passed to a {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ConsumerListener} from DTrace that prompted this exception. The
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * notification could be any of the following: <ul> <li>a {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Drop} passed to {@link ConsumerListener#dataDropped(DropEvent e)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * dataDropped()}</li> <li>an {@link Error} passed to {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ConsumerListener#errorEncountered(ErrorEvent e)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * errorEncountered()}</li> <li>a {@link ProcessState} passed to
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * {@link ConsumerListener#processStateChanged(ProcessEvent e)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * processStateChanged()}</li> </ul> or it could be a user-defined
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * object that describes anything unexpected in {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ConsumerListener#dataReceived(DataEvent e) dataReceived()} or
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * that defines an arbitrary error threshold. An {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ExceptionHandler} should be defined to handle any type of
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * notification object set by user code. May be {@code null}.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @see Consumer#go(ExceptionHandler h)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee public
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee ConsumerException(String message, Object notification)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee {
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee super(message);
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee notificationObject = notification;
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee }
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee /**
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Gets the optional object from the {@link ConsumerListener} that
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * communicates to the {@link ExceptionHandler} why the listener
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * threw this exception. Usually this is the object from DTrace
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * (such as an {@link org.opensolaris.os.dtrace.Error Error}) that
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * prompted the exception, simply forwarded to the exception
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * handler.
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee *
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @return an object that communicates to the {@link
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * ExceptionHandler} why the {@link ConsumerListener} threw this
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * exception, may be {@code null}
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @see Consumer#go(ExceptionHandler h)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * @see #ConsumerException(String message,
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee * Object dtraceNotificationObject)
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee */
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee public Object
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee getNotificationObject()
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee {
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee return notificationObject;
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee }
fb3fb4f3d76d55b64440afd0af72775dfad3bd1dtomee}