Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset fdbe50121f48
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.logging.Logger;
29 import com.sun.xml.internal.ws.api.pipe.Pipe;
30 import com.sun.xml.internal.ws.api.pipe.Tube;
31 import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
32 import com.sun.xml.internal.ws.assembler.dev.TubelineAssemblyContext;
33 import java.text.MessageFormat;
35 import java.util.LinkedList;
36 import java.util.List;
37 import java.util.logging.Level;
39 /**
40 * A base tubeline assembly context class providing common methods for both
41 * client and server assembly context classes.
42 *
43 * @author Marek Potociar (marek.potociar at sun.com)
44 */
45 class TubelineAssemblyContextImpl implements TubelineAssemblyContext {
46 private static final Logger LOGGER = Logger.getLogger(TubelineAssemblyContextImpl.class);
48 private Tube head;
49 private Pipe adaptedHead;
50 private List<Tube> tubes = new LinkedList<Tube>();
52 @Override
53 public Tube getTubelineHead() {
54 return head;
55 }
57 @Override
58 public Pipe getAdaptedTubelineHead() {
59 if (adaptedHead == null) {
60 adaptedHead = PipeAdapter.adapt(head);
61 }
62 return adaptedHead;
63 }
65 boolean setTubelineHead(Tube newHead) {
66 if (newHead == head || newHead == adaptedHead) {
67 return false;
68 }
70 head = newHead;
71 tubes.add(head);
72 adaptedHead = null;
74 if (LOGGER.isLoggable(Level.FINER)) {
75 LOGGER.finer(MessageFormat.format("Added '{0}' tube instance to the tubeline.", (newHead == null) ? null : newHead.getClass().getName()));
76 }
78 return true;
79 }
81 @Override
82 public <T> T getImplementation(Class<T> type) {
83 for (Tube tube : tubes) {
84 if (type.isInstance(tube)) {
85 return type.cast(tube);
86 }
87 }
88 return null;
89 }
90 }