001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package javax.xml.rpc.handler;
021    
022    import javax.xml.namespace.QName;
023    
024    /**
025     * The <code>javax.xml.rpc.handler.GenericHandler</code> class
026     * implements the <code>Handler</code> interface. SOAP Message
027     * Handler developers should typically subclass
028     * <code>GenericHandler</code> class unless the Handler class
029     * needs another class as a superclass.
030     *
031     * <p>
032     * The <code>GenericHandler</code> class is a convenience abstract
033     * class that makes writing Handlers easy. This class provides
034     * default implementations of the lifecycle methods <code>init</code>
035     * and <code>destroy</code> and also different handle methods.
036     * A Handler developer should only override methods that it needs
037     * to specialize as part of the derived <code>Handler</code>
038     * implementation class.
039     *
040     * @version $Rev: 467553 $ $Date: 2006-10-25 00:01:51 -0400 (Wed, 25 Oct 2006) $
041     */
042    public abstract class GenericHandler implements Handler {
043    
044        /**
045         * Default constructor.
046         */
047        protected GenericHandler() {}
048    
049        /**
050         * The <code>handleRequest</code> method processes the request
051         * SOAP message. The default implementation of this method returns
052         * <code>true</code>. This indicates that the handler chain
053         * should continue processing of the request SOAP message.
054         * This method should be overridden if the derived Handler class
055         * needs to specialize implementation of this method.
056         *
057         * @param context the message context
058         * @return true/false
059         */
060        public boolean handleRequest(MessageContext context) {
061            return true;
062        }
063    
064        /**
065         * The <code>handleResponse</code> method processes the response
066         * message. The default implementation of this method returns
067         * <code>true</code>. This indicates that the handler chain
068         * should continue processing of the response SOAP message.
069         * This method should be overridden if the derived Handler class
070         * needs to specialize implementation of this method.
071         *
072         * @param context the message context
073         * @return true/false
074         */
075        public boolean handleResponse(MessageContext context) {
076            return true;
077        }
078    
079        /**
080         * The <code>handleFault</code> method processes the SOAP faults
081         * based on the SOAP message processing model. The default
082         * implementation of this method returns <code>true</code>. This
083         * indicates that the handler chain should continue processing
084         * of the SOAP fault. This method should be overridden if
085         * the derived Handler class needs to specialize implementation
086         * of this method.
087         *
088         * @param context the message context
089         * @return true/false
090         */
091        public boolean handleFault(MessageContext context) {
092            return true;
093        }
094    
095        /**
096         * The <code>init</code> method to enable the Handler instance to
097         * initialize itself. This method should be overridden if
098         * the derived Handler class needs to specialize implementation
099         * of this method.
100         *
101         * @param config handler configuration
102         */
103        public void init(HandlerInfo config) {}
104    
105        /**
106         * The <code>destroy</code> method indicates the end of lifecycle
107         * for a Handler instance. This method should be overridden if
108         * the derived Handler class needs to specialize implementation
109         * of this method.
110         */
111        public void destroy() {}
112    
113        /**
114         * Gets the header blocks processed by this Handler instance.
115         *
116         * @return Array of QNames of header blocks processed by this handler instance.
117         * <code>QName</code> is the qualified name of the outermost element of the Header block.
118         */
119        public abstract QName[] getHeaders();
120    }
121