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 * Contract to handle a STOMP frame. 025 * 026 * @author Rossen Stoyanchev 027 * @since 4.2 028 */ 029public interface StompFrameHandler { 030 031 /** 032 * Invoked before {@link #handleFrame(StompHeaders, Object)} to determine the 033 * type of Object the payload should be converted to. 034 * @param headers the headers of a message 035 */ 036 Type getPayloadType(StompHeaders headers); 037 038 /** 039 * Handle a STOMP frame with the payload converted to the target type returned 040 * from {@link #getPayloadType(StompHeaders)}. 041 * @param headers the headers of the frame 042 * @param payload the payload, or {@code null} if there was no payload 043 */ 044 void handleFrame(StompHeaders headers, @Nullable Object payload); 045 046}