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

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.xml.internal.ws.api.pipe;
ohair@286 27
ohair@286 28 import java.util.Map;
ohair@286 29
ohair@286 30 /**
ohair@286 31 * Clones the whole pipeline.
ohair@286 32 *
ohair@286 33 * <p>
ohair@286 34 * Since {@link Tube}s may form an arbitrary directed graph, someone needs
ohair@286 35 * to keep track of isomorphism for a clone to happen correctly. This class
ohair@286 36 * serves that role.
ohair@286 37 *
ohair@286 38 * @author Kohsuke Kawaguchi
ohair@286 39 */
ohair@286 40 public abstract class TubeCloner {
ohair@286 41 // Pipe to pipe, or tube to tube
ohair@286 42 public final Map<Object,Object> master2copy;
ohair@286 43
ohair@286 44 /**
ohair@286 45 * Invoked by a client of a tube to clone the whole pipeline.
ohair@286 46 *
ohair@286 47 * <p>
alanb@368 48 * {@link Tube}s implementing the {@link Tube#copy(com.sun.xml.internal.ws.api.pipe.TubeCloner)} method
ohair@286 49 * shall use {@link #copy(Tube)} method.
ohair@286 50 *
ohair@286 51 * @param p
ohair@286 52 * The entry point of a pipeline to be copied. must not be null.
ohair@286 53 * @return
ohair@286 54 * The cloned pipeline. Always non-null.
ohair@286 55 */
ohair@286 56 @SuppressWarnings("deprecation")
ohair@286 57 public static Tube clone(Tube p) {
ohair@286 58 // we often want to downcast TubeCloner to PipeCloner,
ohair@286 59 // so let's create PipeCloner to make that possible
ohair@286 60 return new PipeClonerImpl().copy(p);
ohair@286 61 }
ohair@286 62
ohair@286 63 // no need to be constructed publicly. always use the static clone method.
ohair@286 64 /*package*/ TubeCloner(Map<Object,Object> master2copy) {
ohair@286 65 this.master2copy = master2copy;
ohair@286 66 }
ohair@286 67
ohair@286 68 /**
alanb@368 69 * Invoked by a {@link Tube#copy(com.sun.xml.internal.ws.api.pipe.TubeCloner)} implementation
ohair@286 70 * to copy a reference to another pipe.
ohair@286 71 *
ohair@286 72 * <p>
ohair@286 73 * This method is for {@link Tube} implementations, not for users.
ohair@286 74 *
ohair@286 75 * <p>
ohair@286 76 * If the given tube is already copied for this cloning episode,
ohair@286 77 * this method simply returns that reference. Otherwise it copies
ohair@286 78 * a tube, make a note, and returns a copied tube. This additional
ohair@286 79 * step ensures that a graph is cloned isomorphically correctly.
ohair@286 80 *
ohair@286 81 * <p>
ohair@286 82 * (Think about what happens when a graph is A->B, A->C, B->D, and C->D
ohair@286 83 * if you don't have this step.)
ohair@286 84 *
ohair@286 85 * @param t
ohair@286 86 * The tube to be copied.
ohair@286 87 * @return
ohair@286 88 * The cloned tube. Always non-null.
ohair@286 89 */
ohair@286 90 public abstract <T extends Tube> T copy(T t);
ohair@286 91
ohair@286 92 /**
ohair@286 93 * This method must be called from within the copy constructor
ohair@286 94 * to notify that the copy was created.
ohair@286 95 *
ohair@286 96 * <p>
ohair@286 97 * When your pipe has references to other pipes,
ohair@286 98 * it's particularly important to call this method
ohair@286 99 * before you start copying the pipes you refer to,
ohair@286 100 * or else there's a chance of inifinite loop.
ohair@286 101 */
ohair@286 102 public abstract void add(Tube original, Tube copy);
ohair@286 103 }

mercurial