View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  
21  package org.apache.james.socket;
22  
23  import org.apache.avalon.framework.logger.Logger;
24  import org.apache.james.util.watchdog.Watchdog;
25  
26  import java.io.InputStream;
27  import java.io.OutputStream;
28  import java.io.PrintWriter;
29  import java.net.Socket;
30  
31  /**
32   * This is the helper interface provided to ProtocolHandlers to let them
33   * communicate with the outside world.
34   */
35  public interface ProtocolHandlerHelper {
36  
37      /**
38       * Writes a response to the client and flush it.
39       * @param responseString the response string
40       */
41      public void writeLoggedFlushedResponse(String responseString);
42      
43      /**
44       * Writes a response to the client without flushing.
45       * @param responseString the response string
46       */
47      public void writeLoggedResponse(String responseString);
48      
49      /**
50       * The watchdog is used to deal with timeouts.
51       * @return the watchdog instance
52       */
53      public Watchdog getWatchdog();
54      
55      /**
56       * Provides logging facility to the handler.
57       * @return logger instance
58       */
59      public Logger getAvalonLogger();
60  
61      /**
62       * getter for the remote hostname
63       * @return remote hostname 
64       */
65      public String getRemoteHost();
66      
67      /**
68       * getter for the remote ip
69       * @return remote ip 
70       */
71      public String getRemoteIP();
72      
73      /**
74       * Returns a CRLF terminated line reader
75       * @return line reader
76       */
77      public CRLFTerminatedReader getInputReader();
78      
79      /**
80       * Returns the raw input stream
81       * @return the raw inputstream
82       */
83      public InputStream getInputStream();
84      
85      /**
86       * Returns the raw outputstream
87       * @return outputstream
88       */
89      public OutputStream getOutputStream();
90      
91      /**
92       * Returns the printwriter.
93       * @return the output printwriter
94       */
95      public PrintWriter getOutputWriter();
96      
97      /**
98       * Provides basic errorhandling cleanup.
99       * @param e the runtimeexception
100      */
101     public void defaultErrorHandler(RuntimeException e);
102     
103     /**
104      * Provides access to the socket
105      * @return socket
106      */
107     public Socket getSocket();
108 
109     /**
110      * The name of this handler.
111      * Used for context sensitive logging.
112      * @return the name, not null
113      */
114     public String getName();
115 }