1096N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1096N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1096N/A *
1096N/A * This code is free software; you can redistribute it and/or modify it
1096N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
1096N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
1096N/A *
1096N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1096N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1096N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1096N/A * version 2 for more details (a copy is included in the LICENSE file that
1096N/A * accompanied this code).
1096N/A *
1096N/A * You should have received a copy of the GNU General Public License version
1096N/A * 2 along with this work; if not, write to the Free Software Foundation,
1096N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1096N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1096N/A */
1096N/Apackage com.sun.nio.sctp;
1096N/A
1096N/A/**
1096N/A * A skeletal handler that consumes notifications and continues.
1096N/A *
1096N/A * <P> This class trivially implements the {@code handleNotification} methods to
1096N/A * return {@link HandlerResult#CONTINUE CONTINUE} so that all notifications are
1096N/A * consumed and the channel continues to try and receive a message.
1096N/A *
1096N/A * <P> It also provides overloaded versions of the {@code handleNotification}
1096N/A * methods, one for each of the required supported notification types, {@link
1096N/A * AssociationChangeNotification}, {@link PeerAddressChangeNotification},
1096N/A * {@link SendFailedNotification}, and {@link ShutdownNotification}. The
1096N/A * appropriate method will be invoked when the notification is received.
1096N/A *
1096N/A * @since 1.7
1096N/A */
1096N/Apublic class AbstractNotificationHandler<T>
1096N/A implements NotificationHandler<T>
1096N/A{
1096N/A /**
1096N/A * Initializes a new instance of this class.
1096N/A */
1096N/A protected AbstractNotificationHandler() {}
1096N/A
1096N/A /**
1096N/A * Invoked when an implementation specific notification is received from the
1096N/A * SCTP stack.
1096N/A *
1096N/A * @param notification
1096N/A * The notification
1096N/A *
1096N/A * @param attachment
1096N/A * The object attached to the {@code receive} operation when it was
1096N/A * initiated.
1096N/A *
1096N/A * @return The handler result
1096N/A */
1096N/A @Override
1096N/A public HandlerResult handleNotification(Notification notification,
1096N/A T attachment) {
1096N/A return HandlerResult.CONTINUE;
1096N/A }
1096N/A
1096N/A /**
1096N/A * Invoked when an {@link AssociationChangeNotification} is received from
1096N/A * the SCTP stack.
1096N/A *
1096N/A * @param notification
1096N/A * The notification
1096N/A *
1096N/A * @param attachment
1096N/A * The object attached to the {@code receive} operation when it was
1096N/A * initiated.
1096N/A *
1096N/A * @return The handler result
1096N/A */
1096N/A public HandlerResult handleNotification(AssociationChangeNotification notification,
1096N/A T attachment) {
1096N/A return HandlerResult.CONTINUE;
1096N/A }
1096N/A
1096N/A /**
1096N/A * Invoked when an {@link PeerAddressChangeNotification} is received from
1096N/A * the SCTP stack.
1096N/A *
1096N/A * @param notification
1096N/A * The notification
1096N/A *
1096N/A * @param attachment
1096N/A * The object attached to the {@code receive} operation when it was
1096N/A * initiated.
1096N/A *
1096N/A * @return The handler result
1096N/A */
1096N/A public HandlerResult handleNotification(PeerAddressChangeNotification notification,
1096N/A T attachment) {
1096N/A return HandlerResult.CONTINUE;
1096N/A }
1096N/A
1096N/A /**
1096N/A * Invoked when an {@link SendFailedNotification} is received from
1096N/A * the SCTP stack.
1096N/A *
1096N/A * @param notification
1096N/A * The notification
1096N/A *
1096N/A * @param attachment
1096N/A * The object attached to the {@code receive} operation when it was
1096N/A * initiated.
1096N/A *
1096N/A * @return The handler result
1096N/A */
1096N/A public HandlerResult handleNotification(SendFailedNotification notification,
1096N/A T attachment) {
1096N/A return HandlerResult.CONTINUE;
1096N/A }
1096N/A
1096N/A /**
1096N/A * Invoked when an {@link ShutdownNotification} is received from
1096N/A * the SCTP stack.
1096N/A *
1096N/A * @param notification
1096N/A * The notification
1096N/A *
1096N/A * @param attachment
1096N/A * The object attached to the {@code receive} operation when it was
1096N/A * initiated.
1096N/A *
1096N/A * @return The handler result
1096N/A */
1096N/A public HandlerResult handleNotification(ShutdownNotification notification,
1096N/A T attachment) {
1096N/A return HandlerResult.CONTINUE;
1096N/A }
1096N/A}