001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.messaging.simp.stomp;
018
019import java.lang.reflect.Type;
020
021import org.springframework.lang.Nullable;
022
023/**
024 * Abstract adapter class for {@link StompSessionHandler} with mostly empty
025 * implementation methods except for {@link #getPayloadType} which returns String
026 * as the default Object type expected for STOMP ERROR frame payloads.
027 *
028 * @author Rossen Stoyanchev
029 * @since 4.2
030 */
031public abstract class StompSessionHandlerAdapter implements StompSessionHandler {
032
033        /**
034         * This implementation returns String as the expected payload type
035         * for STOMP ERROR frames.
036         */
037        @Override
038        public Type getPayloadType(StompHeaders headers) {
039                return String.class;
040        }
041
042        /**
043         * This implementation is empty.
044         */
045        @Override
046        public void handleFrame(StompHeaders headers, @Nullable Object payload) {
047        }
048
049        /**
050         * This implementation is empty.
051         */
052        @Override
053        public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
054        }
055
056        /**
057         * This implementation is empty.
058         */
059        @Override
060        public void handleException(StompSession session, @Nullable StompCommand command,
061                        StompHeaders headers, byte[] payload, Throwable exception) {
062        }
063
064        /**
065         * This implementation is empty.
066         */
067        @Override
068        public void handleTransportError(StompSession session, Throwable exception) {
069        }
070
071}