19d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair/* 29d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Copyright 2007 the original author or authors. 39d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * 49d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Licensed under the Apache License, Version 2.0 (the "License"); 59d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * you may not use this file except in compliance with the License. 69d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * You may obtain a copy of the License at 79d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * 89d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * http://www.apache.org/licenses/LICENSE-2.0 99d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * 109d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Unless required by applicable law or agreed to in writing, software 119d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * distributed under the License is distributed on an "AS IS" BASIS, 129d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * See the License for the specific language governing permissions and 149d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * limitations under the License. 159d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 169d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismairpackage org.mockftpserver.core.command; 179d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 189d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismairimport org.mockftpserver.core.session.Session; 199d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismairimport org.mockftpserver.core.util.AssertFailedException; 209d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismairimport org.mockftpserver.stub.command.AbstractStubCommandHandler; 219d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 229d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair/** 239d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * CommandHandler that sends back the configured reply code and text. You can customize the 249d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * returned reply code by setting the required <code>replyCode</code> property. If only the 259d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * <code>replyCode</code> property is set, then the default reply text corresponding to that 269d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * reply code is used in the response. You can optionally configure the reply text by setting 279d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * the <code>replyMessageKey</code> or <code>replyText</code> property. 289d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * <p> 299d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Each invocation record stored by this CommandHandler contains no data elements. 309d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * 319d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @version $Revision$ - $Date$ 329d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * 339d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @author Chris Mair 349d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 359d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismairpublic final class StaticReplyCommandHandler extends AbstractStubCommandHandler implements CommandHandler { 369d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 379d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair /** 389d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Create a new uninitialized instance 399d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 409d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair public StaticReplyCommandHandler() { 419d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair } 429d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 439d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair /** 449d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Create a new instance with the specified replyCode 459d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @param replyCode - the replyCode to use 469d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @throws AssertFailedException - if the replyCode is null 479d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 489d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair public StaticReplyCommandHandler(int replyCode) { 499d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair setReplyCode(replyCode); 509d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair } 519d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 529d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair /** 539d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * Create a new instance with the specified replyCode and replyText 549d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @param replyCode - the replyCode to use 559d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @param replyText - the replyText 569d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @throws AssertFailedException - if the replyCode is null 579d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 589d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair public StaticReplyCommandHandler(int replyCode, String replyText) { 599d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair setReplyCode(replyCode); 609d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair setReplyText(replyText); 619d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair } 629d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 639d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair /** 649d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair * @see org.mockftpserver.core.command.CommandHandler#handleCommand(Command, Session, InvocationRecord) 659d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair */ 669d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair public void handleCommand(Command command, Session session, InvocationRecord invocationRecord) { 679d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair sendReply(session); 689d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair } 699d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair 709d9aece7b2c2865253fdd2946a4d11a4f642c5aechrismair} 71