feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.WSService;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.api.server.Container;
import java.io.PrintStream;
/**
* Factory for well-known {@link Pipe} implementations
* that the {@link PipelineAssembler} needs to use
* to satisfy JAX-WS requirements.
*
* @author Kohsuke Kawaguchi
* @deprecated Use {@link ClientTubeAssemblerContext}.
*/
public final class ClientPipeAssemblerContext extends ClientTubeAssemblerContext {
public ClientPipeAssemblerContext(@NotNull EndpointAddress address, @NotNull WSDLPort wsdlModel, @NotNull WSService rootOwner, @NotNull WSBinding binding) {
this(address, wsdlModel, rootOwner, binding, Container.NONE);
}
public ClientPipeAssemblerContext(@NotNull EndpointAddress address, @NotNull WSDLPort wsdlModel,
@NotNull WSService rootOwner, @NotNull WSBinding binding,
@NotNull Container container) {
super(address, wsdlModel, rootOwner, binding, container);
}
/**
* creates a {@link Pipe} that dumps messages that pass through.
*/
public Pipe createDumpPipe(String name, PrintStream out, Pipe next) {
return PipeAdapter.adapt(super.createDumpTube(name, out, PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that performs WS-Addressig processing.
* This pipe should be before {@link com.sun.xml.internal.ws.protocol.soap.ClientMUTube}.
*/
public Pipe createWsaPipe(Pipe next) {
return PipeAdapter.adapt(super.createWsaTube(PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that performs SOAP mustUnderstand processing.
* This pipe should be before HandlerPipes.
*/
public Pipe createClientMUPipe(Pipe next) {
return PipeAdapter.adapt(super.createClientMUTube(PipeAdapter.adapt(next)));
}
/**
* creates a {@link Pipe} that validates messages against schema
*/
public Pipe createValidationPipe(Pipe next) {
return PipeAdapter.adapt(super.createValidationTube(PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that invokes protocol and logical handlers.
*/
public Pipe createHandlerPipe(Pipe next) {
return PipeAdapter.adapt(super.createHandlerTube(PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Tube} that adds container specific security
*/
public @NotNull Pipe createSecurityPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createSecurityTube(PipeAdapter.adapt(next)));
}
/**
* Creates a transport pipe (for client), which becomes the terminal pipe.
*/
public Pipe createTransportPipe() {
return PipeAdapter.adapt(super.createTransportTube());
}
}

View File

@@ -0,0 +1,340 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.addressing.W3CWsaClientTube;
import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionWsaClientTube;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.WSService;
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
import com.sun.xml.internal.ws.api.client.ClientPipelineHook;
import com.sun.xml.internal.ws.api.client.WSPortInfo;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.binding.BindingImpl;
import com.sun.xml.internal.ws.client.ClientSchemaValidationTube;
import com.sun.xml.internal.ws.developer.SchemaValidationFeature;
import com.sun.xml.internal.ws.developer.WSBindingProvider;
import com.sun.xml.internal.ws.handler.ClientLogicalHandlerTube;
import com.sun.xml.internal.ws.handler.ClientMessageHandlerTube;
import com.sun.xml.internal.ws.handler.ClientSOAPHandlerTube;
import com.sun.xml.internal.ws.handler.HandlerTube;
import com.sun.xml.internal.ws.protocol.soap.ClientMUTube;
import com.sun.xml.internal.ws.transport.DeferredTransportPipe;
import com.sun.xml.internal.ws.util.pipe.DumpTube;
import javax.xml.ws.soap.SOAPBinding;
import java.io.PrintStream;
/**
* Factory for well-known {@link Tube} implementations
* that the {@link TubelineAssembler} needs to use
* to satisfy JAX-WS requirements.
*
* @author Jitendra Kotamraju
*/
public class ClientTubeAssemblerContext {
private final @NotNull EndpointAddress address;
private final @Nullable WSDLPort wsdlModel;
private final @Nullable SEIModel seiModel;
private final @Nullable Class sei;
private final @NotNull WSService rootOwner;
private final @NotNull WSBinding binding;
private final @NotNull Container container;
private @NotNull Codec codec;
//Nullable only to maintain comaptibility with old constructors of this class.
private final @Nullable WSBindingProvider bindingProvider;
/**
* This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
* @deprecated
* Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
*/
public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel, @NotNull WSService rootOwner, @NotNull WSBinding binding) {
this(address, wsdlModel, rootOwner, binding, Container.NONE);
}
/**
* This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
* @deprecated
* Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
*/
public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
@NotNull WSService rootOwner, @NotNull WSBinding binding,
@NotNull Container container) {
// WSBinding is actually BindingImpl
this(address, wsdlModel, rootOwner, binding, container, ((BindingImpl)binding).createCodec() );
}
/**
* This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
* @deprecated
* Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
*/
public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
@NotNull WSService rootOwner, @NotNull WSBinding binding,
@NotNull Container container, Codec codec) {
this(address, wsdlModel, rootOwner, binding, container, codec, null, null);
}
/**
* This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
* @deprecated
* Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
*/
public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
@NotNull WSService rootOwner, @NotNull WSBinding binding,
@NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
this(address, wsdlModel, rootOwner, null/* no info on which port it is, so pass null*/, binding, container, codec, seiModel, sei);
}
/**
* This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
*
* @since JAX-WS 2.2
*/
public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
@NotNull WSBindingProvider bindingProvider, @NotNull WSBinding binding,
@NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
this(address, wsdlModel, (bindingProvider==null? null: bindingProvider.getPortInfo().getOwner()), bindingProvider, binding, container, codec, seiModel, sei);
}
//common constructor
//WSService is null, when ClientTubeAssemblerContext is created for sending non-anonymous responses.
private ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
@Nullable WSService rootOwner, @Nullable WSBindingProvider bindingProvider, @NotNull WSBinding binding,
@NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
this.address = address;
this.wsdlModel = wsdlModel;
this.rootOwner = rootOwner;
this.bindingProvider = bindingProvider;
this.binding = binding;
this.container = container;
this.codec = codec;
this.seiModel = seiModel;
this.sei = sei;
}
/**
* The endpoint address. Always non-null. This parameter is taken separately
* from {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort} (even though there's {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort#getAddress()})
* because sometimes WSDL is not available.
*/
public @NotNull EndpointAddress getAddress() {
return address;
}
/**
* The created pipeline will be used to serve this port.
* Null if the service isn't associated with any port definition in WSDL,
* and otherwise non-null.
*/
public @Nullable WSDLPort getWsdlModel() {
return wsdlModel;
}
/**
* The pipeline is created for this {@link com.sun.xml.internal.ws.api.WSService}.
* Always non-null. (To be precise, the newly created pipeline
* is owned by a proxy or a dispatch created from thsi {@link com.sun.xml.internal.ws.api.WSService}.)
*/
public @NotNull WSService getService() {
return rootOwner;
}
/**
* The pipeline is created for this {@link com.sun.xml.internal.ws.api.client.WSPortInfo}.
* Nullable incase of backwards compatible usages of this class.
*/
public @Nullable WSPortInfo getPortInfo() {
return bindingProvider == null? null: bindingProvider.getPortInfo();
}
/**
* The pipeline is created for this {@link WSBindingProvider}.
* Nullable incase of backwards compatible usages of this class.
*/
public @Nullable WSBindingProvider getBindingProvider() {
return bindingProvider;
}
/**
* The binding of the new pipeline to be created.
*/
public @NotNull WSBinding getBinding() {
return binding;
}
/**
* The created pipeline will use seiModel to get java concepts for the endpoint
*
* @return Null if the service doesn't have SEI model e.g. Dispatch,
* and otherwise non-null.
*/
public @Nullable SEIModel getSEIModel() {
return seiModel;
}
/**
* The SEI class for the endpoint
*
* @return Null if the service doesn't have SEI model e.g. Dispatch,
* and otherwise non-null.
*/
public @Nullable Class getSEI() {
return sei;
}
/**
* Returns the Container in which the client is running
*
* @return Container in which client is running
*/
public Container getContainer() {
return container;
}
/**
* creates a {@link Tube} that dumps messages that pass through.
*/
public Tube createDumpTube(String name, PrintStream out, Tube next) {
return new DumpTube(name, out, next);
}
/**
* Creates a {@link Tube} that adds container specific security
*/
public @NotNull Tube createSecurityTube(@NotNull Tube next) {
ClientPipelineHook hook = container.getSPI(ClientPipelineHook.class);
if (hook != null) {
ClientPipeAssemblerContext ctxt = new ClientPipeAssemblerContext(address, wsdlModel,
rootOwner, binding, container);
return PipeAdapter.adapt(hook.createSecurityPipe(ctxt, PipeAdapter.adapt(next)));
}
return next;
}
/**
* Creates a {@link Tube} that invokes protocol and logical handlers.
*/
public Tube createWsaTube(Tube next) {
if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
} else {
return new W3CWsaClientTube(wsdlModel, binding, next);
}
else
return next;
}
/**
* Creates a {@link Tube} that invokes protocol and logical handlers.
*/
public Tube createHandlerTube(Tube next) {
HandlerTube cousinHandlerTube = null;
//XML/HTTP Binding can have only LogicalHandlerPipe
if (binding instanceof SOAPBinding) {
//Add MessageHandlerTube
HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
next = cousinHandlerTube = messageHandlerTube;
//Add SOAPHandlerTuber
HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
next = cousinHandlerTube = soapHandlerTube;
}
return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
}
/**
* Creates a {@link Tube} that performs SOAP mustUnderstand processing.
* This pipe should be before HandlerPipes.
*/
public Tube createClientMUTube(Tube next) {
if(binding instanceof SOAPBinding)
return new ClientMUTube(binding,next);
else
return next;
}
/**
* creates a {@link Tube} that validates messages against schema
*/
public Tube createValidationTube(Tube next) {
if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
return new ClientSchemaValidationTube(binding, wsdlModel, next);
else
return next;
}
/**
* Creates a transport pipe (for client), which becomes the terminal pipe.
*/
public Tube createTransportTube() {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
// The application may configure the endpoint address through request context
// using {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}. Let us
// defer the creation of actual transport until the service invocation,
// DeferredTransportPipe is used for this purpose.
return new DeferredTransportPipe(cl,this);
}
/**
* Gets the {@link Codec} that is set by {@link #setCodec} or the default codec
* based on the binding.
*
* @return codec to be used for web service requests
*/
public @NotNull Codec getCodec() {
return codec;
}
/**
* Interception point to change {@link Codec} during {@link Tube}line assembly. The
* new codec will be used by jax-ws client runtime for encoding/decoding web service
* request/response messages. The new codec should be used by the transport tubes.
*
* <p>
* the codec should correctly implement {@link Codec#copy} since it is used while
* serving requests concurrently.
*
* @param codec codec to be used for web service requests
*/
public void setCodec(@NotNull Codec codec) {
this.codec = codec;
}
}

View File

@@ -0,0 +1,241 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.xml.internal.ws.api.BindingID;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.server.EndpointAwareCodec;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
/**
* Encodes a {@link Message} (its XML infoset and attachments) to a sequence of bytes.
*
* <p>
* This interface provides pluggability for different ways of encoding XML infoset,
* such as plain XML (plus MIME attachments), XOP, and FastInfoset.
*
* <p>
* Transport usually needs a MIME content type of the encoding, so the {@link Codec}
* interface is designed to return this information. However, for some encoding
* (such as XOP), the encoding may actually change based on the actual content of
* {@link Message}, therefore the codec returns the content type as a result of encoding.
*
* <p>
* {@link Codec} does not produce transport-specific information, such as HTTP headers.
*
* <p>
* {@link Codec} implementations should be thread-safe; a codec instance could be used
* concurrently in multiple threads. If a codec have to generate or use a per-request
* state, the codec implementation must store the state in the Packet instead of using an
* instance variable of the codec implementation.
*
* <p>
* {@link BindingID} determines the {@link Codec}. See {@link BindingID#createEncoder(WSBinding)}.
*
* @author Kohsuke Kawaguchi
* @author shih-chang.chen@oracle.com
*
* @see EndpointAwareCodec
*/
public interface Codec {
/**
* Get the MIME type associated with this Codec.
* <p>
* If available the MIME type will represent the media that the codec
* encodes and decodes.
*
* The MIME type returned will be the most general representation independent
* of an instance of this MIME type utilized as a MIME content-type.
*
* @return
* null if the MIME type can't be determined by the <code>Codec</code>
* implementation. Otherwise the MIME type is returned.
*/
public String getMimeType();
/**
* If the MIME content-type of the encoding is known statically
* then this method returns it.
*
* <p>
* Transports often need to write the content type before it writes
* the message body, and since the encode method returns the content type
* after the body is written, it requires a buffering.
*
* For those {@link Codec}s that always use a constant content type,
* This method allows a transport to streamline the write operation.
*
* @return
* null if the content-type can't be determined in short of
* encodin the packet. Otherwise content type for this {@link Packet},
* such as "application/xml".
*/
ContentType getStaticContentType(Packet packet);
/**
* Encodes an XML infoset portion of the {@link Message}
* (from &lt;soap:Envelope> to &lt;/soap:Envelope>).
*
* <p>
* Internally, this method is most likely invoke {@link Message#writeTo(XMLStreamWriter)}
* to turn the message into infoset.
*
* @param packet
* @param out
* Must not be null. The caller is responsible for closing the stream,
* not the callee.
*
* @return
* The MIME content type of the encoded message (such as "application/xml").
* This information is often ncessary by transport.
*
* @throws IOException
* if a {@link OutputStream} throws {@link IOException}.
*/
ContentType encode( Packet packet, OutputStream out ) throws IOException;
/**
* The version of {@link #encode(Packet,OutputStream)}
* that writes to NIO {@link ByteBuffer}.
*
* <p>
* TODO: for the convenience of implementation, write
* an adapter that wraps {@link WritableByteChannel} to {@link OutputStream}.
*/
ContentType encode( Packet packet, WritableByteChannel buffer );
/*
* The following methods need to be documented and implemented.
*
* Such methods will be used by a client side
* transport pipe that implements the ClientEdgePipe.
*
String encode( InputStreamMessage message, OutputStream out ) throws IOException;
String encode( InputStreamMessage message, WritableByteChannel buffer );
*/
/**
* Creates a copy of this {@link Codec}.
*
* <p>
* Since {@link Codec} instance is not re-entrant, the caller
* who needs to encode two {@link Message}s simultaneously will
* want to have two {@link Codec} instances. That's what this
* method produces.
*
* <h3>Implentation Note</h3>
* <p>
* Note that this method might be invoked by one thread while
* another thread is executing one of the {@link #encode} methods.
* <!-- or otherwise you'd always have to maintain one idle copy -->
* <!-- just so that you can make copies from -->
* This should be OK because you'll be only copying things that
* are thread-safe, and creating new ones for thread-unsafe resources,
* but please let us know if this contract is difficult.
*
* @return
* always non-null valid {@link Codec} that performs
* the encoding work in the same way --- that is, if you
* copy an FI codec, you'll get another FI codec.
*
* <p>
* Once copied, two {@link Codec}s may be invoked from
* two threads concurrently; therefore, they must not share
* any state that requires isolation (such as temporary buffer.)
*
* <p>
* If the {@link Codec} implementation is already
* re-entrant and multi-thread safe to begin with,
* then this method may simply return <tt>this</tt>.
*/
Codec copy();
/**
* Reads bytes from {@link InputStream} and constructs a {@link Message}.
*
* <p>
* The design encourages lazy decoding of a {@link Message}, where
* a {@link Message} is returned even before the whole message is parsed,
* and additional parsing is done as the {@link Message} body is read along.
* A {@link Codec} is most likely have its own implementation of {@link Message}
* for this purpose.
*
* @param in
* the data to be read into a {@link Message}. The transport would have
* read any transport-specific header before it passes an {@link InputStream},
* and {@link InputStream} is expected to be read until EOS. Never null.
*
* <p>
* Some transports, such as SMTP, may 'encode' data into another format
* (such as uuencode, base64, etc.) It is the caller's responsibility to
* 'decode' these transport-level encoding before it passes data into
* {@link Codec}.
*
* @param contentType
* The MIME content type (like "application/xml") of this byte stream.
* Thie text includes all the sub-headers of the content-type header. Therefore,
* in more complex case, this could be something like
* <tt>multipart/related; boundary="--=_outer_boundary"; type="multipart/alternative"</tt>.
* This parameter must not be null.
*
* @param response
* The parsed {@link Message} will be set to this {@link Packet}.
* {@link Codec} may add additional properties to this {@link Packet}.
* On a successful method completion, a {@link Packet} must contain a
* {@link Message}.
*
* @throws IOException
* if {@link InputStream} throws an exception.
*/
void decode( InputStream in, String contentType, Packet response ) throws IOException;
/**
*
* @see #decode(InputStream, String, Packet)
*/
void decode( ReadableByteChannel in, String contentType, Packet response );
/*
* The following methods need to be documented and implemented.
*
* Such methods will be used by a server side
* transport pipe that can support the invocation of methods on a
* ServerEdgePipe.
*
XMLStreamReaderMessage decode( InputStream in, String contentType ) throws IOException;
XMLStreamReaderMessage decode( ReadableByteChannel in, String contentType );
*/
}

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.WSFeatureList;
/**
* Factory methods for some of the {@link Codec} implementations.
*
* <p>
* This class provides methods to create codecs for SOAP/HTTP binding.
* It allows to replace default SOAP envelope(primary part in MIME message)
* codec in the whole Codec.
*
* <p>
* This is a part of the JAX-WS RI internal API so that
* {@link Tube} and transport implementations can reuse the implementations
* done inside the JAX-WS.
*
* @author Jitendra Kotamraju
* @author Kohsuke Kawaguchi
*/
public abstract class Codecs {
/**
* This creates a full {@link Codec} for SOAP binding.
*
* @param feature the WebServiceFeature objects
* @return non null codec to parse entire SOAP message(including MIME parts)
*/
public static @NotNull SOAPBindingCodec createSOAPBindingCodec(WSFeatureList feature) {
return new com.sun.xml.internal.ws.encoding.SOAPBindingCodec(feature);
}
/**
* This creates a full {@link Codec} for XML binding.
*
* @param feature the WebServiceFeature objects
* @return non null codec to parse entire XML message.
*/
public static @NotNull Codec createXMLCodec(WSFeatureList feature) {
return new com.sun.xml.internal.ws.encoding.XMLHTTPBindingCodec(feature);
}
/**
* This creates a full {@link Codec} for SOAP binding using the primary
* XML codec argument. The codec argument is used to encode/decode SOAP envelopes
* while the returned codec is responsible for encoding/decoding the whole
* message.
*
* <p>
* Creates codecs can be set during the {@link Tube}line assembly process.
*
* @see ServerTubeAssemblerContext#setCodec(Codec)
* @see ClientTubeAssemblerContext#setCodec(Codec)
*
* @param binding binding of the webservice
* @param xmlEnvelopeCodec SOAP envelope codec
* @return non null codec to parse entire SOAP message(including MIME parts)
*/
public static @NotNull SOAPBindingCodec createSOAPBindingCodec(WSBinding binding, StreamSOAPCodec xmlEnvelopeCodec) {
return new com.sun.xml.internal.ws.encoding.SOAPBindingCodec(binding.getFeatures(), xmlEnvelopeCodec);
}
/**
* Creates a default {@link Codec} that can be used to used to
* decode XML infoset in SOAP envelope(primary part in MIME message). New codecs
* can be written using this codec as delegate.
*
* @param version SOAP version of the binding
* @return non null default xml codec
*/
public static @NotNull
StreamSOAPCodec createSOAPEnvelopeXmlCodec(@NotNull SOAPVersion version) {
return com.sun.xml.internal.ws.encoding.StreamSOAPCodec.create(version);
}
/**
* Creates a default {@link Codec} that can be used to used to
* decode XML infoset in SOAP envelope(primary part in MIME message).
* New codecs can be written using this codec as delegate. WSBinding
* parameter is used to get SOAP version and features.
*
* @param binding SOAP version and features are used from this binding
* @return non null default xml codec
*
* @deprecated use {@link #createSOAPEnvelopeXmlCodec(WSFeatureList)}
*/
public static @NotNull StreamSOAPCodec createSOAPEnvelopeXmlCodec(@NotNull WSBinding binding) {
return com.sun.xml.internal.ws.encoding.StreamSOAPCodec.create(binding);
}
/**
* Creates a default {@link Codec} that can be used to used to
* decode XML infoset in SOAP envelope(primary part in MIME message).
* New codecs can be written using this codec as delegate. WSFeatureList
* parameter is used to get SOAP version and features.
*
* @param features SOAP version and features are used from this WSFeatureList
* @return non null default xml codec
*/
public static @NotNull StreamSOAPCodec createSOAPEnvelopeXmlCodec(@NotNull WSFeatureList features) {
return com.sun.xml.internal.ws.encoding.StreamSOAPCodec.create(features);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
/**
* A Content-Type transport header that will be returned by {@link Codec#encode(com.sun.xml.internal.ws.api.message.Packet, java.io.OutputStream)}.
* It will provide the Content-Type header and also take care of SOAP 1.1 SOAPAction header.
*
* @see com.oracle.webservices.internal.api.message.ContentType
* TODO: rename to ContentMetadata?
*
* @author Vivek Pandey
*/
public interface ContentType extends com.oracle.webservices.internal.api.message.ContentType {
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.api.server.ContainerResolver;
/**
* Collection of {@link Fiber}s.
* Owns an {@link Executor} to run them.
*
* @author Kohsuke Kawaguchi
* @author Jitendra Kotamraju
*/
public class Engine {
private volatile Executor threadPool;
public final String id;
private final Container container;
String getId() { return id; }
Container getContainer() { return container; }
Executor getExecutor() { return threadPool; }
public Engine(String id, Executor threadPool) {
this(id, ContainerResolver.getDefault().getContainer(), threadPool);
}
public Engine(String id, Container container, Executor threadPool) {
this(id, container);
this.threadPool = threadPool != null ? wrap(threadPool) : null;
}
public Engine(String id) {
this(id, ContainerResolver.getDefault().getContainer());
}
public Engine(String id, Container container) {
this.id = id;
this.container = container;
}
public void setExecutor(Executor threadPool) {
this.threadPool = threadPool != null ? wrap(threadPool) : null;
}
void addRunnable(Fiber fiber) {
if(threadPool==null) {
synchronized(this) {
threadPool = wrap(Executors.newCachedThreadPool(new DaemonThreadFactory()));
}
}
threadPool.execute(fiber);
}
private Executor wrap(Executor ex) {
return ContainerResolver.getDefault().wrapExecutor(container, ex);
}
/**
* Creates a new fiber in a suspended state.
*
* <p>
* To start the returned fiber, call {@link Fiber#start(Tube,Packet,Fiber.CompletionCallback)}.
* It will start executing the given {@link Tube} with the given {@link Packet}.
*
* @return new Fiber
*/
public Fiber createFiber() {
return new Fiber(this);
}
private static class DaemonThreadFactory implements ThreadFactory {
static final AtomicInteger poolNumber = new AtomicInteger(1);
final AtomicInteger threadNumber = new AtomicInteger(1);
final String namePrefix;
DaemonThreadFactory() {
namePrefix = "jaxws-engine-" + poolNumber.getAndIncrement() + "-thread-";
}
public Thread newThread(Runnable r) {
Thread t = new Thread(null, r, namePrefix + threadNumber.getAndIncrement(), 0);
if (!t.isDaemon()) {
t.setDaemon(true);
}
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,105 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* Interception for {@link Fiber} context switch.
*
* <p>
* Even though pipeline runs asynchronously, sometimes it's desirable
* to bind some state to the current thread running a fiber. Such state
* may include security subject (in terms of {@link AccessController#doPrivileged}),
* or a transaction.
*
* <p>
* This mechanism makes it possible to do such things, by allowing
* some code to be executed before and after a thread executes a fiber.
*
* <p>
* The design also encapsulates the entire fiber execution in a single
* opaque method invocation {@link Work#execute}, allowing the use of
* <tt>finally</tt> block.
*
*
* @author Kohsuke Kawaguchi
*/
public interface FiberContextSwitchInterceptor {
/**
* Allows the interception of the fiber execution.
*
* <p>
* This method needs to be implemented like this:
*
* <pre>
* &lt;R,P> R execute( Fiber f, P p, Work&lt;R,P> work ) {
* // do some preparation work
* ...
* try {
* // invoke
* return work.execute(p);
* } finally {
* // do some clean up work
* ...
* }
* }
* </pre>
*
* <p>
* While somewhat unintuitive,
* this interception mechanism enables the interceptor to wrap
* the whole fiber execution into a {@link AccessController#doPrivileged(PrivilegedAction)},
* for example.
*
* @param f
* {@link Fiber} to be executed.
* @param p
* The opaque parameter value for {@link Work}. Simply pass this value to
* {@link Work#execute(Object)}.
* @return
* The opaque return value from the the {@link Work}. Simply return
* the value from {@link Work#execute(Object)}.
*/
<R,P> R execute( Fiber f, P p, Work<R,P> work );
/**
* Abstraction of the execution that happens inside the interceptor.
*/
interface Work<R,P> {
/**
* Have the current thread executes the current fiber,
* and returns when it stops doing so.
*
* <p>
* The parameter and the return value is controlled by the
* JAX-WS runtime, and interceptors should simply treat
* them as opaque values.
*/
R execute(P param);
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
/**
* Factory for (@link FiberContextSwitchInterceptor} instances
*
* @since 2.2.6
*/
public interface FiberContextSwitchInterceptorFactory {
/**
* Creates {@link FiberContextSwitchInterceptor} instance.
* @return interceptor instance
*/
public FiberContextSwitchInterceptor create();
}

View File

@@ -0,0 +1,272 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.xml.internal.ws.api.message.Packet;
import java.util.concurrent.Executor;
/**
* Indicates what shall happen after {@link Tube#processRequest(Packet)} or
* {@link Tube#processResponse(Packet)} returns.
*
* <p>
* To allow reuse of this object, this class is mutable.
*
* @author Kohsuke Kawaguchi
*/
public final class NextAction {
int kind;
Tube next;
Packet packet;
/**
* Really either {@link RuntimeException} or {@link Error}.
*/
Throwable throwable;
Runnable onExitRunnable;
// public enum Kind { INVOKE, INVOKE_AND_FORGET, RETURN, SUSPEND }
static final int INVOKE = 0;
static final int INVOKE_AND_FORGET = 1;
static final int RETURN = 2;
static final int THROW = 3;
static final int SUSPEND = 4;
// Used to abort processResponse chain if a fatal exception is encountered
static final int THROW_ABORT_RESPONSE = 5;
// Used to abort processResponse chain if a response should be aborted
static final int ABORT_RESPONSE = 6;
// Used to switch a tubeline from synchronous to asynchronous execution
// with respect to the thread that started this tubeline.
static final int INVOKE_ASYNC = 7;
private void set(int k, Tube v, Packet p, Throwable t) {
this.kind = k;
this.next = v;
this.packet = p;
this.throwable = t;
}
/**
* Indicates that the next action should be to
* invoke the next tube's {@link Tube#processRequest(Packet)},
* then later invoke the current tube's {@link Tube#processResponse(Packet)}
* with the response packet.
*/
public void invoke(Tube next, Packet p) {
set(INVOKE, next, p, null);
}
/**
* Indicates that the next action should be to
* invoke the next tube's {@link Tube#processRequest(Packet)},
* but the current tube doesn't want to receive the response packet to
* its {@link Tube#processResponse(Packet)}.
*/
public void invokeAndForget(Tube next, Packet p) {
set(INVOKE_AND_FORGET, next, p, null);
}
/**
* Indicates that the next action is to flip the processing direction
* and starts response processing.
*/
public void returnWith( Packet response ) {
set(RETURN, null, response, null);
}
/**
* Indicates that the next action is to flip the processing direction
* and starts exception processing, but with the indicated context.
*
* @param t
* Either {@link RuntimeException} or {@link Error}, but defined to
* take {@link Throwable} because {@link Tube#processException(Throwable)}
* takes {@link Throwable}.
*/
public void throwException( Packet response, Throwable t ) {
// Use of RETURN is correct -- Fiber processing does not set packet for type of THROW
set(RETURN, null, response, t);
}
/**
* Indicates that the next action is to flip the processing direction
* and starts exception processing.
*
* @param t
* Either {@link RuntimeException} or {@link Error}, but defined to
* take {@link Throwable} because {@link Tube#processException(Throwable)}
* takes {@link Throwable}.
*/
public void throwException(Throwable t) {
assert t instanceof RuntimeException || t instanceof Error;
set(THROW,null,null,t);
}
/**
* Indicates that the next action is to abort the processResponse chain
* because of an exception. How that exception is processed is not
* defined.
*
* @param t
* Either {@link RuntimeException} or {@link Error}
*/
public void throwExceptionAbortResponse(Throwable t) {
set(THROW_ABORT_RESPONSE,null,null,t);
}
/**
* Indicates that the next action is to abort the processResponse chain
* because of some non-exception condition.
*
* @param response The response that is being aborted
*/
public void abortResponse(Packet response) {
set(ABORT_RESPONSE,null,response,null);
}
/**
* Indicates that the next action is to invoke the next tube in the
* tubeline async from the thread that started the tubeline. Only fibers
* that were started using startSync should use this next action kind.
* @param next The next tube in the tubeline
* @param p The request to pass to the next tube
*/
public void invokeAsync(Tube next, Packet p) {
set(INVOKE_ASYNC,next,p,null);
}
/**
* Indicates that the fiber should be suspended.
* Once {@link Fiber#resume(Packet) resumed}, return the response processing.
* @deprecated Use variants that pass {@link Runnable}
*/
public void suspend() {
suspend(null, null);
}
/**
* Indicates that the fiber should be suspended. Once the current {@link Thread}
* exits the fiber's control loop, the onExitRunnable will be invoked. This {@link Runnable}
* may call {@link Fiber#resume(Packet)}; however it is still guaranteed that the current
* Thread will return control, therefore, further processing will be handled on a {@link Thread}
* from the {@link Executor}. For synchronous cases, the Thread invoking this fiber cannot return
* until fiber processing is complete; therefore, the guarantee is only that the onExitRunnable
* will be invoked prior to completing the suspension.
* @since 2.2.7
*/
public void suspend(Runnable onExitRunnable) {
suspend(null, onExitRunnable);
}
/**
* Indicates that the fiber should be suspended.
* Once {@link Fiber#resume(Packet) resumed}, resume with the
* {@link Tube#processRequest(Packet)} on the given next tube.
* @deprecated Use variants that pass {@link Runnable}
*/
public void suspend(Tube next) {
suspend(next, null);
}
/**
* Indicates that the fiber should be suspended. Once the current {@link Thread}
* exits the fiber's control loop, the onExitRunnable will be invoked. This {@link Runnable}
* may call {@link Fiber#resume(Packet)}; however it is still guaranteed that the current
* fiber will return control, therefore, further processing will be handled on a {@link Thread}
* from the {@link Executor}. For synchronous cases, the Thread invoking this fiber cannot return
* until fiber processing is complete; therefore, the guarantee is only that the onExitRunnable
* will be invoked prior to completing the suspension.
* <p>
* Once {@link Fiber#resume(Packet) resumed}, resume with the
* {@link Tube#processRequest(Packet)} on the given next tube.
* @since 2.2.7
*/
public void suspend(Tube next, Runnable onExitRunnable) {
set(SUSPEND, next, null, null);
this.onExitRunnable = onExitRunnable;
}
/** Returns the next tube
* @return Next tube
*/
public Tube getNext() {
return next;
}
/** Sets the next tube
* @param next Next tube
*/
public void setNext(Tube next) {
this.next = next;
}
/**
* Returns the last Packet
* @return Packet
*/
public Packet getPacket() {
return packet;
}
/**
* Returns the Throwable generated by the last Tube
* @return the Throwable
*/
public Throwable getThrowable() {
return throwable;
}
/**
* Dumps the contents to assist debugging.
*/
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(super.toString()).append(" [");
buf.append("kind=").append(getKindString()).append(',');
buf.append("next=").append(next).append(',');
buf.append("packet=").append(packet != null ? packet.toShortString() : null).append(',');
buf.append("throwable=").append(throwable).append(']');
return buf.toString();
}
/**
* Returns {@link #kind} in a human readable string, to assist debugging.
*/
public String getKindString() {
switch(kind) {
case INVOKE: return "INVOKE";
case INVOKE_AND_FORGET: return "INVOKE_AND_FORGET";
case RETURN: return "RETURN";
case THROW: return "THROW";
case SUSPEND: return "SUSPEND";
case THROW_ABORT_RESPONSE: return "THROW_ABORT_RESPONSE";
case ABORT_RESPONSE: return "ABORT_RESPONSE";
case INVOKE_ASYNC: return "INVOKE_ASYNC";
default: throw new AssertionError(kind);
}
}
}

View File

@@ -0,0 +1,346 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterPipeImpl;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractPipeImpl;
import javax.annotation.PreDestroy;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
/**
* Abstraction of the intermediate layers in the processing chain
* and transport.
*
* <h2>What is a {@link Pipe}?</h2>
* <p>
* Transport is a kind of pipe. It sends the {@link Packet}
* through, say, HTTP connection, and receives the data back into another {@link Packet}.
*
* <p>
* More often, a pipe is a filter. It acts on a packet,
* and then it passes the packet into another pipe. It can
* do the same on the way back.
*
* <p>
* For example, XWSS will be a {@link Pipe}
* that delegates to another {@link Pipe}, and it can wrap a {@link Packet} into
* another {@link Packet} to encrypt the body and add a header, for example.
*
* <p>
* Yet another kind of filter pipe is those that wraps {@link LogicalHandler}
* and {@link SOAPHandler}. These pipes are heavy-weight; they often consume
* a message in a packet and create a new one, and then pass it to the next pipe.
* For performance reason it probably makes sense to have one {@link Pipe}
* instance that invokes a series of {@link LogicalHandler}s, another one
* for {@link SOAPHandler}.
*
* <p>
* There would be a {@link Pipe} implementation that invokes {@link Provider}.
* There would be a {@link Pipe} implementation that invokes a service method
* on the user's code.
* There would be a {@link Dispatch} implementation that invokes a {@link Pipe}.
*
* <p>
* WS-MEX can be implemented as a {@link Pipe} that looks for
* {@link Message#getPayloadNamespaceURI()} and serves the request.
*
*
* <h2>Pipe Lifecycle</h2>
* {@link Pipe}line is expensive to set up, so once it's created it will be reused.
* A {@link Pipe}line is not reentrant; one pipeline is used to process one request/response
* at at time. The same pipeline instance may serve request/response for different threads,
* if one comes after another and they don't overlap.
* <p>
* Where a need arises to process multiple requests concurrently, a pipeline
* gets cloned through {@link PipeCloner}. Note that this need may happen on
* both server (because it quite often serves multiple requests concurrently)
* and client (because it needs to support asynchronous method invocations.)
* <p>
* Created pipelines (including cloned ones and the original) may be discarded and GCed
* at any time at the discretion of whoever owns pipelines. Pipes can, however, expect
* at least one copy (or original) of pipeline to live at any given time while a pipeline
* owner is interested in the given pipeline configuration (in more concerete terms,
* for example, as long as a dispatch object lives, it's going to keep at least one
* copy of a pipeline alive.)
* <p>
* Before a pipeline owner dies, it may invoke {@link #preDestroy()} on the last
* remaining pipeline. It is "may" for pipeline owners that live in the client-side
* of JAX-WS (such as dispatches and proxies), but it is a "must" for pipeline owners
* that live in the server-side of JAX-WS.
* <p>
* This last invocation gives a chance for some pipes to clean up any state/resource
* acquired (such as WS-RM's sequence, WS-Trust's SecurityToken), although as stated above,
* this is not required for clients.
*
*
*
* <h2>Pipe and State</h2>
* <p>
* The lifecycle of pipelines is designed to allow a {@link Pipe} to store various
* state in easily accessible fashion.
*
*
* <h3>Per-packet state</h3>
* <p>
* Any information that changes from a packet to packet should be
* stored in {@link Packet}. This includes information like
* transport-specific headers.
*
* <h3>Per-thread state</h3>
* <p>
* Any expensive objects that are non-reentrant can be stored in
* instance variables of a {@link Pipe}, since {@link #process(Packet)} is
* non reentrant. When a pipe is copied, new instances should be allocated
* so that two {@link Pipe} instances don't share thread-unsafe resources.
* This includes things like canonicalizers, JAXB unmarshallers, buffers,
* and so on.
*
* <h3>Per-proxy/per-endpoint state</h3>
* <p>
* Information that is tied to a particular proxy/dispatch can be stored
* in a separate object that is referenced from a pipe. When
* a new pipe is copied, you can simply hand out a reference to the newly
* created one, so that all copied pipes refer to the same instance.
* See the following code as an example:
*
* <pre>
* class PipeImpl {
* // this object stores per-proxy state
* class DataStore {
* int counter;
* }
*
* private DataStore ds;
*
* // create a fresh new pipe
* public PipeImpl(...) {
* ....
* ds = new DataStore();
* }
*
* // copy constructor
* private PipeImpl(PipeImpl that, PipeCloner cloner) {
* cloner.add(that,this);
* ...
* this.ds = that.ds;
* }
*
* public PipeImpl copy(PipeCloner pc) {
* return new PipeImpl(this,pc);
* }
* }
* </pre>
*
* <p>
* Note that access to such resource often needs to be synchronized,
* since multiple copies of pipelines may execute concurrently.
*
* <p>
* If such information is read-only,
* it can be stored as instance variables of a pipe,
* and its reference copied as pipes get copied. (The only difference between
* this and per-thread state is that you just won't allocate new things when
* pipes get copied here.)
*
*
* <h3>VM-wide state</h3>
* <p>
* <tt>static</tt> is always there for you to use.
*
*
*
* <h2>Pipes and Handlers</h2>
* <p>
* JAX-WS has a notion of {@link LogicalHandler} and {@link SOAPHandler}, and
* we intend to have one {@link Pipe} implementation that invokes all the
* {@link LogicalHandler}s and another {@link Pipe} implementation that invokes
* all the {@link SOAPHandler}s. Those implementations need to convert a {@link Message}
* into an appropriate format, but grouping all the handlers together eliminates
* the intermediate {@link Message} instanciation between such handlers.
* <p>
* This grouping also allows such implementations to follow the event notifications
* to handlers (i.e. {@link Handler#close(MessageContext)} method.
*
*
* <pre>
* TODO: Possible types of pipe:
* creator: create message from wire
* to SAAJ SOAP message
* to cached representation
* directly to JAXB beans
* transformer: transform message from one representation to another
* JAXB beans to encoded SOAP message
* StAX writing + JAXB bean to encoded SOAP message
* modifier: modify message
* add SOAP header blocks
* security processing
* header block processor:
* process certain SOAP header blocks
* outbound initiator: input from the client
* Manage input e.g. JAXB beans and associated with parts of the SOAP message
* inbound invoker: invoke the service
* Inkoke SEI, e.g. EJB or SEI in servlet.
* </pre>
*
* @see AbstractPipeImpl
* @see AbstractFilterPipeImpl
* @deprecated
* Use {@link Tube}.
*/
public interface Pipe {
/**
* Sends a {@link Packet} and returns a response {@link Packet} to it.
*
* @throws WebServiceException
* On the server side, this signals an error condition where
* a fault reply is in order (or the exception gets eaten by
* the top-most transport {@link Pipe} if it's one-way.)
* This frees each {@link Pipe} from try/catching a
* {@link WebServiceException} in every layer.
*
* Note that this method is also allowed to return a {@link Packet}
* that has a fault as the payload.
*
* <p>
* On the client side, the {@link WebServiceException} thrown
* will be propagated all the way back to the calling client
* applications. (The consequence of that is that if you are
* a filtering {@link Pipe}, you must not catch the exception
* that your next {@link Pipe} threw.
*
* @throws RuntimeException
* Other runtime exception thrown by this method must
* be treated as a bug in the pipe implementation,
* and therefore should not be converted into a fault.
* (Otherwise it becomes very difficult to debug implementation
* problems.)
*
* <p>
* On the server side, this exception should be most likely
* just logged. On the client-side it gets propagated to the
* client application.
*
* <p>
* The consequence of this is that if a pipe calls
* into an user application (such as {@link SOAPHandler}
* or {@link LogicalHandler}), where a {@link RuntimeException}
* is *not* a bug in the JAX-WS implementation, it must be catched
* and wrapped into a {@link WebServiceException}.
*
* @param request
* The packet that represents a request message. Must not be null.
* If the packet has a non-null message, it must be a valid
* unconsumed {@link Message}. This message represents the
* SOAP message to be sent as a request.
* <p>
* The packet is also allowed to carry no message, which indicates
* that this is an output-only request.
* (that's called "solicit", right? - KK)
*
* @return
* The packet that represents a response message. Must not be null.
* If the packet has a non-null message, it must be
* a valid unconsumed {@link Message}. This message represents
* a response to the request message passed as a parameter.
* <p>
* The packet is also allowed to carry no message, which indicates
* that there was no response. This is used for things like
* one-way message and/or one-way transports.
*/
Packet process( Packet request);
/**
* Invoked before the last copy of the pipeline is about to be discarded,
* to give {@link Pipe}s a chance to clean up any resources.
*
* <p>
* This can be used to invoke {@link PreDestroy} lifecycle methods
* on user handler. The invocation of it is optional on the client side,
* but mandatory on the server side.
*
* <p>
* When multiple copies of pipelines are created, this method is called
* only on one of them.
*
* @throws WebServiceException
* If the clean up fails, {@link WebServiceException} can be thrown.
* This exception will be propagated to users (if this is client),
* or recorded (if this is server.)
*/
void preDestroy();
/**
* Creates an identical clone of this {@link Pipe}.
*
* <p>
* This method creates an identical pipeline that can be used
* concurrently with this pipeline. When the caller of a pipeline
* is multi-threaded and need concurrent use of the same pipeline,
* it can do so by creating copies through this method.
*
* <h3>Implementation Note</h3>
* <p>
* It is the implementation's responsibility to call
* {@link PipeCloner#add(Pipe,Pipe)} to register the copied pipe
* with the original. This is required before you start copying
* the other {@link Pipe} references you have, or else there's a
* risk of infinite recursion.
* <p>
* For most {@link Pipe} implementations that delegate to another
* {@link Pipe}, this method requires that you also copy the {@link Pipe}
* that you delegate to.
* <p>
* For limited number of {@link Pipe}s that do not maintain any
* thread unsafe resource, it is allowed to simply return <tt>this</tt>
* from this method (notice that even if you are stateless, if you
* got a delegating {@link Pipe} and that one isn't stateless, you
* still have to copy yourself.)
*
* <p>
* Note that this method might be invoked by one thread while another
* thread is executing the {@link #process(Packet)} method. See
* the {@link Codec#copy()} for more discussion about this.
*
* @param cloner
* Use this object (in particular its {@link PipeCloner#copy(Pipe)} method
* to clone other pipe references you have
* in your pipe. See {@link PipeCloner} for more discussion
* about why.
*
* @return
* always non-null {@link Pipe}.
*/
Pipe copy(PipeCloner cloner);
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import java.util.Map;
/**
* Clones the whole pipeline.
*
* <p>
* Since {@link Pipe}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.
*
* @deprecated
* Use {@link TubeCloner}.
* @author Kohsuke Kawaguchi
*/
public abstract class PipeCloner extends TubeCloner {
/**
* {@link Pipe} version of {@link #clone(Tube)}
*/
public static Pipe clone(Pipe p) {
return new PipeClonerImpl().copy(p);
}
// no need to be constructed publicly. always use the static clone method.
/*package*/ PipeCloner(Map<Object,Object> master2copy) {
super(master2copy);
}
/**
* {@link Pipe} version of {@link #copy(Tube)}
*/
@SuppressWarnings("unchecked")
public abstract <T extends Pipe> T copy(T p);
/**
* The {@link Pipe} version of {@link #add(Tube, Tube)}.
*/
public abstract void add(Pipe original, Pipe copy);
}

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import java.util.logging.Level;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractTubeImpl;
/**
* Clones the whole pipeline.
*
* <p>
* Since {@link Pipe}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
*/
@SuppressWarnings("deprecation")
public class PipeClonerImpl extends PipeCloner {
private static final Logger LOGGER = Logger.getLogger(PipeClonerImpl.class.getName());
// no need to be constructed publicly. always use the static clone method.
/*package*/ public PipeClonerImpl() {
super(new HashMap<Object,Object>());
}
protected PipeClonerImpl(Map<Object,Object> master2copy) {
super(master2copy);
}
/**
* {@link Pipe} version of {@link #copy(Tube)}
*/
@SuppressWarnings("unchecked")
public <T extends Pipe> T copy(T p) {
Pipe r = (Pipe)master2copy.get(p);
if(r==null) {
r = p.copy(this);
// the pipe must puts its copy to the map by itself
assert master2copy.get(p)==r : "the pipe must call the add(...) method to register itself before start copying other pipes, but "+p+" hasn't done so";
}
return (T)r;
}
/**
* The {@link Pipe} version of {@link #add(Tube, Tube)}.
*/
public void add(Pipe original, Pipe copy) {
assert !master2copy.containsKey(original);
assert original!=null && copy!=null;
master2copy.put(original,copy);
}
/**
* Disambiguation version.
*/
public void add(AbstractTubeImpl original, AbstractTubeImpl copy) {
add((Tube)original,copy);
}
@Override
public void add(Tube original, Tube copy) {
assert !master2copy.containsKey(original);
assert original!=null && copy!=null;
master2copy.put(original,copy);
}
@SuppressWarnings("unchecked")
@Override
public <T extends Tube> T copy(T t) {
Tube r = (Tube)master2copy.get(t);
if(r==null) {
if (t != null) {
r = t.copy(this);
} else {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.fine("WARNING, tube passed to 'copy' in " + this + " was null, so no copy was made");
}
}
}
return (T)r;
}
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.server.WSEndpoint;
import com.sun.xml.internal.ws.api.WSService;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
/**
* Creates a pipeline.
*
* <p>
* This pluggability layer enables the upper layer to
* control exactly how the pipeline is composed.
*
* <p>
* JAX-WS is going to have its own default implementation
* when used all by itself, but it can be substituted by
* other implementations.
*
* <p>
* See {@link PipelineAssemblerFactory} for how {@link PipelineAssembler}s
* are located.
*
* <p>
* TODO: the JAX-WS team felt that no {@link Pipe} should be relying
* on the {@link SEIModel}, so it is no longer given to the assembler.
* Talk to us if you need it.
*
* @see ClientPipeAssemblerContext
*
* @author Kohsuke Kawaguchi
*/
public interface PipelineAssembler {
/**
* Creates a new pipeline for clients.
*
* <p>
* When a JAX-WS client creates a proxy or a {@link Dispatch} from
* a {@link Service}, JAX-WS runtime internally uses this method
* to create a new pipeline as a part of the initilization.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the pipeline to be assembled.
*
* @return
* non-null freshly created pipeline.
*
* @throws WebServiceException
* if there's any configuration error that prevents the
* pipeline from being constructed. This exception will be
* propagated into the application, so it must have
* a descriptive error.
*/
@NotNull Pipe createClient(@NotNull ClientPipeAssemblerContext context);
/**
* Creates a new pipeline for servers.
*
* <p>
* When a JAX-WS server deploys a new endpoint, it internally
* uses this method to create a new pipeline as a part of the
* initialization.
*
* <p>
* Note that this method is called only once to set up a
* 'master pipeline', and it gets {@link Pipe#copy(PipeCloner) copied}
* from it.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the pipeline to be assembled.
*
* @return
* non-null freshly created pipeline.
*
* @throws WebServiceException
* if there's any configuration error that prevents the
* pipeline from being constructed. This exception will be
* propagated into the container, so it must have
* a descriptive error.
*
*/
@NotNull Pipe createServer(@NotNull ServerPipeAssemblerContext context);
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.xml.internal.ws.api.BindingID;
import com.sun.xml.internal.ws.util.ServiceFinder;
import javax.xml.ws.soap.SOAPBinding;
import java.util.logging.Logger;
/**
* Creates {@link PipelineAssembler}.
*
* <p>
* To create a pipeline,
* the JAX-WS runtime locates {@link PipelineAssemblerFactory}s through
* the <tt>META-INF/services/com.sun.xml.internal.ws.api.pipe.PipelineAssemblerFactory</tt> files.
* Factories found are checked to see if it supports the given binding ID one by one,
* and the first valid {@link PipelineAssembler} returned will be used to create
* a pipeline.
*
* <p>
* TODO: is bindingId really extensible? for this to be extensible,
* someone seems to need to hook into WSDL parsing.
*
* <p>
* TODO: JAX-WSA might not define its own binding ID -- it may just go to an extension element
* of WSDL. So this abstraction might need to be worked on.
*
* @author Kohsuke Kawaguchi
* @deprecated
* Use {@link TubelineAssemblerFactory} instead.
*/
public abstract class PipelineAssemblerFactory {
/**
* Creates a {@link PipelineAssembler} applicable for the given binding ID.
*
* @param bindingId
* The binding ID for which a pipeline will be created,
* such as {@link SOAPBinding#SOAP11HTTP_BINDING}.
* Must not be null.
*
* @return
* null if this factory doesn't recognize the given binding ID.
*/
public abstract PipelineAssembler doCreate(BindingID bindingId);
/**
* Locates {@link PipelineAssemblerFactory}s and create
* a suitable {@link PipelineAssembler}.
*
* @param bindingId
* The binding ID string for which the new {@link PipelineAssembler}
* is created. Must not be null.
* @return
* Always non-null, since we fall back to our default {@link PipelineAssembler}.
*/
public static PipelineAssembler create(ClassLoader classLoader, BindingID bindingId) {
for (PipelineAssemblerFactory factory : ServiceFinder.find(PipelineAssemblerFactory.class,classLoader)) {
PipelineAssembler assembler = factory.doCreate(bindingId);
if(assembler!=null) {
logger.fine(factory.getClass()+" successfully created "+assembler);
return assembler;
}
}
// default binding IDs that are known
// TODO: replace this with proper ones
return new com.sun.xml.internal.ws.util.pipe.StandalonePipeAssembler();
}
private static final Logger logger = Logger.getLogger(PipelineAssemblerFactory.class.getName());
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Message;
import javax.xml.stream.XMLStreamReader;
/**
*
*
* @see com.sun.xml.internal.ws.api.pipe.Codecs
* @author Jitendra Kotamraju
*/
public interface SOAPBindingCodec extends Codec {
StreamSOAPCodec getXMLCodec();
}

View File

@@ -0,0 +1,115 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.api.server.WSEndpoint;
import java.io.PrintStream;
/**
* Factory for well-known server {@link Pipe} implementations
* that the {@link PipelineAssembler} needs to use
* to satisfy JAX-WS requirements.
*
* @author Jitendra Kotamraju
* @deprecated Use {@link ServerTubeAssemblerContext}.
*/
public final class ServerPipeAssemblerContext extends ServerTubeAssemblerContext {
public ServerPipeAssemblerContext(@Nullable SEIModel seiModel, @Nullable WSDLPort wsdlModel, @NotNull WSEndpoint endpoint, @NotNull Tube terminal, boolean isSynchronous) {
super(seiModel, wsdlModel, endpoint, terminal, isSynchronous);
}
/**
* Creates a {@link Pipe} that performs SOAP mustUnderstand processing.
* This pipe should be before HandlerPipes.
*/
public @NotNull Pipe createServerMUPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createServerMUTube(PipeAdapter.adapt(next)));
}
/**
* creates a {@link Pipe} that dumps messages that pass through.
*/
public Pipe createDumpPipe(String name, PrintStream out, Pipe next) {
return PipeAdapter.adapt(super.createDumpTube(name, out, PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that does the monitoring of the invocation for a
* container
*/
public @NotNull Pipe createMonitoringPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createMonitoringTube(PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that adds container specific security
*/
public @NotNull Pipe createSecurityPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createSecurityTube(PipeAdapter.adapt(next)));
}
/**
* creates a {@link Pipe} that validates messages against schema
*/
public @NotNull Pipe createValidationPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createValidationTube(PipeAdapter.adapt(next)));
}
/**
* Creates a {@link Pipe} that invokes protocol and logical handlers.
*/
public @NotNull Pipe createHandlerPipe(@NotNull Pipe next) {
return PipeAdapter.adapt(super.createHandlerTube(PipeAdapter.adapt(next)));
}
/**
* The last {@link Pipe} in the pipeline. The assembler is expected to put
* additional {@link Pipe}s in front of it.
*
* <p>
* (Just to give you the idea how this is used, normally the terminal pipe
* is the one that invokes the user application or {@link javax.xml.ws.Provider}.)
*
* @return always non-null terminal pipe
*/
public @NotNull Pipe getTerminalPipe() {
return PipeAdapter.adapt(super.getTerminalTube());
}
/**
* Creates WS-Addressing pipe
*/
public Pipe createWsaPipe(Pipe next) {
return PipeAdapter.adapt(super.createWsaTube(PipeAdapter.adapt(next)));
}
}

View File

@@ -0,0 +1,256 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.addressing.W3CWsaServerTube;
import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionWsaServerTube;
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.api.server.ServerPipelineHook;
import com.sun.xml.internal.ws.api.server.WSEndpoint;
import com.sun.xml.internal.ws.binding.BindingImpl;
import com.sun.xml.internal.ws.developer.SchemaValidationFeature;
import com.sun.xml.internal.ws.handler.HandlerTube;
import com.sun.xml.internal.ws.handler.ServerLogicalHandlerTube;
import com.sun.xml.internal.ws.handler.ServerMessageHandlerTube;
import com.sun.xml.internal.ws.handler.ServerSOAPHandlerTube;
import com.sun.xml.internal.ws.protocol.soap.ServerMUTube;
import com.sun.xml.internal.ws.server.ServerSchemaValidationTube;
import com.sun.xml.internal.ws.util.pipe.DumpTube;
import javax.xml.ws.soap.SOAPBinding;
import java.io.PrintStream;
/**
* Factory for well-known server {@link Tube} implementations
* that the {@link TubelineAssembler} needs to use
* to satisfy JAX-WS requirements.
*
* @author Jitendra Kotamraju
*/
public class ServerTubeAssemblerContext {
private final SEIModel seiModel;
private final WSDLPort wsdlModel;
private final WSEndpoint endpoint;
private final BindingImpl binding;
private final Tube terminal;
private final boolean isSynchronous;
private @NotNull Codec codec;
public ServerTubeAssemblerContext(@Nullable SEIModel seiModel,
@Nullable WSDLPort wsdlModel, @NotNull WSEndpoint endpoint,
@NotNull Tube terminal, boolean isSynchronous) {
this.seiModel = seiModel;
this.wsdlModel = wsdlModel;
this.endpoint = endpoint;
this.terminal = terminal;
// WSBinding is actually BindingImpl
this.binding = (BindingImpl)endpoint.getBinding();
this.isSynchronous = isSynchronous;
this.codec = this.binding.createCodec();
}
/**
* The created pipeline will use seiModel to get java concepts for the endpoint
*
* @return Null if the service doesn't have SEI model e.g. Provider endpoints,
* and otherwise non-null.
*/
public @Nullable SEIModel getSEIModel() {
return seiModel;
}
/**
* The created pipeline will be used to serve this port.
*
* @return Null if the service isn't associated with any port definition in WSDL,
* and otherwise non-null.
*/
public @Nullable WSDLPort getWsdlModel() {
return wsdlModel;
}
/**
*
* The created pipeline is used to serve this {@link com.sun.xml.internal.ws.api.server.WSEndpoint}.
* Specifically, its {@link com.sun.xml.internal.ws.api.WSBinding} should be of interest to many
* {@link com.sun.xml.internal.ws.api.pipe.Pipe}s.
* @return Always non-null.
*/
public @NotNull WSEndpoint<?> getEndpoint() {
return endpoint;
}
/**
* The last {@link com.sun.xml.internal.ws.api.pipe.Pipe} in the pipeline. The assembler is expected to put
* additional {@link com.sun.xml.internal.ws.api.pipe.Pipe}s in front of it.
*
* <p>
* (Just to give you the idea how this is used, normally the terminal pipe
* is the one that invokes the user application or {@link javax.xml.ws.Provider}.)
*
* @return always non-null terminal pipe
*/
public @NotNull Tube getTerminalTube() {
return terminal;
}
/**
* If this server pipeline is known to be used for serving synchronous transport,
* then this method returns true. This can be potentially use as an optimization
* hint, since often synchronous versions are cheaper to execute than asycnhronous
* versions.
*/
public boolean isSynchronous() {
return isSynchronous;
}
/**
* Creates a {@link Tube} that performs SOAP mustUnderstand processing.
* This pipe should be before HandlerPipes.
*/
public @NotNull Tube createServerMUTube(@NotNull Tube next) {
if (binding instanceof SOAPBinding)
return new ServerMUTube(this,next);
else
return next;
}
/**
* Creates a {@link Tube} that invokes protocol and logical handlers.
*/
public @NotNull Tube createHandlerTube(@NotNull Tube next) {
if (!binding.getHandlerChain().isEmpty()) {
HandlerTube cousin = new ServerLogicalHandlerTube(binding, seiModel, wsdlModel, next);
next = cousin;
if (binding instanceof SOAPBinding) {
//Add SOAPHandlerTube
next = cousin = new ServerSOAPHandlerTube(binding, next, cousin);
//Add MessageHandlerTube
next = new ServerMessageHandlerTube(seiModel, binding, next, cousin);
}
}
return next;
}
/**
* Creates a {@link Tube} that does the monitoring of the invocation for a
* container
*/
public @NotNull Tube createMonitoringTube(@NotNull Tube next) {
ServerPipelineHook hook = endpoint.getContainer().getSPI(ServerPipelineHook.class);
if (hook != null) {
ServerPipeAssemblerContext ctxt = new ServerPipeAssemblerContext(seiModel, wsdlModel, endpoint, terminal, isSynchronous);
return PipeAdapter.adapt(hook.createMonitoringPipe(ctxt, PipeAdapter.adapt(next)));
}
return next;
}
/**
* Creates a {@link Tube} that adds container specific security
*/
public @NotNull Tube createSecurityTube(@NotNull Tube next) {
ServerPipelineHook hook = endpoint.getContainer().getSPI(ServerPipelineHook.class);
if (hook != null) {
ServerPipeAssemblerContext ctxt = new ServerPipeAssemblerContext(seiModel, wsdlModel, endpoint, terminal, isSynchronous);
return PipeAdapter.adapt(hook.createSecurityPipe(ctxt, PipeAdapter.adapt(next)));
}
return next;
}
/**
* creates a {@link Tube} that dumps messages that pass through.
*/
public Tube createDumpTube(String name, PrintStream out, Tube next) {
return new DumpTube(name, out, next);
}
/**
* creates a {@link Tube} that validates messages against schema
*/
public Tube createValidationTube(Tube next) {
if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
return new ServerSchemaValidationTube(endpoint, binding, seiModel, wsdlModel, next);
else
return next;
}
/**
* Creates WS-Addressing pipe
*/
public Tube createWsaTube(Tube next) {
if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding)) {
if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
return new MemberSubmissionWsaServerTube(endpoint, wsdlModel, binding, next);
} else {
return new W3CWsaServerTube(endpoint, wsdlModel, binding, next);
}
} else
return next;
}
/**
* Gets the {@link Codec} that is set by {@link #setCodec} or the default codec
* based on the binding. The codec is a full codec that is responsible for
* encoding/decoding entire protocol message(for e.g: it is responsible to
* encode/decode entire MIME messages in SOAP binding)
*
* @return codec to be used for web service requests
* @see Codecs
*/
public @NotNull Codec getCodec() {
return codec;
}
/**
* Interception point to change {@link Codec} during {@link Tube}line assembly. The
* new codec will be used by jax-ws server runtime for encoding/decoding web service
* request/response messages. {@link WSEndpoint#createCodec()} will return a copy
* of this new codec and will be used in the server runtime.
*
* <p>
* The codec is a full codec that is responsible for
* encoding/decoding entire protocol message(for e.g: it is responsible to
* encode/decode entire MIME messages in SOAP binding)
*
* <p>
* the codec should correctly implement {@link Codec#copy} since it is used while
* serving requests concurrently.
*
* @param codec codec to be used for web service requests
* @see Codecs
*/
public void setCodec(@NotNull Codec codec) {
this.codec = codec;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.AttachmentSet;
import javax.xml.stream.XMLStreamReader;
/**
* Reads events from {@link XMLStreamReader} and constructs a
* {@link Message} for SOAP envelope. {@link Codecs} allows a
* way to construct a whole codec that can handle MTOM, MIME
* encoded packages using this codec.
*
*
* @see Codecs
* @author Jitendra Kotamraju
*/
public interface StreamSOAPCodec extends Codec {
/**
* Reads events from {@link XMLStreamReader} and constructs a
* {@link Message} for SOAP envelope.
*
* @param reader that represents SOAP envelope infoset
* @return a {@link Message} for SOAP envelope
*/
public @NotNull Message decode(@NotNull XMLStreamReader reader);
/**
* Reads events from {@link XMLStreamReader} and constructs a
* {@link Message} for SOAP envelope.
*
* @param reader that represents SOAP envelope infoset
* @param att attachments for the message
* @return a {@link Message} for SOAP envelope
*/
public @NotNull Message decode(@NotNull XMLStreamReader reader, @NotNull AttachmentSet att);
}

View File

@@ -0,0 +1,450 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.WSService;
import com.sun.xml.internal.ws.api.client.WSPortInfo;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.SEIModel;
import com.sun.xml.internal.ws.binding.BindingImpl;
import com.sun.xml.internal.ws.client.WSServiceDelegate;
import com.sun.xml.internal.ws.client.dispatch.DataSourceDispatch;
import com.sun.xml.internal.ws.client.dispatch.DispatchImpl;
import com.sun.xml.internal.ws.client.dispatch.JAXBDispatch;
import com.sun.xml.internal.ws.client.dispatch.MessageDispatch;
import com.sun.xml.internal.ws.client.dispatch.PacketDispatch;
import com.sun.xml.internal.ws.client.sei.SEIStub;
import com.sun.xml.internal.ws.developer.WSBindingProvider;
import com.sun.xml.internal.ws.model.SOAPSEIModel;
import javax.activation.DataSource;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.WebServiceException;
import java.lang.reflect.Proxy;
/**
* Factory methods of various stubs.
*
* <p>
* This class provides various methods to create "stub"s,
* which are the component that turns a method invocation
* into a {@link Message} and back into a return value.
*
* <p>
* This class is meant to serve as the API from JAX-WS to
* Tango, so that they don't have hard-code dependency on
* our implementation classes.
*
* <a name="param"></a>
* <h2>Common Parameters and Their Meanings</h2>
*
* <h3>Pipe next</h3>
* <p>
* Stubs turn a method invocation into a {@link Pipe#process(com.sun.xml.internal.ws.api.message.Packet)} invocation,
* and this pipe passed in as the <tt>next</tt> parameter will receive a {@link Message}
* from newly created stub. All the methods taking Tube <<next>> parameter are deprecated. JAX-WS Runtime takes care of
* creating the tubeline when the <tt>next</tt> parameter is not passed. This gives flexibility for the JAX-WS Runtime
* to pass extra information during the tube line creation via {@link ClientTubeAssemblerContext}.
*
* <h3>WSPortInfo portInfo</h3>
* <p> Gives information about the port for which the "stub" being created. Such information includes Port QName,
* target endpoint address, and bindingId etc.
*
* <h3>BindingImpl binding</h3>
* <p>
* Stubs implement {@link BindingProvider}, and its {@link BindingProvider#getBinding()}
* will return this <tt>binding</tt> object. Stubs often also use this information
* to decide which SOAP version a {@link Message} should be created in.
*
* <h3>{@link WSService} service</h3>
* <p>
* This object represents a {@link Service} that owns the newly created stub.
* For example, asynchronous method invocation will use {@link Service#getExecutor()}.
*
* <h3>{@link WSEndpointReference} epr</h3>
* <p>
* If you want the created {@link Dispatch} to talk to the given EPR, specify the parameter.
* Otherwise leave it <tt>null</tt>. Note that the addressing needs to be enabled separately
* for this to take effect.
*
* @author Kohsuke Kawaguchi
* @author Kathy Walsh
*/
public abstract class Stubs {
private Stubs() {} // no instanciation please
/**
* Creates a new {@link Dispatch} stub for {@link SOAPMessage}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,SOAPMessage.class,mode,next);
* </pre>
*/
@Deprecated
public static Dispatch<SOAPMessage> createSAAJDispatch(QName portName, WSService owner, WSBinding binding, Service.Mode mode, Tube next, @Nullable WSEndpointReference epr) {
DispatchImpl.checkValidSOAPMessageDispatch(binding, mode);
return new com.sun.xml.internal.ws.client.dispatch.SOAPMessageDispatch(portName, mode, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub for {@link SOAPMessage}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,SOAPMessage.class,mode,next);
* </pre>
*/
public static Dispatch<SOAPMessage> createSAAJDispatch(WSPortInfo portInfo, WSBinding binding, Service.Mode mode, @Nullable WSEndpointReference epr) {
DispatchImpl.checkValidSOAPMessageDispatch(binding, mode);
return new com.sun.xml.internal.ws.client.dispatch.SOAPMessageDispatch(portInfo, mode, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub for {@link DataSource}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,DataSource.class,mode,next);
* </pre>
*/
@Deprecated
public static Dispatch<DataSource> createDataSourceDispatch(QName portName, WSService owner, WSBinding binding, Service.Mode mode, Tube next, @Nullable WSEndpointReference epr) {
DispatchImpl.checkValidDataSourceDispatch(binding, mode);
return new DataSourceDispatch(portName, mode, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub for {@link DataSource}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,DataSource.class,mode,next);
* </pre>
*/
public static Dispatch<DataSource> createDataSourceDispatch(WSPortInfo portInfo, WSBinding binding, Service.Mode mode,@Nullable WSEndpointReference epr) {
DispatchImpl.checkValidDataSourceDispatch(binding, mode);
return new DataSourceDispatch(portInfo, mode, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub for {@link Source}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,Source.class,mode,next);
* </pre>
*/
@Deprecated
public static Dispatch<Source> createSourceDispatch(QName portName, WSService owner, WSBinding binding, Service.Mode mode, Tube next, @Nullable WSEndpointReference epr) {
return DispatchImpl.createSourceDispatch(portName, mode, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub for {@link Source}.
*
* This is short-cut of calling
* <pre>
* createDispatch(port,owner,binding,Source.class,mode,next);
* </pre>
*/
public static Dispatch<Source> createSourceDispatch(WSPortInfo portInfo, WSBinding binding, Service.Mode mode, @Nullable WSEndpointReference epr) {
return DispatchImpl.createSourceDispatch(portInfo, mode, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Dispatch} stub that connects to the given pipe.
*
* @param portName
* see {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param clazz
* Type of the {@link Dispatch} to be created.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param mode
* The mode of the dispatch.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
* TODO: are these parameters making sense?
*/
@SuppressWarnings("unchecked")
public static <T> Dispatch<T> createDispatch(QName portName,
WSService owner,
WSBinding binding,
Class<T> clazz, Service.Mode mode, Tube next,
@Nullable WSEndpointReference epr) {
if (clazz == SOAPMessage.class) {
return (Dispatch<T>) createSAAJDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == Source.class) {
return (Dispatch<T>) createSourceDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == DataSource.class) {
return (Dispatch<T>) createDataSourceDispatch(portName, owner, binding, mode, next, epr);
} else if (clazz == Message.class) {
if(mode==Mode.MESSAGE)
return (Dispatch<T>) createMessageDispatch(portName, owner, binding, next, epr);
else
throw new WebServiceException(mode+" not supported with Dispatch<Message>");
} else if (clazz == Packet.class) {
return (Dispatch<T>) createPacketDispatch(portName, owner, binding, next, epr);
} else
throw new WebServiceException("Unknown class type " + clazz.getName());
}
/**
* Creates a new {@link Dispatch} stub that connects to the given pipe.
*
* @param portInfo
* see <a href="#param">common parameters</a>
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param clazz
* Type of the {@link Dispatch} to be created.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param mode
* The mode of the dispatch.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param epr
* see <a href="#param">common parameters</a>
* TODO: are these parameters making sense?
*/
public static <T> Dispatch<T> createDispatch(WSPortInfo portInfo,
WSService owner,
WSBinding binding,
Class<T> clazz, Service.Mode mode,
@Nullable WSEndpointReference epr) {
if (clazz == SOAPMessage.class) {
return (Dispatch<T>) createSAAJDispatch(portInfo, binding, mode, epr);
} else if (clazz == Source.class) {
return (Dispatch<T>) createSourceDispatch(portInfo, binding, mode, epr);
} else if (clazz == DataSource.class) {
return (Dispatch<T>) createDataSourceDispatch(portInfo, binding, mode, epr);
} else if (clazz == Message.class) {
if(mode==Mode.MESSAGE)
return (Dispatch<T>) createMessageDispatch(portInfo, binding, epr);
else
throw new WebServiceException(mode+" not supported with Dispatch<Message>");
} else if (clazz == Packet.class) {
if(mode==Mode.MESSAGE)
return (Dispatch<T>) createPacketDispatch(portInfo, binding, epr);
else
throw new WebServiceException(mode+" not supported with Dispatch<Packet>");
} else
throw new WebServiceException("Unknown class type " + clazz.getName());
}
/**
* Creates a new JAXB-based {@link Dispatch} stub that connects to the given pipe.
*
* @param portName
* see {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param jaxbContext
* {@link JAXBContext} used to convert between objects and XML.
* @param mode
* The mode of the dispatch.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
@Deprecated
public static Dispatch<Object> createJAXBDispatch(
QName portName, WSService owner, WSBinding binding,
JAXBContext jaxbContext, Service.Mode mode, Tube next,
@Nullable WSEndpointReference epr) {
return new JAXBDispatch(portName, jaxbContext, mode, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new JAXB-based {@link Dispatch} stub that connects to the given pipe.
*
* @param portInfo see <a href="#param">common parameters</a>
* @param binding see <a href="#param">common parameters</a>
* @param jaxbContext {@link JAXBContext} used to convert between objects and XML.
* @param mode The mode of the dispatch.
* See {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param epr see <a href="#param">common parameters</a>
*/
public static Dispatch<Object> createJAXBDispatch(
WSPortInfo portInfo, WSBinding binding,
JAXBContext jaxbContext, Service.Mode mode,
@Nullable WSEndpointReference epr) {
return new JAXBDispatch(portInfo, jaxbContext, mode, (BindingImpl) binding, epr);
}
/**
* Creates a new {@link Message}-based {@link Dispatch} stub that connects to the given pipe.
* The returned dispatch is always {@link Mode#MESSAGE}.
*
* @param portName
* see {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
@Deprecated
public static Dispatch<Message> createMessageDispatch(
QName portName, WSService owner, WSBinding binding,
Tube next, @Nullable WSEndpointReference epr) {
return new MessageDispatch(portName, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Message}-based {@link Dispatch} stub that connects to the given pipe.
* The returned dispatch is always {@link Mode#MESSAGE}.
*
* @param portInfo
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
public static Dispatch<Message> createMessageDispatch(
WSPortInfo portInfo, WSBinding binding,
@Nullable WSEndpointReference epr) {
return new MessageDispatch(portInfo, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Packet}-based {@link Dispatch} stub that connects to the given pipe.
*
* @param portName
* see {@link Service#createDispatch(QName, Class, Service.Mode)}.
* @param owner
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
public static Dispatch<Packet> createPacketDispatch(
QName portName, WSService owner, WSBinding binding,
Tube next, @Nullable WSEndpointReference epr) {
return new PacketDispatch(portName, (WSServiceDelegate)owner, next, (BindingImpl)binding, epr);
}
/**
* Creates a new {@link Message}-based {@link Dispatch} stub that connects to the given pipe.
* The returned dispatch is always {@link Mode#MESSAGE}.
*
* @param portInfo
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
public static Dispatch<Packet> createPacketDispatch(
WSPortInfo portInfo, WSBinding binding,
@Nullable WSEndpointReference epr) {
return new PacketDispatch(portInfo, (BindingImpl)binding, epr);
}
/**
* Creates a new strongly-typed proxy object that implements a given port interface.
*
* @param service
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param model
* This model shall represent a port interface.
* TODO: can model be constructed from portInterface and binding?
* Find out and update.
* @param portInterface
* The port interface that has operations as Java methods.
* @param next
* see <a href="#param">common parameters</a>
* @param epr
* see <a href="#param">common parameters</a>
*/
public <T> T createPortProxy( WSService service, WSBinding binding, SEIModel model,
Class<T> portInterface, Tube next, @Nullable WSEndpointReference epr ) {
SEIStub ps = new SEIStub((WSServiceDelegate)service,(BindingImpl)binding, (SOAPSEIModel)model, next, epr);
return portInterface.cast(
Proxy.newProxyInstance( portInterface.getClassLoader(),
new Class[]{portInterface, WSBindingProvider.class}, ps ));
}
/**
* Creates a new strongly-typed proxy object that implements a given port interface.
*
* @param portInfo
* see <a href="#param">common parameters</a>
* @param binding
* see <a href="#param">common parameters</a>
* @param model
* This model shall represent a port interface.
* TODO: can model be constructed from portInterface and binding?
* Find out and update.
* @param portInterface
* The port interface that has operations as Java methods.
* @param epr
* see <a href="#param">common parameters</a>
*/
public <T> T createPortProxy( WSPortInfo portInfo, WSBinding binding, SEIModel model,
Class<T> portInterface, @Nullable WSEndpointReference epr ) {
SEIStub ps = new SEIStub(portInfo, (BindingImpl)binding, (SOAPSEIModel)model, epr);
return portInterface.cast(
Proxy.newProxyInstance( portInterface.getClassLoader(),
new Class[]{portInterface, WSBindingProvider.class}, ps ));
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import javax.xml.ws.WebServiceFeature;
/**
* Feature used to request starting a fiber synchronous to the calling
* thread but allowing it to later switch to run asynchronously to that thread.
*
* @since 2.2.6
*/
public class SyncStartForAsyncFeature
extends WebServiceFeature {
public SyncStartForAsyncFeature() {
enabled = true;
}
@Override
public String getID() {
return SyncStartForAsyncFeature.class.getSimpleName();
}
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import javax.xml.ws.Dispatch;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.oracle.webservices.internal.api.message.BasePropertySet;
import com.oracle.webservices.internal.api.message.PropertySet;
/**
* When using {@link Dispatch}<{@link Packet}> and the invocation completes with a Throwable, it is
* useful to be able to inspect the Packet in addition to the Throwable as the Packet contains
* meta-data about the request and/or response. However, the default behavior is that the caller
* only receives the Throwable.
*
* This {@link PropertySet} is part of the implementation that allows a completing Fiber to return
* the Throwable to the caller as part of the Packet.
*
*/
public class ThrowableContainerPropertySet extends BasePropertySet {
public ThrowableContainerPropertySet(final Throwable throwable) {
this.throwable = throwable;
}
////////////////////////////////////////////////////
//
// The original throwable
//
public static final String FIBER_COMPLETION_THROWABLE = "com.sun.xml.internal.ws.api.pipe.fiber-completion-throwable";
private Throwable throwable;
@Property(FIBER_COMPLETION_THROWABLE)
public Throwable getThrowable() {
return throwable;
}
public void setThrowable(final Throwable throwable) {
this.throwable = throwable;
}
////////////////////////////////////////////////////
//
// The FAULT message created in WsaServerTube or WSEndpointImpl
//
public static final String FAULT_MESSAGE = "com.sun.xml.internal.ws.api.pipe.fiber-completion-fault-message";
private Message faultMessage;
@Property(FAULT_MESSAGE)
public Message getFaultMessage() {
return faultMessage;
}
public void setFaultMessage(final Message faultMessage) {
this.faultMessage = faultMessage;
}
////////////////////////////////////////////////////
//
// The response Packet seen in WsaServerTube.processException or WSEndpointImpl
//
public static final String RESPONSE_PACKET = "com.sun.xml.internal.ws.api.pipe.fiber-completion-response-packet";
private Packet responsePacket;
@Property(RESPONSE_PACKET)
public Packet getResponsePacket() {
return responsePacket;
}
public void setResponsePacket(final Packet responsePacket) {
this.responsePacket = responsePacket;
}
////////////////////////////////////////////////////
//
// If the fault representation of the exception has already been created
//
public static final String IS_FAULT_CREATED = "com.sun.xml.internal.ws.api.pipe.fiber-completion-is-fault-created";
private boolean isFaultCreated = false;
@Property(IS_FAULT_CREATED)
public boolean isFaultCreated() {
return isFaultCreated;
}
public void setFaultCreated(final boolean isFaultCreated) {
this.isFaultCreated = isFaultCreated;
}
//
// boilerplate
//
@Override
protected PropertyMap getPropertyMap() {
return model;
}
private static final PropertyMap model;
static {
model = parse(ThrowableContainerPropertySet.class);
}
}

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.util.pipe.StandalonePipeAssembler;
import javax.xml.ws.WebServiceException;
/**
* Factory for transport pipes that enables transport pluggability.
*
* <p>
* At runtime, on the client side, JAX-WS (more specifically the default {@link PipelineAssembler}
* of JAX-WS client runtime) relies on this factory to create a suitable transport {@link Pipe}
* that can handle the given {@link EndpointAddress endpoint address}.
*
* <p>
* JAX-WS extensions that provide additional transport support can
* extend this class and implement the {@link #doCreate} method.
* They are expected to check the scheme of the endpoint address
* (and possibly some other settings from bindings), and create
* their transport pipe implementations accordingly.
* For example,
*
* <pre>
* class MyTransportPipeFactoryImpl {
* Pipe doCreate(...) {
* String scheme = address.getURI().getScheme();
* if(scheme.equals("foo"))
* return new MyTransport(...);
* else
* return null;
* }
* }
* </pre>
*
* <p>
* {@link TransportPipeFactory} look-up follows the standard service
* discovery mechanism, so you need
* {@code META-INF/services/com.sun.xml.internal.ws.api.pipe.TransportPipeFactory}.
*
*
*
* <h2>TODO</h2>
* <p>
* One of the JAX-WS operation mode is supposedly where it doesn't have no WSDL whatsoever.
* How do we identify the endpoint in such case?
*
* @author Kohsuke Kawaguchi
* @see StandalonePipeAssembler
*/
public abstract class TransportPipeFactory {
/**
* Creates a transport {@link Pipe} for the given port, if this factory can do so,
* or return null.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the pipeline to be assembled.
*
* @return
* null to indicate that this factory isn't capable of creating a transport
* for this port (which causes the caller to search for other {@link TransportPipeFactory}s
* that can. Or non-null.
*
* @throws WebServiceException
* if this factory is capable of creating a transport pipe but some fatal
* error prevented it from doing so. This exception will be propagated
* back to the user application, and no further {@link TransportPipeFactory}s
* are consulted.
*/
public abstract Pipe doCreate(@NotNull ClientPipeAssemblerContext context);
/**
* Locates {@link PipelineAssemblerFactory}s and create
* a suitable {@link PipelineAssembler}.
*
* @param classLoader
* used to locate {@code META-INF/servces} files.
* @return
* Always non-null, since we fall back to our default {@link PipelineAssembler}.
*
* @deprecated
* Use {@link TransportTubeFactory#create(ClassLoader, ClientTubeAssemblerContext)}
*/
public static Pipe create(@Nullable ClassLoader classLoader, @NotNull ClientPipeAssemblerContext context) {
return PipeAdapter.adapt(TransportTubeFactory.create(classLoader,context));
}
}

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.EndpointAddress;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe;
import com.sun.xml.internal.ws.util.ServiceFinder;
import com.sun.xml.internal.ws.util.pipe.StandaloneTubeAssembler;
import java.util.logging.Level;
import javax.xml.ws.WebServiceException;
import java.util.logging.Logger;
/**
* Factory for transport tubes that enables transport pluggability.
*
* <p>
* At runtime, on the client side, JAX-WS (more specifically the default {@link TubelineAssembler}
* of JAX-WS client runtime) relies on this factory to create a suitable transport {@link Tube}
* that can handle the given {@link EndpointAddress endpoint address}.
*
* <p>
* JAX-WS extensions that provide additional transport support can
* extend this class and implement the {@link #doCreate} method.
* They are expected to check the scheme of the endpoint address
* (and possibly some other settings from bindings), and create
* their transport tube implementations accordingly.
* For example,
*
* <pre>
* class MyTransportTubeFactoryImpl {
* Tube doCreate(...) {
* String scheme = address.getURI().getScheme();
* if(scheme.equals("foo"))
* return new MyTransport(...);
* else
* return null;
* }
* }
* </pre>
*
* <p>
* {@link TransportTubeFactory} look-up follows the standard service
* discovery mechanism, so you need
* {@code META-INF/services/com.sun.xml.internal.ws.api.pipe.BasicTransportTubeFactory}.
*
* @author Jitendra Kotamraju
* @see StandaloneTubeAssembler
*/
public abstract class TransportTubeFactory {
/**
* Creates a transport {@link Tube} for the given port, if this factory can do so,
* or return null.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the tubeline to be assembled.
*
* @return
* null to indicate that this factory isn't capable of creating a transport
* for this port (which causes the caller to search for other {@link TransportTubeFactory}s
* that can. Or non-null.
*
* @throws WebServiceException
* if this factory is capable of creating a transport tube but some fatal
* error prevented it from doing so. This exception will be propagated
* back to the user application, and no further {@link TransportTubeFactory}s
* are consulted.
*/
public abstract Tube doCreate(@NotNull ClientTubeAssemblerContext context);
private static final TransportTubeFactory DEFAULT = new DefaultTransportTubeFactory();
private static class DefaultTransportTubeFactory extends TransportTubeFactory {
@Override
public Tube doCreate(ClientTubeAssemblerContext context) {
return createDefault(context);
}
}
/**
* Locates {@link TransportTubeFactory}s and create a suitable transport {@link Tube}.
*
* @param classLoader
* used to locate {@code META-INF/servces} files.
* @return
* Always non-null, since we fall back to our default {@link Tube}.
*/
public static Tube create(@Nullable ClassLoader classLoader, @NotNull ClientTubeAssemblerContext context) {
for (TransportTubeFactory factory : ServiceFinder.find(TransportTubeFactory.class,classLoader, context.getContainer())) {
Tube tube = factory.doCreate(context);
if (tube !=null) {
if (logger.isLoggable(Level.FINE)) {
TransportTubeFactory.logger.log(Level.FINE, "{0} successfully created {1}", new Object[]{factory.getClass(), tube});
}
return tube;
}
}
// See if there is a {@link TransportPipeFactory} out there and use it for compatibility.
ClientPipeAssemblerContext ctxt = new ClientPipeAssemblerContext(
context.getAddress(), context.getWsdlModel(), context.getService(),
context.getBinding(), context.getContainer());
ctxt.setCodec(context.getCodec());
for (TransportPipeFactory factory : ServiceFinder.find(TransportPipeFactory.class,classLoader)) {
Pipe pipe = factory.doCreate(ctxt);
if (pipe!=null) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "{0} successfully created {1}", new Object[]{factory.getClass(), pipe});
}
return PipeAdapter.adapt(pipe);
}
}
return DEFAULT.createDefault(ctxt);
}
protected Tube createDefault(ClientTubeAssemblerContext context) {
// default built-in transports
String scheme = context.getAddress().getURI().getScheme();
if (scheme != null) {
if(scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))
return createHttpTransport(context);
}
throw new WebServiceException("Unsupported endpoint address: "+context.getAddress()); // TODO: i18n
}
protected Tube createHttpTransport(ClientTubeAssemblerContext context) {
return new HttpTransportPipe(context.getCodec(), context.getBinding());
}
private static final Logger logger = Logger.getLogger(TransportTubeFactory.class.getName());
}

View File

@@ -0,0 +1,396 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractTubeImpl;
import com.sun.xml.internal.ws.api.server.Adapter;
import javax.annotation.PreDestroy;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.soap.SOAPHandler;
import java.text.SimpleDateFormat;
/**
* Abstraction of the intermediate layers in the processing chain
* and transport.
*
* <h2>What is a {@link Tube}?</h2>
* <p>
* {@link Tube} is a basic processing unit that represents SOAP-level
* protocol handling code. Mutliple tubes are often put together in
* a line (it needs not one dimensional &mdash; more later), and act on
* {@link Packet}s in a sequential fashion.
*
* <p>
* {@link Tube}s run asynchronously. That is, there is no guarantee that
* {@link #processRequest(Packet)} and {@link #processResponse(Packet)} runs
* in the same thread, nor is there any guarantee that this tube and next
* tube runs in the same thread. Furthermore, one thread may be used to
* run multiple pipeline in turn (just like a real CPU runs multiple
* threads in turn.)
*
*
* <h2>Tube examples</h2>
* <p>
* Transport is a kind of tube. It sends the {@link Packet}
* through, say, HTTP connection, and receives the data back into another {@link Packet}.
*
* <p>
* More often, a tube works like a filter. It acts on a packet,
* and then it tells the JAX-WS that the packet should be passed into another
* tube. It can do the same on the way back.
*
* <p>
* For example, XWSS will be a {@link Tube}. It will act on a request
* {@link Packet}, then perhaps wrap it into
* another {@link Packet} to encrypt the body and add a header, then
* the processing will go on to the next tube.
*
* <p>
* Yet another kind of filter tube is those that wraps {@link LogicalHandler}
* and {@link SOAPHandler}. These tubes are heavy-weight; they often consume
* a message in a packet and create a new one, and then pass it to the next tube.
*
* <p>
* There would be a {@link Tube} implementation that invokes {@link Provider}.
* There would be a {@link Tube} implementation that invokes a service method
* on the user's code.
* There would be a {@link Dispatch} implementation that invokes a {@link Tube}.
*
* <p>
* WS-MEX can be implemented as a {@link Tube} that looks for
* {@link Message#getPayloadNamespaceURI()} and serves the request.
*
*
*
*
* <h2>Tube Lifecycle</h2>
* Pipeline is expensive to set up, so once it's created it will be reused.
* A pipeline is not reentrant; one pipeline is used to process one request/response
* at at time. The same pipeline instance may serve multiple request/response,
* if one comes after another and they don't overlap.
* <p>
* Where a need arises to process multiple requests concurrently, a pipeline
* gets cloned through {@link TubeCloner}. Note that this need may happen on
* both server (because it quite often serves multiple requests concurrently)
* and client (because it needs to support asynchronous method invocations.)
* <p>
* Created pipelines (including cloned ones and the original) may be discarded and GC-ed
* at any time at the discretion of whoever owns pipelines. Tubes can, however, expect
* at least one copy (or original) of pipeline to live at any given time while a pipeline
* owner is interested in the given pipeline configuration (in more concerete terms,
* for example, as long as a dispatch object lives, it's going to keep at least one
* copy of a pipeline alive.)
* <p>
* Before a pipeline owner dies, it may invoke {@link #preDestroy()} on the last
* remaining pipeline. It is "may" for pipeline owners that live in the client-side
* of JAX-WS (such as dispatches and proxies), but it is a "must" for pipeline owners
* that live in the server-side of JAX-WS.
* <p>
* This last invocation gives a chance for some pipes to clean up any state/resource
* acquired (such as WS-RM's sequence, WS-Trust's SecurityToken), although as stated above,
* this is not required for clients.
*
*
*
* <h2>Tube and state</h2>
* <p>
* The lifecycle of pipelines is designed to allow a {@link Tube} to store various
* state in easily accessible fashion.
*
*
* <h3>Per-packet state</h3>
* <p>
* Any information that changes from a packet to packet should be
* stored in {@link Packet} (if such informaton is specific to your problem domain,
* then most likely {@link Packet#invocationProperties}.)
* This includes information like transport-specific headers.
*
* <h3>Per-thread state</h3>
* <p>
* Any expensive-to-create objects that are non-reentrant can be stored
* either in instance variables of a {@link Tube}, or a static {@link ThreadLocal}.
*
* <p>
* The first approach works, because {@link Tube} is
* non reentrant. When a tube is copied, new instances should be allocated
* so that two {@link Tube} instances don't share thread-unsafe resources.
*
* Similarly the second approach works, since {@link ThreadLocal} guarantees
* that each thread gets its own private copy.
*
* <p>
* The former is faster to access, and you need not worry about clean up.
* On the other hand, because there can be many more concurrent requests
* than # of threads, you may end up holding onto more resources than necessary.
*
* <p>
* This includes state like canonicalizers, JAXB unmarshallers,
* {@link SimpleDateFormat}, etc.
*
*
* <h3>Per-proxy/per-endpoint state</h3>
* <p>
* Information that is tied to a particular proxy/dispatch can be stored
* in a separate object that is referenced from a tube. When
* a new tube is copied, you can simply hand out a reference to the newly
* created one, so that all copied tubes refer to the same instance.
* See the following code as an example:
*
* <pre>
* class TubeImpl {
* // this object stores per-proxy state
* class DataStore {
* int counter;
* }
*
* private DataStore ds;
*
* // create a fresh new pipe
* public TubeImpl(...) {
* ....
* ds = new DataStore();
* }
*
* // copy constructor
* private TubeImpl(TubeImpl that, PipeCloner cloner) {
* cloner.add(that,this);
* ...
* this.ds = that.ds;
* }
*
* public TubeImpl copy(PipeCloner pc) {
* return new TubeImpl(this,pc);
* }
* }
* </pre>
*
* <p>
* Note that access to such resource may need to be synchronized,
* since multiple copies of pipelines may execute concurrently.
*
*
*
* <h3>VM-wide state</h3>
* <p>
* <tt>static</tt> is always there for you to use.
*
*
*
* @see AbstractTubeImpl
* @see AbstractFilterTubeImpl
*
* @author Kohsuke Kawaguchi
* @author Jitendra Kotamraju
*/
public interface Tube {
/**
* Acts on a request and perform some protocol specific operation.
*
* TODO: exception handling semantics need more discussion
*
* @throws WebServiceException
* On the server side, this signals an error condition where
* a fault reply is in order (or the exception gets eaten by
* the top-most transport {@link Adapter} if it's one-way.)
* This frees each {@link Tube} from try/catching a
* {@link WebServiceException} in every layer.
*
* Note that this method is also allowed to return
* {@link NextAction#returnWith(Packet)} with
* a {@link Packet} that has a fault as the payload.
*
* <p>
* On the client side, the {@link WebServiceException} thrown
* will be propagated all the way back to the calling client
* applications. (The consequence of that is that if you are
* a filtering {@link Tube}, you must not eat the exception
* that was given to {@link #processException(Throwable)} .
*
* @throws RuntimeException
* Other runtime exception thrown by this method must
* be treated as a bug in the tube implementation,
* and therefore should not be converted into a fault.
* (Otherwise it becomes very difficult to debug implementation
* problems.)
*
* <p>
* On the server side, this exception should be most likely
* just logged. On the client-side it gets propagated to the
* client application.
*
* <p>
* The consequence of this is that if a pipe calls
* into an user application (such as {@link SOAPHandler}
* or {@link LogicalHandler}), where a {@link RuntimeException}
* is *not* a bug in the JAX-WS implementation, it must be catched
* and wrapped into a {@link WebServiceException}.
*
* @param request
* The packet that represents a request message.
* If the packet has a non-null message, it must be a valid
* unconsumed {@link Message}. This message represents the
* SOAP message to be sent as a request.
* <p>
* The packet is also allowed to carry no message, which indicates
* that this is an output-only request.
* (that's called "solicit", right? - KK)
*
* @return
* A {@link NextAction} object that represents the next action
* to be taken by the JAX-WS runtime.
*/
@NotNull NextAction processRequest(@NotNull Packet request);
/**
* Acts on a response and performs some protocol specific operation.
*
* <p>
* Once a {@link #processRequest(Packet)} is invoked, this method
* will be always invoked with the response, before this {@link Tube}
* processes another request.
*
* @param response
* If the packet has a non-null message, it must be
* a valid unconsumed {@link Message}. This message represents
* a response to the request message passed to
* {@link #processRequest(Packet)} earlier.
* <p>
* The packet is also allowed to carry no message, which indicates
* that there was no response. This is used for things like
* one-way message and/or one-way transports.
*
* TODO: exception handling semantics need more discussion
*
* @return
* A {@link NextAction} object that represents the next action
* to be taken by the JAX-WS runtime.
*/
@NotNull NextAction processResponse(@NotNull Packet response);
/**
* Acts on a exception and performs some clean up operations.
*
* <p>
* If a {@link #processRequest(Packet)}, {@link #processResponse(Packet)},
* {@link #processException(Throwable)} throws an exception, this method
* will be always invoked on all the {@link Tube}s in the remaining
* {@link NextAction}s.
*
* <p>
* On the server side, the {@link Throwable} thrown will be propagated to the
* top-most transport. The transport converts the exception to fault reply or
* simply logs in case of one-way MEP. If you are a filtering {@link Tube} like
* {@link AbstractTubeImpl}, you don't have to override the implementation). On
* the other hand, any intermediate {@link Tube} may want to convert the exception
* to a fault message.
*
* <p>
* On the client side, the {@link Throwable} thrown
* will be propagated all the way back to the calling client
* applications. (The consequence of that is that if you are
* a filtering {@link Tube} like {@link AbstractTubeImpl}, you don't have to
* override the implementation)
*
* @param t
*
* @return
* A {@link NextAction} object that represents the next action
* to be taken by the JAX-WS runtime.
*/
@NotNull NextAction processException(@NotNull Throwable t);
/**
* Invoked before the last copy of the pipeline is about to be discarded,
* to give {@link Tube}s a chance to clean up any resources.
*
* <p>
* This can be used to invoke {@link PreDestroy} lifecycle methods
* on user handler. The invocation of it is optional on the client side,
* but mandatory on the server side.
*
* <p>
* When multiple copies of pipelines are created, this method is called
* only on one of them.
*
* @throws WebServiceException
* If the clean up fails, {@link WebServiceException} can be thrown.
* This exception will be propagated to users (if this is client),
* or recorded (if this is server.)
*/
void preDestroy();
/**
* Creates an identical clone of this {@link Tube}.
*
* <p>
* This method creates an identical pipeline that can be used
* concurrently with this pipeline. When the caller of a pipeline
* is multi-threaded and need concurrent use of the same pipeline,
* it can do so by creating copies through this method.
*
* <h3>Implementation Note</h3>
* <p>
* It is the implementation's responsibility to call
* {@link TubeCloner#add(Tube,Tube)} to register the copied pipe
* with the original. This is required before you start copying
* the other {@link Tube} references you have, or else there's a
* risk of infinite recursion.
* <p>
* For most {@link Tube} implementations that delegate to another
* {@link Tube}, this method requires that you also copy the {@link Tube}
* that you delegate to.
* <p>
* For limited number of {@link Tube}s that do not maintain any
* thread unsafe resource, it is allowed to simply return <tt>this</tt>
* from this method (notice that even if you are stateless, if you
* got a delegating {@link Tube} and that one isn't stateless, you
* still have to copy yourself.)
*
* <p>
* Note that this method might be invoked by one thread while another
* thread is executing the other process method. See
* the {@link Codec#copy()} for more discussion about this.
*
* @param cloner
* Use this object (in particular its {@link TubeCloner#copy(Tube)} method
* to clone other pipe references you have
* in your pipe. See {@link TubeCloner} for more discussion
* about why.
*
* @return
* always non-null {@link Tube}.
*/
Tube copy(TubeCloner cloner);
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import java.util.Map;
/**
* Clones the whole pipeline.
*
* <p>
* 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<Object,Object> master2copy;
/**
* Invoked by a client of a tube to clone the whole pipeline.
*
* <p>
* {@link Tube}s implementing the {@link Tube#copy(com.sun.xml.internal.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<Object,Object> master2copy) {
this.master2copy = master2copy;
}
/**
* Invoked by a {@link Tube#copy(com.sun.xml.internal.ws.api.pipe.TubeCloner)} implementation
* to copy a reference to another pipe.
*
* <p>
* This method is for {@link Tube} implementations, not for users.
*
* <p>
* 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.
*
* <p>
* (Think about what happens when a graph is A->B, A->C, B->D, and C->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 extends Tube> T copy(T t);
/**
* This method must be called from within the copy constructor
* to notify that the copy was created.
*
* <p>
* 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);
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
/**
* Creates a tubeline.
*
* <p>
* This pluggability layer enables the upper layer to
* control exactly how the tubeline is composed.
*
* <p>
* JAX-WS is going to have its own default implementation
* when used all by itself, but it can be substituted by
* other implementations.
*
* <p>
* See {@link TubelineAssemblerFactory} for how {@link TubelineAssembler}s
* are located.
*
*
* @see com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext
*
* @author Kohsuke Kawaguchi
* @author Jitendra Kotamraju
*/
public interface TubelineAssembler {
/**
* Creates a new tubeline for clients.
*
* <p>
* When a JAX-WS client creates a proxy or a {@link javax.xml.ws.Dispatch} from
* a {@link javax.xml.ws.Service}, JAX-WS runtime internally uses this method
* to create a new tubeline as a part of the initilization.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the tubeline to be assembled.
*
* @return
* non-null freshly created tubeline.
*
* @throws javax.xml.ws.WebServiceException
* if there's any configuration error that prevents the
* tubeline from being constructed. This exception will be
* propagated into the application, so it must have
* a descriptive error.
*/
@NotNull Tube createClient(@NotNull ClientTubeAssemblerContext context);
/**
* Creates a new tubeline for servers.
*
* <p>
* When a JAX-WS server deploys a new endpoint, it internally
* uses this method to create a new tubeline as a part of the
* initialization.
*
* <p>
* Note that this method is called only once to set up a
* 'master tubeline', and it gets {@link Tube#copy(TubeCloner) copied}
* from it.
*
* @param context
* Object that captures various contextual information
* that can be used to determine the tubeline to be assembled.
*
* @return
* non-null freshly created tubeline.
*
* @throws javax.xml.ws.WebServiceException
* if there's any configuration error that prevents the
* tubeline from being constructed. This exception will be
* propagated into the container, so it must have
* a descriptive error.
*
*/
@NotNull Tube createServer(@NotNull ServerTubeAssemblerContext context);
}

View File

@@ -0,0 +1,141 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.BindingID;
import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.assembler.MetroTubelineAssembler;
import com.sun.xml.internal.ws.util.ServiceFinder;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Creates {@link TubelineAssembler}.
* <p/>
* <p/>
* To create a tubeline,
* the JAX-WS runtime locates {@link TubelineAssemblerFactory}s through
* the <tt>META-INF/services/com.sun.xml.internal.ws.api.pipe.TubelineAssemblerFactory</tt> files.
* Factories found are checked to see if it supports the given binding ID one by one,
* and the first valid {@link TubelineAssembler} returned will be used to create
* a tubeline.
*
* @author Jitendra Kotamraju
*/
public abstract class TubelineAssemblerFactory {
/**
* Creates a {@link TubelineAssembler} applicable for the given binding ID.
*
* @param bindingId The binding ID for which a tubeline will be created,
* such as {@link javax.xml.ws.soap.SOAPBinding#SOAP11HTTP_BINDING}.
* Must not be null.
* @return null if this factory doesn't recognize the given binding ID.
*/
public abstract TubelineAssembler doCreate(BindingID bindingId);
/**
* @deprecated
* Use {@link #create(ClassLoader, BindingID, Container)}
*/
public static TubelineAssembler create(ClassLoader classLoader, BindingID bindingId) {
return create(classLoader,bindingId,null);
}
/**
* Locates {@link TubelineAssemblerFactory}s and create
* a suitable {@link TubelineAssembler}.
*
* @param bindingId The binding ID string for which the new {@link TubelineAssembler}
* is created. Must not be null.
* @param container
* if specified, the container is given a chance to specify a {@link TubelineAssembler}
* instance. This parameter should be always given on the server, but can be null.
* @return Always non-null, since we fall back to our default {@link TubelineAssembler}.
*/
public static TubelineAssembler create(ClassLoader classLoader, BindingID bindingId, @Nullable Container container) {
if(container!=null) {
// first allow the container to control pipeline for individual endpoint.
TubelineAssemblerFactory taf = container.getSPI(TubelineAssemblerFactory.class);
if(taf!=null) {
TubelineAssembler a = taf.doCreate(bindingId);
if (a != null) {
return a;
}
}
}
for (TubelineAssemblerFactory factory : ServiceFinder.find(TubelineAssemblerFactory.class, classLoader)) {
TubelineAssembler assembler = factory.doCreate(bindingId);
if (assembler != null) {
TubelineAssemblerFactory.logger.log(Level.FINE, "{0} successfully created {1}", new Object[]{factory.getClass(), assembler});
return assembler;
}
}
// See if there is a PipelineAssembler out there and use it for compatibility.
for (PipelineAssemblerFactory factory : ServiceFinder.find(PipelineAssemblerFactory.class,classLoader)) {
PipelineAssembler assembler = factory.doCreate(bindingId);
if(assembler!=null) {
logger.log(Level.FINE, "{0} successfully created {1}", new Object[]{factory.getClass(), assembler});
return new TubelineAssemblerAdapter(assembler);
}
}
// default binding IDs that are known
return new MetroTubelineAssembler(bindingId, MetroTubelineAssembler.JAXWS_TUBES_CONFIG_NAMES);
}
private static class TubelineAssemblerAdapter implements TubelineAssembler {
private PipelineAssembler assembler;
TubelineAssemblerAdapter(PipelineAssembler assembler) {
this.assembler = assembler;
}
@Override
public @NotNull Tube createClient(@NotNull ClientTubeAssemblerContext context) {
ClientPipeAssemblerContext ctxt = new ClientPipeAssemblerContext(
context.getAddress(), context.getWsdlModel(), context.getService(),
context.getBinding(), context.getContainer());
return PipeAdapter.adapt(assembler.createClient(ctxt));
}
@Override
public @NotNull Tube createServer(@NotNull ServerTubeAssemblerContext context) {
if (!(context instanceof ServerPipeAssemblerContext)) {
throw new IllegalArgumentException("{0} is not instance of ServerPipeAssemblerContext");
}
return PipeAdapter.adapt(assembler.createServer((ServerPipeAssemblerContext) context));
}
}
private static final Logger logger = Logger.getLogger(TubelineAssemblerFactory.class.getName());
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.xml.internal.ws.api.pipe.Pipe;
import com.sun.xml.internal.ws.api.pipe.PipeCloner;
import com.sun.xml.internal.ws.api.message.Packet;
/**
* Default implementation of {@link Pipe} that is used as a filter.
*
* <p>
* A filter pipe works on a {@link Packet}, then pass it onto the next pipe.
*
*
* <h2>How do I implement a filter?</h2>
* <p>
* Filter {@link Pipe}s are ideal for those components that wish to
* do some of the followings:
*
* <dl>
* <dt><b>
* To read an incoming message and perform some work before the
* application (or more precisely the next pipe sees it)
* </b>
* <dd>
* Implement the {@link #process} method and do some processing before
* you pass the packet to the next pipe:
* <pre>
* process(request) {
* doSomethingWith(request);
* return next.process(request);
* }
* </pre>
*
*
* <dt><b>
* To intercept an incoming message and prevent the next pipe from seeing it.
* </b>
* <dd>
* Implement the {@link #process} method and do some processing,
* then do NOT pass the request onto the next pipe.
* <pre>
* process(request) {
* if(isSomethingWrongWith(request))
* return createErrorMessage();
* else
* return next.proces(request);
* }
* </pre>
*
* <dt><b>
* To post process a reply and possibly modify a message:
* </b>
* <dd>
* Implement the {@link #process} method and do some processing,
* then do NOT pass the request onto the next pipe.
* <pre>
* process(request) {
* op = request.getMessage().getOperation();
* reply = next.proces(request);
* if(op is something I care) {
* reply = playWith(reply);
* }
* return reply;
* }
* </pre>
*
* </dl>
*
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractFilterPipeImpl extends AbstractPipeImpl {
/**
* Next pipe to call.
*/
protected final Pipe next;
protected AbstractFilterPipeImpl(Pipe next) {
this.next = next;
assert next!=null;
}
protected AbstractFilterPipeImpl(AbstractFilterPipeImpl that, PipeCloner cloner) {
super(that, cloner);
this.next = cloner.copy(that.next);
assert next!=null;
}
public Packet process(Packet packet) {
return next.process(packet);
}
@Override
public void preDestroy() {
next.preDestroy();
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.pipe.NextAction;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
/**
* Convenient default implementation for filtering {@link Tube}.
*
* <p>
* In this prototype, this is not that convenient, but in the real production
* code where we have {@code preDestroy()} and {@code clone()}, this
* is fairly handy.
*
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractFilterTubeImpl extends AbstractTubeImpl {
protected final Tube next;
protected AbstractFilterTubeImpl(Tube next) {
this.next = next;
}
protected AbstractFilterTubeImpl(AbstractFilterTubeImpl that, TubeCloner cloner) {
super(that, cloner);
if (that.next != null) {
this.next = cloner.copy(that.next);
} else {
this.next = null;
}
}
/**
* Default no-op implementation.
*/
public @NotNull NextAction processRequest(Packet request) {
return doInvoke(next,request);
}
/**
* Default no-op implementation.
*/
public @NotNull NextAction processResponse(Packet response) {
return doReturnWith(response);
}
/**
* Default no-op implementation.
*/
public @NotNull NextAction processException(Throwable t) {
return doThrow(t);
}
public void preDestroy() {
if (next != null) {
next.preDestroy();
}
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.xml.internal.ws.api.pipe.Pipe;
import com.sun.xml.internal.ws.api.pipe.PipeCloner;
/**
* Partial default implementation of {@link Pipe}.
*
* <p>
* To be shielded from potentail changes in JAX-WS,
* please consider extending from this class, instead
* of implementing {@link Pipe} directly.
*
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractPipeImpl implements Pipe {
/**
* Do-nothing constructor.
*/
protected AbstractPipeImpl() {
}
/**
* Basis for the copy constructor.
*
* <p>
* This registers the newly created {@link Pipe} with the {@link PipeCloner}
* through {@link PipeCloner#add(Pipe, Pipe)}.
*/
protected AbstractPipeImpl(Pipe that, PipeCloner cloner) {
cloner.add(that,this);
}
public void preDestroy() {
// noop
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.pipe.Fiber;
import com.sun.xml.internal.ws.api.pipe.NextAction;
import com.sun.xml.internal.ws.api.pipe.Pipe;
import com.sun.xml.internal.ws.api.pipe.PipeCloner;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
/**
* Base class for {@link Tube} implementation.
*
* <p>
* This can be also used as a {@link Pipe}, and thus effectively
* making every {@link Tube} usable as a {@link Pipe}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractTubeImpl implements Tube, Pipe {
/**
* Default constructor.
*/
protected AbstractTubeImpl() {
}
/**
* Copy constructor.
*/
protected AbstractTubeImpl(AbstractTubeImpl that, TubeCloner cloner) {
cloner.add(that,this);
}
protected final NextAction doInvoke(Tube next, Packet packet) {
NextAction na = new NextAction();
na.invoke(next,packet);
return na;
}
protected final NextAction doInvokeAndForget(Tube next, Packet packet) {
NextAction na = new NextAction();
na.invokeAndForget(next,packet);
return na;
}
protected final NextAction doReturnWith(Packet response) {
NextAction na = new NextAction();
na.returnWith(response);
return na;
}
protected final NextAction doThrow(Packet response, Throwable t) {
NextAction na = new NextAction();
na.throwException(response, t);
return na;
}
@Deprecated
protected final NextAction doSuspend() {
NextAction na = new NextAction();
na.suspend();
return na;
}
protected final NextAction doSuspend(Runnable onExitRunnable) {
NextAction na = new NextAction();
na.suspend(onExitRunnable);
return na;
}
@Deprecated
protected final NextAction doSuspend(Tube next) {
NextAction na = new NextAction();
na.suspend(next);
return na;
}
protected final NextAction doSuspend(Tube next, Runnable onExitRunnable) {
NextAction na = new NextAction();
na.suspend(next, onExitRunnable);
return na;
}
protected final NextAction doThrow(Throwable t) {
NextAction na = new NextAction();
na.throwException(t);
return na;
}
/**
* "Dual stack" compatibility mechanism.
* Allows {@link Tube} to be invoked from a {@link Pipe}.
*/
public Packet process(Packet p) {
return Fiber.current().runSync(this,p);
}
/**
* Needs to be implemented by the derived class, but we can't make it abstract
* without upsetting javac.
*/
public final AbstractTubeImpl copy(PipeCloner cloner) {
return copy((TubeCloner)cloner);
}
public abstract AbstractTubeImpl copy(TubeCloner cloner);
}

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.pipe.Fiber;
import com.sun.xml.internal.ws.api.pipe.NextAction;
import com.sun.xml.internal.ws.api.pipe.Pipe;
import com.sun.xml.internal.ws.api.pipe.PipeCloner;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
/**
* {@link Tube} that invokes {@link Pipe}.
*
* <p>
* This can be used to make a {@link Pipe} look like a {@link Tube}.
*
* @author Kohsuke Kawaguchi
* @author Jitendra Kotamraju
*/
public class PipeAdapter extends AbstractTubeImpl {
private final Pipe next;
public static Tube adapt(Pipe p) {
if (p instanceof Tube) {
return (Tube) p;
} else {
return new PipeAdapter(p);
}
}
public static Pipe adapt(Tube p) {
if (p instanceof Pipe) {
return (Pipe) p;
} else {
class TubeAdapter extends AbstractPipeImpl {
private final Tube t;
public TubeAdapter(Tube t) {
this.t = t;
}
private TubeAdapter(TubeAdapter that, PipeCloner cloner) {
super(that, cloner);
this.t = cloner.copy(that.t);
}
public Packet process(Packet request) {
return Fiber.current().runSync(t,request);
}
public Pipe copy(PipeCloner cloner) {
return new TubeAdapter(this,cloner);
}
}
return new TubeAdapter(p);
}
}
private PipeAdapter(Pipe next) {
this.next = next;
}
/**
* Copy constructor
*/
private PipeAdapter(PipeAdapter that, TubeCloner cloner) {
super(that,cloner);
this.next = ((PipeCloner)cloner).copy(that.next);
}
/**
* Uses the current fiber and runs the whole pipe to the completion
* (meaning everything from now on will run synchronously.)
*/
public @NotNull NextAction processRequest(@NotNull Packet p) {
return doReturnWith(next.process(p));
}
public @NotNull NextAction processResponse(@NotNull Packet p) {
throw new IllegalStateException();
}
@NotNull
public NextAction processException(@NotNull Throwable t) {
throw new IllegalStateException();
}
public void preDestroy() {
next.preDestroy();
}
public PipeAdapter copy(TubeCloner cloner) {
return new PipeAdapter(this,cloner);
}
public String toString() {
return super.toString()+"["+next.toString()+"]";
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Default partial implementations of {@link com.sun.xml.internal.ws.api.pipe.Pipe}.
*
* <p>
* This is intended to be useful for projects building on
* top of the JAX-WS RI.
*/
package com.sun.xml.internal.ws.api.pipe.helper;
import com.sun.xml.internal.ws.api.pipe.Pipe;

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* {@link com.sun.xml.internal.ws.api.pipe.Pipe} and related abstractions.
*/
package com.sun.xml.internal.ws.api.pipe;