KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsif > providers > java > WSIFDynamicProvider_Java


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 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 "WSIF" 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 and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.apache.wsif.providers.java;
59
60 import java.util.Iterator JavaDoc;
61 import java.util.List JavaDoc;
62
63 import javax.wsdl.Binding;
64 import javax.wsdl.Definition;
65 import javax.wsdl.Port;
66 import javax.wsdl.Service;
67 import org.apache.wsif.WSIFException;
68 import org.apache.wsif.WSIFPort;
69 import org.apache.wsif.logging.Trc;
70 import org.apache.wsif.providers.WSIFDynamicTypeMap;
71 import org.apache.wsif.spi.WSIFProvider;
72 import org.apache.wsif.wsdl.extensions.java.JavaBinding;
73
74 /**
75  * Java specific provider of dynamic WSDL invocations.
76  * <p>
77  * The WSIF Java Provider allows WSIF to invoke Java classes and JavaBeans.
78  * This is designed to allow customers in a 'thin-client' environment such as
79  * a JVM or Tomcat test runtime to define 'shortcuts' to local Java code.
80  * <p>
81  * The Java binding exploits the format binding for type mapping.
82  * The format binding allows WSDL to define the mapping between XML Schema
83  * types and Java types.
84  * <p>
85  * The Java provider requires the targeted Java classes to be in the
86  * classpath of the client. The Java method is invoked synchronously,
87  * in-process, in-thread, with the current thread and ORB contexts.
88  * The Java provider is not transactional.
89  * <p>
90  * The binding extends WSDL with the following extensibility elements:
91  * <p>
92  * <pre>
93  * &lt;definitions .... &gt;
94  * &lt;!-- Java binding --&gt;
95  * &lt;binding ... &gt;
96  * &lt;java:binding/&gt;
97  * &lt;format:typeMapping style="uri" encoding="..."/&gt;?
98  * &lt;format:typeMap name="qname" formatType="nmtoken"/&gt;*
99  * &lt;/format:typeMapping&gt;
100  * &lt;operation&gt;*
101  * &lt;java:operation
102  * method="nmtoken"
103  * parameterOrder="nmtoken"?
104  * methodType="instance|static|constructor"?
105  * returnPart="nmtoken"? /&gt;?
106  * &lt;input name="nmtoken"? /&gt;?
107  * &lt;output name="nmtoken"? /&gt;?
108  * &lt;fault name="nmtoken"? /&gt;?
109  * &lt;/operation&gt;
110  * &lt;/binding&gt;
111  * &lt;service ... &gt;
112  * &lt;port&gt;*
113  * &lt;java:address
114  * class="nmtoken"
115  * archive="uri"?
116  * classloader="nmtoken"? /&gt;
117  * &lt;/port&gt;
118  * &lt;/service&gt;
119  * &lt;/definitions&gt;
120  * </pre>
121  * <p>
122  * @author <a HREF="mailto:gpfau@de.ibm.com">Gerhard Pfau</a>
123  * @author <a HREF="mailto:owenb@apache.org">Owen Burroughs</a>
124  * @author <a HREF="mailto:antelder@apache.org">Ant Elder</a>
125  * @author <a HREF="mailto:hughesj@apache.org">Jeremy Hughes</a>
126  * @author <a HREF="mailto:whitlock@apache.org">Mark Whitlock</a>
127  */

128 public class WSIFDynamicProvider_Java implements WSIFProvider {
129     private static final String JavaDoc[] supportedBindingNamespaceURIs =
130         { "http://schemas.xmlsoap.org/wsdl/java/" };
131
132     private static final String JavaDoc[] supportedAddressNamespaceURIs =
133         { "http://schemas.xmlsoap.org/wsdl/java/" };
134
135     public WSIFDynamicProvider_Java() {
136         Trc.entry(this);
137         Trc.exit();
138     }
139
140     /**
141      * Check if WSDL port has Java binding and if successful try
142      * to create Java port instance.
143      */

144     public WSIFPort createDynamicWSIFPort(
145         Definition def,
146         Service service,
147         Port port,
148         WSIFDynamicTypeMap typeMap)
149         throws WSIFException {
150         Trc.entry(this, def, service, port, typeMap);
151
152         // check that Port binding has Java binding extensibility element
153
Binding binding = port.getBinding();
154         List JavaDoc exs = binding.getExtensibilityElements();
155         for (Iterator JavaDoc i = exs.iterator(); i.hasNext();) {
156             Object JavaDoc o = i.next();
157             if (o instanceof JavaBinding) {
158                 // if so try to create Java dynamic port instance
159
WSIFPort wp = new WSIFPort_Java(def, port, typeMap);
160                 Trc.exit(wp);
161                 return wp;
162             }
163         }
164
165         // otherwise return null (so other providers can be checked)
166
Trc.exit();
167         return null;
168     }
169
170     /**
171      * Returns the WSDL namespace URIs of any bindings this provider supports.
172      * @return an array of all binding namespaces supported by this provider
173      */

174     public String JavaDoc[] getBindingNamespaceURIs() {
175         Trc.entry(this);
176         Trc.exit(supportedBindingNamespaceURIs);
177         return supportedBindingNamespaceURIs;
178     }
179
180     /**
181      * Returns the WSDL namespace URIs of any port addresses this provider supports.
182      * @return an array of all address namespaces supported by this provider
183      */

184     public String JavaDoc[] getAddressNamespaceURIs() {
185         Trc.entry(this);
186         Trc.exit(supportedAddressNamespaceURIs);
187         return supportedAddressNamespaceURIs;
188     }
189 }
Popular Tags