1 /* 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package com.sun.nio.sctp; 26 27 /** 28 * A skeletal handler that consumes notifications and continues. 29 * 30 * <P> This class trivially implements the {@code handleNotification} methods to 31 * return {@link HandlerResult#CONTINUE CONTINUE} so that all notifications are 32 * consumed and the channel continues to try and receive a message. 33 * 34 * <P> It also provides overloaded versions of the {@code handleNotification} 35 * methods, one for each of the required supported notification types, {@link 36 * AssociationChangeNotification}, {@link PeerAddressChangeNotification}, 37 * {@link SendFailedNotification}, and {@link ShutdownNotification}. The 38 * appropriate method will be invoked when the notification is received. 39 * 40 * @since 1.7 41 */ 42 public class AbstractNotificationHandler<T> 43 implements NotificationHandler<T> 44 { 45 /** 46 * Initializes a new instance of this class. 47 */ 48 protected AbstractNotificationHandler() {} 49 50 /** 51 * Invoked when an implementation specific notification is received from the 52 * SCTP stack. 53 * 54 * @param notification 55 * The notification 56 * 57 * @param attachment 58 * The object attached to the {@code receive} operation when it was 59 * initiated. 60 * 61 * @return The handler result 62 */ 63 @Override 64 public HandlerResult handleNotification(Notification notification, 65 T attachment) { 66 return HandlerResult.CONTINUE; 67 } 68 69 /** 70 * Invoked when an {@link AssociationChangeNotification} is received from 71 * the SCTP stack. 72 * 73 * @param notification 74 * The notification 75 * 76 * @param attachment 77 * The object attached to the {@code receive} operation when it was 78 * initiated. 79 * 80 * @return The handler result 81 */ 82 public HandlerResult handleNotification(AssociationChangeNotification notification, 83 T attachment) { 84 return HandlerResult.CONTINUE; 85 } 86 87 /** 88 * Invoked when an {@link PeerAddressChangeNotification} is received from 89 * the SCTP stack. 90 * 91 * @param notification 92 * The notification 93 * 94 * @param attachment 95 * The object attached to the {@code receive} operation when it was 96 * initiated. 97 * 98 * @return The handler result 99 */ 100 public HandlerResult handleNotification(PeerAddressChangeNotification notification, 101 T attachment) { 102 return HandlerResult.CONTINUE; 103 } 104 105 /** 106 * Invoked when an {@link SendFailedNotification} is received from 107 * the SCTP stack. 108 * 109 * @param notification 110 * The notification 111 * 112 * @param attachment 113 * The object attached to the {@code receive} operation when it was 114 * initiated. 115 * 116 * @return The handler result 117 */ 118 public HandlerResult handleNotification(SendFailedNotification notification, 119 T attachment) { 120 return HandlerResult.CONTINUE; 121 } 122 123 /** 124 * Invoked when an {@link ShutdownNotification} is received from 125 * the SCTP stack. 126 * 127 * @param notification 128 * The notification 129 * 130 * @param attachment 131 * The object attached to the {@code receive} operation when it was 132 * initiated. 133 * 134 * @return The handler result 135 */ 136 public HandlerResult handleNotification(ShutdownNotification notification, 137 T attachment) { 138 return HandlerResult.CONTINUE; 139 } 140 }