Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java
32300 views
/*1* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package sun.nio.ch.sctp;2526import com.sun.nio.sctp.Association;27import com.sun.nio.sctp.AssociationChangeNotification;28import java.lang.annotation.Native;2930/**31* An implementation of AssociationChangeNotification32*/33public class AssociationChange extends AssociationChangeNotification34implements SctpNotification35{36/* static final ints so that they can be referenced from native */37@Native private final static int SCTP_COMM_UP = 1;38@Native private final static int SCTP_COMM_LOST = 2;39@Native private final static int SCTP_RESTART = 3;40@Native private final static int SCTP_SHUTDOWN = 4;41@Native private final static int SCTP_CANT_START = 5;4243private Association association;4445/* assocId is used to lookup the association before the notification is46* returned to user code */47private int assocId;48private AssocChangeEvent event;49private int maxOutStreams;50private int maxInStreams;5152/* Invoked from native */53private AssociationChange(int assocId,54int intEvent,55int maxOutStreams,56int maxInStreams) {57switch (intEvent) {58case SCTP_COMM_UP :59this.event = AssocChangeEvent.COMM_UP;60break;61case SCTP_COMM_LOST :62this.event = AssocChangeEvent.COMM_LOST;63break;64case SCTP_RESTART :65this.event = AssocChangeEvent.RESTART;66break;67case SCTP_SHUTDOWN :68this.event = AssocChangeEvent.SHUTDOWN;69break;70case SCTP_CANT_START :71this.event = AssocChangeEvent.CANT_START;72break;73default :74throw new AssertionError(75"Unknown Association Change Event type: " + intEvent);76}7778this.assocId = assocId;79this.maxOutStreams = maxOutStreams;80this.maxInStreams = maxInStreams;81}8283@Override84public int assocId() {85return assocId;86}8788@Override89public void setAssociation(Association association) {90this.association = association;91}9293@Override94public Association association() {95assert association != null;96return association;97}9899@Override100public AssocChangeEvent event() {101return event;102}103104int maxOutStreams() {105return maxOutStreams;106}107108int maxInStreams() {109return maxInStreams;110}111112@Override113public String toString() {114StringBuilder sb = new StringBuilder();115sb.append(super.toString()).append(" [");116sb.append("Association:").append(association);117sb.append(", Event: ").append(event).append("]");118return sb.toString();119}120}121122123