All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.xml.ws.api.pipe.TubeCloner Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
/*
 * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.xml.ws.api.pipe;

import java.util.Map;

/**
 * Clones the whole pipeline.
 *
 * 

* Since {@link Tube}s may form an arbitrary directed graph, someone needs * to keep track of isomorphism for a clone to happen correctly. This class * serves that role. * * @author Kohsuke Kawaguchi */ public abstract class TubeCloner { // Pipe to pipe, or tube to tube public final Map master2copy; /** * Invoked by a client of a tube to clone the whole pipeline. * *

* {@link Tube}s implementing the {@link Tube#copy(com.sun.xml.ws.api.pipe.TubeCloner)} method * shall use {@link #copy(Tube)} method. * * @param p * The entry point of a pipeline to be copied. must not be null. * @return * The cloned pipeline. Always non-null. */ @SuppressWarnings("deprecation") public static Tube clone(Tube p) { // we often want to downcast TubeCloner to PipeCloner, // so let's create PipeCloner to make that possible return new PipeClonerImpl().copy(p); } // no need to be constructed publicly. always use the static clone method. /*package*/ TubeCloner(Map master2copy) { this.master2copy = master2copy; } /** * Invoked by a {@link Tube#copy(com.sun.xml.ws.api.pipe.TubeCloner)} implementation * to copy a reference to another pipe. * *

* This method is for {@link Tube} implementations, not for users. * *

* If the given tube is already copied for this cloning episode, * this method simply returns that reference. Otherwise it copies * a tube, make a note, and returns a copied tube. This additional * step ensures that a graph is cloned isomorphically correctly. * *

* (Think about what happens when a graph is A-{@literal >}B, A-{@literal >}C, * B-{@literal >}D, and C-{@literal >}D * if you don't have this step.) * * @param t * The tube to be copied. * @return * The cloned tube. Always non-null. */ public abstract T copy(T t); /** * This method must be called from within the copy constructor * to notify that the copy was created. * *

* When your pipe has references to other pipes, * it's particularly important to call this method * before you start copying the pipes you refer to, * or else there's a chance of inifinite loop. */ public abstract void add(Tube original, Tube copy); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy