KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > samples > ServerSideHandler


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.webservice.samples;
23
24 import org.jboss.logging.Logger;
25
26 import javax.xml.namespace.QName JavaDoc;
27 import javax.xml.rpc.handler.GenericHandler JavaDoc;
28 import javax.xml.rpc.handler.HandlerInfo JavaDoc;
29 import javax.xml.rpc.handler.MessageContext JavaDoc;
30
31 /**
32  * A simple server side handler
33  *
34  * @author thomas.diesler@jboss.org
35  */

36 public class ServerSideHandler extends GenericHandler JavaDoc
37 {
38    // provide logging
39
private static final Logger log = Logger.getLogger(ServerSideHandler.class);
40
41    // header blocks processed by this Handler instance
42
private QName JavaDoc[] headers;
43
44    /**
45     * Gets the header blocks processed by this Handler instance.
46     *
47     * @return Array of QNames of header blocks processed by this handler instance.
48     * QName is the qualified name of the outermost element of the Header block.
49     */

50    public QName JavaDoc[] getHeaders()
51    {
52       return headers;
53    }
54
55    /**
56     * The init method to enable the Handler instance to initialize itself. This method should be overridden if the
57     * derived Handler class needs to specialize implementation of this method.
58     * @param config handler configuration
59     */

60    public void init(HandlerInfo JavaDoc config)
61    {
62       log.info("init");
63       headers = config.getHeaders();
64    }
65
66    /**
67     * The destroy method indicates the end of lifecycle for a Handler instance. This method should be overridden if
68     * the derived Handler class needs to specialize implementation of this method.
69     */

70    public void destroy()
71    {
72       log.info("destroy");
73    }
74
75    /**
76     * The handleRequest method processes the request SOAP message. The default implementation of this method returns true.
77     * This indicates that the handler chain should continue processing of the request SOAP message.
78     * This method should be overridden if the derived Handler class needs to specialize implementation of this method.
79     * @param msgContext the message msgContext
80     * @return true/false
81     */

82    public boolean handleRequest(MessageContext JavaDoc msgContext)
83    {
84       log.info("handleRequest");
85       return true;
86    }
87
88    /**
89     * The handleResponse method processes the response message. The default implementation of this method returns true.
90     * This indicates that the handler chain should continue processing of the response SOAP message.
91     * This method should be overridden if the derived Handler class needs to specialize implementation of this method.
92     * @param msgContext the message msgContext
93     * @return true/false
94     */

95    public boolean handleResponse(MessageContext JavaDoc msgContext)
96    {
97       log.info("handleResponse");
98       return true;
99    }
100
101    /**
102     * The handleFault method processes the SOAP faults based on the SOAP message processing model.
103     * The default implementation of this method returns true. This indicates that the handler chain should continue
104     * processing of the SOAP fault. This method should be overridden if the derived Handler class needs to specialize
105     * implementation of this method.
106     * @param msgContext the message msgContext
107     * @return the message msgContext
108     */

109    public boolean handleFault(MessageContext JavaDoc msgContext)
110    {
111       log.info("handleFault");
112       return true;
113    }
114 }
115
Popular Tags