Search in sources :

Example 1 with HandlerResult

use of com.sun.nio.sctp.HandlerResult in project jdk8u_jdk by JetBrains.

the class SctpMultiChannelImpl method invokeNotificationHandler.

private <T> HandlerResult invokeNotificationHandler(ResultContainer resultContainer, NotificationHandler<T> handler, T attachment) {
    HandlerResult result;
    SctpNotification notification = resultContainer.notification();
    notification.setAssociation(lookupAssociation(notification.assocId()));
    if (!(handler instanceof AbstractNotificationHandler)) {
        result = handler.handleNotification(notification, attachment);
    } else {
        /* AbstractNotificationHandler */
        AbstractNotificationHandler<T> absHandler = (AbstractNotificationHandler<T>) handler;
        switch(resultContainer.type()) {
            case ASSOCIATION_CHANGED:
                result = absHandler.handleNotification(resultContainer.getAssociationChanged(), attachment);
                break;
            case PEER_ADDRESS_CHANGED:
                result = absHandler.handleNotification(resultContainer.getPeerAddressChanged(), attachment);
                break;
            case SEND_FAILED:
                result = absHandler.handleNotification(resultContainer.getSendFailed(), attachment);
                break;
            case SHUTDOWN:
                result = absHandler.handleNotification(resultContainer.getShutdown(), attachment);
                break;
            default:
                /* implementation specific handlers */
                result = absHandler.handleNotification(resultContainer.notification(), attachment);
        }
    }
    if (!(handler instanceof InternalNotificationHandler)) {
        /* Only remove associations after user handler
             * has finished with them */
        Association assoc = associationToRemove.get();
        if (assoc != null) {
            removeAssociation(assoc);
            associationToRemove.set(null);
        }
    }
    return result;
}
Also used : Association(com.sun.nio.sctp.Association) AbstractNotificationHandler(com.sun.nio.sctp.AbstractNotificationHandler) HandlerResult(com.sun.nio.sctp.HandlerResult)

Aggregations

AbstractNotificationHandler (com.sun.nio.sctp.AbstractNotificationHandler)1 Association (com.sun.nio.sctp.Association)1 HandlerResult (com.sun.nio.sctp.HandlerResult)1