KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > deployment > wsdd > WSDDJAXRPCHandlerInfoChain


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55 package org.jboss.axis.deployment.wsdd;
56
57 import org.jboss.axis.encoding.SerializationContext;
58 import org.jboss.axis.handlers.HandlerInfoChainFactory;
59 import org.jboss.axis.utils.ClassUtils;
60 import org.w3c.dom.Element JavaDoc;
61 import org.xml.sax.helpers.AttributesImpl JavaDoc;
62
63 import javax.xml.namespace.QName JavaDoc;
64 import javax.xml.rpc.handler.HandlerInfo JavaDoc;
65 import java.io.IOException JavaDoc;
66 import java.util.ArrayList JavaDoc;
67 import java.util.Iterator JavaDoc;
68 import java.util.List JavaDoc;
69 import java.util.Map JavaDoc;
70
71 /**
72  *
73  */

74 public class WSDDJAXRPCHandlerInfoChain extends WSDDHandler
75 {
76
77    private ArrayList JavaDoc _hiList;
78    private HandlerInfoChainFactory _hiChainFactory;
79    private String JavaDoc[] _roles;
80
81    /**
82     * Default constructor
83     */

84    public WSDDJAXRPCHandlerInfoChain()
85    {
86    }
87
88    /**
89     * @param e (Element) XXX
90     * @throws WSDDException XXX
91     */

92    public WSDDJAXRPCHandlerInfoChain(Element JavaDoc e) throws WSDDException
93    {
94       super(e);
95
96       ArrayList JavaDoc infoList = new ArrayList JavaDoc();
97       _hiList = new ArrayList JavaDoc();
98       Element JavaDoc[] elements = getChildElements(e, ELEM_WSDD_JAXRPC_HANDLERINFO);
99       if (elements.length != 0)
100       {
101          for (int i = 0; i < elements.length; i++)
102          {
103             WSDDJAXRPCHandlerInfo handlerInfo =
104                     new WSDDJAXRPCHandlerInfo(elements[i]);
105             _hiList.add(handlerInfo);
106
107             String JavaDoc handlerClassName = handlerInfo.getHandlerClassName();
108             Class JavaDoc handlerClass = null;
109             try
110             {
111                handlerClass = ClassUtils.forName(handlerClassName);
112             }
113             catch (ClassNotFoundException JavaDoc cnf)
114             {
115                // GLT - do something here
116
}
117
118             Map JavaDoc handlerMap = handlerInfo.getHandlerMap();
119             QName JavaDoc[] headers = handlerInfo.getHeaders();
120
121             if (handlerClass != null)
122             {
123                HandlerInfo JavaDoc hi =
124                        new HandlerInfo JavaDoc(handlerClass, handlerMap, headers);
125                infoList.add(hi);
126             }
127          }
128       }
129       _hiChainFactory = new HandlerInfoChainFactory(infoList);
130
131       elements = getChildElements(e, ELEM_WSDD_JAXRPC_ROLE);
132       if (elements.length != 0)
133       {
134          ArrayList JavaDoc roleList = new ArrayList JavaDoc();
135          for (int i = 0; i < elements.length; i++)
136          {
137             String JavaDoc role = elements[i].getAttribute(ATTR_SOAPACTORNAME);
138             roleList.add(role);
139          }
140          _roles = new String JavaDoc[roleList.size()];
141          _roles = (String JavaDoc[])roleList.toArray(_roles);
142          _hiChainFactory.setRoles(_roles);
143       }
144
145    }
146
147    public HandlerInfoChainFactory getHandlerChainFactory()
148    {
149       return _hiChainFactory;
150    }
151
152    public void setHandlerChainFactory(HandlerInfoChainFactory handlerInfoChainFactory)
153    {
154       _hiChainFactory = handlerInfoChainFactory;
155    }
156
157    protected QName JavaDoc getElementName()
158    {
159       return WSDDConstants.QNAME_JAXRPC_HANDLERINFOCHAIN;
160    }
161
162    /**
163     * Write this element out to a SerializationContext
164     */

165    public void writeToContext(SerializationContext context)
166            throws IOException JavaDoc
167    {
168       context.startElement(QNAME_JAXRPC_HANDLERINFOCHAIN, null);
169
170       List JavaDoc his = _hiList;
171       Iterator JavaDoc iter = his.iterator();
172       while (iter.hasNext())
173       {
174          WSDDJAXRPCHandlerInfo hi = (WSDDJAXRPCHandlerInfo)iter.next();
175          hi.writeToContext(context);
176       }
177
178       if (_roles != null)
179       {
180          for (int i = 0; i < _roles.length; i++)
181          {
182             AttributesImpl JavaDoc attrs1 = new AttributesImpl JavaDoc();
183             attrs1.addAttribute("", ATTR_SOAPACTORNAME, ATTR_SOAPACTORNAME,
184                     "CDATA", _roles[i]);
185             context.startElement(QNAME_JAXRPC_ROLE, attrs1);
186             context.endElement();
187          }
188       }
189
190       context.endElement();
191    }
192
193    public ArrayList JavaDoc getHandlerInfoList()
194    {
195       return _hiList;
196    }
197
198    public void setHandlerInfoList(ArrayList JavaDoc hiList)
199    {
200       _hiList = hiList;
201    }
202
203    public String JavaDoc[] getRoles()
204    {
205       return _roles;
206    }
207
208    public void setRoles(String JavaDoc[] roles)
209    {
210       _roles = roles;
211    }
212 }
213
Popular Tags