KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 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.ConfigurationException;
58 import org.jboss.axis.EngineConfiguration;
59 import org.jboss.axis.Handler;
60 import org.jboss.axis.encoding.SerializationContext;
61 import org.jboss.axis.utils.ClassUtils;
62 import org.jboss.axis.utils.Messages;
63 import org.jboss.axis.utils.XMLUtils;
64 import org.w3c.dom.Element JavaDoc;
65
66 import javax.xml.namespace.QName JavaDoc;
67 import java.io.IOException JavaDoc;
68
69
70 /**
71  *
72  */

73 public abstract class WSDDTargetedChain
74         extends WSDDDeployableItem
75 {
76    private WSDDRequestFlow requestFlow;
77    private WSDDResponseFlow responseFlow;
78    private QName JavaDoc pivotQName;
79
80    protected WSDDTargetedChain()
81    {
82    }
83
84    /**
85     * @param e (Element) XXX
86     * @throws WSDDException XXX
87     */

88    protected WSDDTargetedChain(Element JavaDoc e)
89            throws WSDDException
90    {
91       super(e);
92       Element JavaDoc reqEl = getChildElement(e, ELEM_WSDD_REQFLOW);
93       if (reqEl != null && reqEl.getElementsByTagName("*").getLength() > 0)
94       {
95          requestFlow = new WSDDRequestFlow(reqEl);
96       }
97       Element JavaDoc respEl = getChildElement(e, ELEM_WSDD_RESPFLOW);
98       if (respEl != null && respEl.getElementsByTagName("*").getLength() > 0)
99       {
100          responseFlow = new WSDDResponseFlow(respEl);
101       }
102
103       // !!! pivot? use polymorphic method?
104
String JavaDoc pivotStr = e.getAttribute(ATTR_PIVOT);
105       if (pivotStr != null && !pivotStr.equals(""))
106          pivotQName = XMLUtils.getQNameFromString(pivotStr, e);
107
108    }
109
110    public WSDDRequestFlow getRequestFlow()
111    {
112       return requestFlow;
113    }
114
115    public void setRequestFlow(WSDDRequestFlow flow)
116    {
117       requestFlow = flow;
118    }
119
120    public WSDDResponseFlow getResponseFlow()
121    {
122       return responseFlow;
123    }
124
125    public void setResponseFlow(WSDDResponseFlow flow)
126    {
127       responseFlow = flow;
128    }
129
130    /**
131     * @return XXX
132     */

133    public WSDDFaultFlow[] getFaultFlows()
134    {
135       return null;
136    }
137
138    /**
139     * @param name XXX
140     * @return XXX
141     */

142    public WSDDFaultFlow getFaultFlow(QName JavaDoc name)
143    {
144
145       WSDDFaultFlow[] t = getFaultFlows();
146
147       for (int n = 0; n < t.length; n++)
148       {
149          if (t[n].getQName().equals(name))
150          {
151             return t[n];
152          }
153       }
154
155       return null;
156    }
157
158    /**
159     * @param type XXX
160     */

161    public void setType(String JavaDoc type) throws WSDDException
162    {
163       throw new WSDDException(Messages.getMessage("noTypeSetting", getElementName().getLocalPart()));
164    }
165
166    public QName JavaDoc getPivotQName()
167    {
168       return pivotQName;
169    }
170
171    public void setPivotQName(QName JavaDoc pivotQName)
172    {
173       this.pivotQName = pivotQName;
174    }
175
176    /**
177     * @param pivot XXX
178     * @param registry XXX
179     * @return XXX
180     * @throws ConfigurationException XXX
181     */

182    public Handler makeNewInstance(EngineConfiguration registry)
183            throws ConfigurationException
184    {
185       Handler reqHandler = null;
186
187       WSDDChain req = getRequestFlow();
188       if (req != null)
189          reqHandler = req.getInstance(registry);
190
191       Handler pivot = null;
192       if (pivotQName != null)
193       {
194          if (URI_WSDD_JAVA.equals(pivotQName.getNamespaceURI()))
195          {
196             try
197             {
198                pivot = (Handler)ClassUtils.forName(pivotQName.getLocalPart()).newInstance();
199             }
200             catch (InstantiationException JavaDoc e)
201             {
202                throw new ConfigurationException(e);
203             }
204             catch (IllegalAccessException JavaDoc e)
205             {
206                throw new ConfigurationException(e);
207             }
208             catch (ClassNotFoundException JavaDoc e)
209             {
210                throw new ConfigurationException(e);
211             }
212          }
213          else
214          {
215             pivot = registry.getHandler(pivotQName);
216          }
217       }
218
219       Handler respHandler = null;
220       WSDDChain resp = getResponseFlow();
221       if (resp != null)
222          respHandler = resp.getInstance(registry);
223
224       return new org.jboss.axis.SimpleTargetedChain(reqHandler, pivot,
225               respHandler);
226    }
227
228    /**
229     * Write this element out to a SerializationContext
230     */

231    public final void writeFlowsToContext(SerializationContext context)
232            throws IOException JavaDoc
233    {
234       if (requestFlow != null)
235       {
236          requestFlow.writeToContext(context);
237       }
238       if (responseFlow != null)
239       {
240          responseFlow.writeToContext(context);
241       }
242
243    }
244
245    public void deployToRegistry(WSDDDeployment registry)
246    {
247       // deploy any named subparts
248
if (requestFlow != null)
249       {
250          requestFlow.deployToRegistry(registry);
251       }
252
253       if (responseFlow != null)
254       {
255          responseFlow.deployToRegistry(registry);
256       }
257    }
258 }
259
Popular Tags