1/* 2 * Copyright 2007 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.mockftpserver.core.command; 17 18import org.mockftpserver.core.session.Session; 19import org.mockftpserver.core.util.AssertFailedException; 20import org.mockftpserver.stub.command.AbstractStubCommandHandler; 21 22/** 23 * CommandHandler that sends back the configured reply code and text. You can customize the 24 * returned reply code by setting the required <code>replyCode</code> property. If only the 25 * <code>replyCode</code> property is set, then the default reply text corresponding to that 26 * reply code is used in the response. You can optionally configure the reply text by setting 27 * the <code>replyMessageKey</code> or <code>replyText</code> property. 28 * <p> 29 * Each invocation record stored by this CommandHandler contains no data elements. 30 * 31 * @version $Revision$ - $Date$ 32 * 33 * @author Chris Mair 34 */ 35public final class StaticReplyCommandHandler extends AbstractStubCommandHandler implements CommandHandler { 36 37 /** 38 * Create a new uninitialized instance 39 */ 40 public StaticReplyCommandHandler() { 41 } 42 43 /** 44 * Create a new instance with the specified replyCode 45 * @param replyCode - the replyCode to use 46 * @throws AssertFailedException - if the replyCode is null 47 */ 48 public StaticReplyCommandHandler(int replyCode) { 49 setReplyCode(replyCode); 50 } 51 52 /** 53 * Create a new instance with the specified replyCode and replyText 54 * @param replyCode - the replyCode to use 55 * @param replyText - the replyText 56 * @throws AssertFailedException - if the replyCode is null 57 */ 58 public StaticReplyCommandHandler(int replyCode, String replyText) { 59 setReplyCode(replyCode); 60 setReplyText(replyText); 61 } 62 63 /** 64 * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord) 65 */ 66 public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { 67 sendReply(session); 68 } 69 70} 71