001 /*
002 * Copyright 2001-2004 The Apache Software Foundation.
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 * http://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 package javax.xml.rpc.handler;
017
018 import javax.xml.namespace.QName;
019
020 /**
021 * The <code>javax.xml.rpc.handler.GenericHandler</code> class
022 * implements the <code>Handler</code> interface. SOAP Message
023 * Handler developers should typically subclass
024 * <code>GenericHandler</code> class unless the Handler class
025 * needs another class as a superclass.
026 *
027 * <p>
028 * The <code>GenericHandler</code> class is a convenience abstract
029 * class that makes writing Handlers easy. This class provides
030 * default implementations of the lifecycle methods <code>init</code>
031 * and <code>destroy</code> and also different handle methods.
032 * A Handler developer should only override methods that it needs
033 * to specialize as part of the derived <code>Handler</code>
034 * implementation class.
035 *
036 * @version 1.0
037 */
038 public abstract class GenericHandler implements Handler {
039
040 /**
041 * Default constructor.
042 */
043 protected GenericHandler() {}
044
045 /**
046 * The <code>handleRequest</code> method processes the request
047 * SOAP message. The default implementation of this method returns
048 * <code>true</code>. This indicates that the handler chain
049 * should continue processing of the request SOAP message.
050 * This method should be overridden if the derived Handler class
051 * needs to specialize implementation of this method.
052 *
053 * @param context the message context
054 * @return true/false
055 */
056 public boolean handleRequest(MessageContext context) {
057 return true;
058 }
059
060 /**
061 * The <code>handleResponse</code> method processes the response
062 * message. The default implementation of this method returns
063 * <code>true</code>. This indicates that the handler chain
064 * should continue processing of the response SOAP message.
065 * This method should be overridden if the derived Handler class
066 * needs to specialize implementation of this method.
067 *
068 * @param context the message context
069 * @return true/false
070 */
071 public boolean handleResponse(MessageContext context) {
072 return true;
073 }
074
075 /**
076 * The <code>handleFault</code> method processes the SOAP faults
077 * based on the SOAP message processing model. The default
078 * implementation of this method returns <code>true</code>. This
079 * indicates that the handler chain should continue processing
080 * of the SOAP fault. This method should be overridden if
081 * the derived Handler class needs to specialize implementation
082 * of this method.
083 *
084 * @param context the message context
085 * @return true/false
086 */
087 public boolean handleFault(MessageContext context) {
088 return true;
089 }
090
091 /**
092 * The <code>init</code> method to enable the Handler instance to
093 * initialize itself. This method should be overridden if
094 * the derived Handler class needs to specialize implementation
095 * of this method.
096 *
097 * @param config handler configuration
098 */
099 public void init(HandlerInfo config) {}
100
101 /**
102 * The <code>destroy</code> method indicates the end of lifecycle
103 * for a Handler instance. This method should be overridden if
104 * the derived Handler class needs to specialize implementation
105 * of this method.
106 */
107 public void destroy() {}
108
109 /**
110 * Gets the header blocks processed by this Handler instance.
111 *
112 * @return Array of QNames of header blocks processed by this handler instance.
113 * <code>QName</code> is the qualified name of the outermost element of the Header block.
114 */
115 public abstract QName[] getHeaders();
116 }
117