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

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2010, 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.api.pipe.helper;
    28 import com.sun.xml.internal.ws.api.message.Packet;
    29 import com.sun.xml.internal.ws.api.pipe.Fiber;
    30 import com.sun.xml.internal.ws.api.pipe.NextAction;
    31 import com.sun.xml.internal.ws.api.pipe.Pipe;
    32 import com.sun.xml.internal.ws.api.pipe.PipeCloner;
    33 import com.sun.xml.internal.ws.api.pipe.Tube;
    34 import com.sun.xml.internal.ws.api.pipe.TubeCloner;
    36 /**
    37  * Base class for {@link Tube} implementation.
    38  *
    39  * <p>
    40  * This can be also used as a {@link Pipe}, and thus effectively
    41  * making every {@link Tube} usable as a {@link Pipe}.
    42  *
    43  * @author Kohsuke Kawaguchi
    44  */
    45 public abstract class AbstractTubeImpl implements Tube, Pipe {
    47     /**
    48      * Default constructor.
    49      */
    50     protected AbstractTubeImpl() {
    51     }
    53     /**
    54      * Copy constructor.
    55      */
    56     protected AbstractTubeImpl(AbstractTubeImpl that, TubeCloner cloner) {
    57         cloner.add(that,this);
    58     }
    60     protected final NextAction doInvoke(Tube next, Packet packet) {
    61         NextAction na = new NextAction();
    62         na.invoke(next,packet);
    63         return na;
    64     }
    66     protected final NextAction doInvokeAndForget(Tube next, Packet packet) {
    67         NextAction na = new NextAction();
    68         na.invokeAndForget(next,packet);
    69         return na;
    70     }
    72     protected final NextAction doReturnWith(Packet response) {
    73         NextAction na = new NextAction();
    74         na.returnWith(response);
    75         return na;
    76     }
    78     protected final NextAction doSuspend() {
    79         NextAction na = new NextAction();
    80         na.suspend();
    81         return na;
    82     }
    84     protected final NextAction doSuspend(Tube next) {
    85         NextAction na = new NextAction();
    86         na.suspend(next);
    87         return na;
    88     }
    90     protected final NextAction doThrow(Throwable t) {
    91         NextAction na = new NextAction();
    92         na.throwException(t);
    93         return na;
    94     }
    96     /**
    97      * "Dual stack" compatibility mechanism.
    98      * Allows {@link Tube} to be invoked from a {@link Pipe}.
    99      */
   100     public Packet process(Packet p) {
   101         return Fiber.current().runSync(this,p);
   102     }
   104     /**
   105      * Needs to be implemented by the derived class, but we can't make it abstract
   106      * without upsetting javac.
   107      */
   108     public final AbstractTubeImpl copy(PipeCloner cloner) {
   109         return copy((TubeCloner)cloner);
   110     }
   112     public abstract AbstractTubeImpl copy(TubeCloner cloner);
   113 }

mercurial