src/share/jaxws_classes/com/sun/xml/internal/ws/api/pipe/TransportPipeFactory.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.xml.internal.ws.api.pipe;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.istack.internal.Nullable;
30 import com.sun.xml.internal.ws.api.EndpointAddress;
31 import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
32 import com.sun.xml.internal.ws.util.pipe.StandalonePipeAssembler;
33
34 import javax.xml.ws.WebServiceException;
35
36 /**
37 * Factory for transport pipes that enables transport pluggability.
38 *
39 * <p>
40 * At runtime, on the client side, JAX-WS (more specifically the default {@link PipelineAssembler}
41 * of JAX-WS client runtime) relies on this factory to create a suitable transport {@link Pipe}
42 * that can handle the given {@link EndpointAddress endpoint address}.
43 *
44 * <p>
45 * JAX-WS extensions that provide additional transport support can
46 * extend this class and implement the {@link #doCreate} method.
47 * They are expected to check the scheme of the endpoint address
48 * (and possibly some other settings from bindings), and create
49 * their transport pipe implementations accordingly.
50 * For example,
51 *
52 * <pre>
53 * class MyTransportPipeFactoryImpl {
54 * Pipe doCreate(...) {
55 * String scheme = address.getURI().getScheme();
56 * if(scheme.equals("foo"))
57 * return new MyTransport(...);
58 * else
59 * return null;
60 * }
61 * }
62 * </pre>
63 *
64 * <p>
65 * {@link TransportPipeFactory} look-up follows the standard service
66 * discovery mechanism, so you need
67 * {@code META-INF/services/com.sun.xml.internal.ws.api.pipe.TransportPipeFactory}.
68 *
69 *
70 *
71 * <h2>TODO</h2>
72 * <p>
73 * One of the JAX-WS operation mode is supposedly where it doesn't have no WSDL whatsoever.
74 * How do we identify the endpoint in such case?
75 *
76 * @author Kohsuke Kawaguchi
77 * @see StandalonePipeAssembler
78 */
79 public abstract class TransportPipeFactory {
80 /**
81 * Creates a transport {@link Pipe} for the given port, if this factory can do so,
82 * or return null.
83 *
84 * @param context
85 * Object that captures various contextual information
86 * that can be used to determine the pipeline to be assembled.
87 *
88 * @return
89 * null to indicate that this factory isn't capable of creating a transport
90 * for this port (which causes the caller to search for other {@link TransportPipeFactory}s
91 * that can. Or non-null.
92 *
93 * @throws WebServiceException
94 * if this factory is capable of creating a transport pipe but some fatal
95 * error prevented it from doing so. This exception will be propagated
96 * back to the user application, and no further {@link TransportPipeFactory}s
97 * are consulted.
98 */
99 public abstract Pipe doCreate(@NotNull ClientPipeAssemblerContext context);
100
101 /**
102 * Locates {@link PipelineAssemblerFactory}s and create
103 * a suitable {@link PipelineAssembler}.
104 *
105 * @param classLoader
106 * used to locate {@code META-INF/servces} files.
107 * @return
108 * Always non-null, since we fall back to our default {@link PipelineAssembler}.
109 *
110 * @deprecated
111 * Use {@link TransportTubeFactory#create(ClassLoader, ClientTubeAssemblerContext)}
112 */
113 public static Pipe create(@Nullable ClassLoader classLoader, @NotNull ClientPipeAssemblerContext context) {
114 return PipeAdapter.adapt(TransportTubeFactory.create(classLoader,context));
115 }
116 }

mercurial