Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
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 */
26 package com.sun.xml.internal.ws.assembler;
28 import com.sun.istack.internal.NotNull;
29 import com.sun.istack.internal.logging.Logger;
30 import com.sun.xml.internal.ws.assembler.dev.ClientTubelineAssemblyContext;
31 import com.sun.xml.internal.ws.resources.TubelineassemblyMessages;
32 import com.sun.xml.internal.ws.runtime.config.TubeFactoryConfig;
33 import com.sun.xml.internal.ws.runtime.config.TubeFactoryList;
35 import javax.xml.namespace.QName;
36 import java.net.URI;
37 import java.net.URISyntaxException;
38 import java.util.Collection;
39 import java.util.LinkedList;
41 /**
42 *
43 * @author Marek Potociar (marek.potociar at sun.com)
44 */
45 final class TubelineAssemblyController {
47 private final MetroConfigName metroConfigName;
49 TubelineAssemblyController(MetroConfigName metroConfigName) {
50 this.metroConfigName = metroConfigName;
51 }
53 /**
54 * Provides a ordered collection of WSIT/Metro client-side tube creators that are be used to
55 * construct a client-side Metro tubeline
56 *
57 * The order of the tube creators in the collection is last-to-first from the
58 * client side request message processing perspective.
59 *
60 * <b>
61 * WARNING: This method is part of Metro internal API and may be changed, removed or
62 * replaced by a different method without a prior notice. The method SHOULD NOT be used
63 * outside of Metro codebase.
64 * </b>
65 *
66 * @param endpointUri URI of the endpoint for which the collection of tube factories should be returned
67 *
68 * @return collection of WSIT/Metro client-side tube creators
69 */
70 Collection<TubeCreator> getTubeCreators(ClientTubelineAssemblyContext context) {
71 URI endpointUri;
72 if (context.getPortInfo() != null) {
73 endpointUri = createEndpointComponentUri(context.getPortInfo().getServiceName(), context.getPortInfo().getPortName());
74 } else {
75 endpointUri = null;
76 }
78 MetroConfigLoader configLoader = new MetroConfigLoader(context.getContainer(), metroConfigName);
79 return initializeTubeCreators(configLoader.getClientSideTubeFactories(endpointUri));
80 }
82 /**
83 * Provides a ordered collection of WSIT/Metro server-side tube creators that are be used to
84 * construct a server-side Metro tubeline for a given endpoint
85 *
86 * The order of the tube creators in the collection is last-to-first from the
87 * server side request message processing perspective.
88 *
89 * <b>
90 * WARNING: This method is part of Metro internal API and may be changed, removed or
91 * replaced by a different method without a prior notice. The method SHOULD NOT be used
92 * outside of Metro codebase.
93 * </b>
94 *
95 * @param endpointUri URI of the endpoint for which the collection of tube factories should be returned
96 *
97 * @return collection of WSIT/Metro server-side tube creators
98 */
99 Collection<TubeCreator> getTubeCreators(DefaultServerTubelineAssemblyContext context) {
100 URI endpointUri;
101 if (context.getEndpoint() != null) {
102 endpointUri = createEndpointComponentUri(context.getEndpoint().getServiceName(), context.getEndpoint().getPortName());
103 } else {
104 endpointUri = null;
105 }
107 MetroConfigLoader configLoader = new MetroConfigLoader(context.getEndpoint().getContainer(), metroConfigName);
108 return initializeTubeCreators(configLoader.getEndpointSideTubeFactories(endpointUri));
109 }
111 private Collection<TubeCreator> initializeTubeCreators(TubeFactoryList tfl) {
112 final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
114 LinkedList<TubeCreator> tubeCreators = new LinkedList<TubeCreator>();
115 for (TubeFactoryConfig tubeFactoryConfig : tfl.getTubeFactoryConfigs()) {
116 tubeCreators.addFirst(new TubeCreator(tubeFactoryConfig, contextClassLoader));
117 }
118 return tubeCreators;
119 }
121 /*
122 * Example WSDL component URI: http://org.sample#wsdl11.port(PingService/HttpPingPort)
123 */
124 private URI createEndpointComponentUri(@NotNull QName serviceName, @NotNull QName portName) {
125 StringBuilder sb = new StringBuilder(serviceName.getNamespaceURI()).append("#wsdl11.port(").append(serviceName.getLocalPart()).append('/').append(portName.getLocalPart()).append(')');
126 try {
127 return new URI(sb.toString());
128 } catch (URISyntaxException ex) {
129 Logger.getLogger(TubelineAssemblyController.class).warning(
130 TubelineassemblyMessages.MASM_0020_ERROR_CREATING_URI_FROM_GENERATED_STRING(sb.toString()),
131 ex);
132 return null;
133 }
134 }
135 }