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,184 @@
/*
* 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.server.provider;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
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.ThrowableContainerPropertySet;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.server.AsyncProvider;
import com.sun.xml.internal.ws.api.server.AsyncProviderCallback;
import com.sun.xml.internal.ws.api.server.Invoker;
import com.sun.xml.internal.ws.api.server.WSEndpoint;
import com.sun.xml.internal.ws.server.AbstractWebServiceContext;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This {@link Tube} is used to invoke the {@link AsyncProvider} endpoints.
*
* @author Jitendra Kotamraju
*/
public // TODO needed by factory
class AsyncProviderInvokerTube<T> extends ProviderInvokerTube<T> {
private static final Logger LOGGER = Logger.getLogger(
com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server.AsyncProviderInvokerTube");
public AsyncProviderInvokerTube(Invoker invoker, ProviderArgumentsBuilder<T> argsBuilder) {
super(invoker, argsBuilder);
}
/*
* This binds the parameter for Provider endpoints and invokes the
* invoke() method of {@linke Provider} endpoint. The return value from
* invoke() is used to create a new {@link Message} that traverses
* through the Pipeline to transport.
*/
public @NotNull NextAction processRequest(@NotNull Packet request) {
T param = argsBuilder.getParameter(request);
NoSuspendResumer resumer = new NoSuspendResumer();
@SuppressWarnings({ "rawtypes", "unchecked" })
AsyncProviderCallbackImpl callback = new AsyncProviderInvokerTube.AsyncProviderCallbackImpl(request, resumer);
AsyncWebServiceContext ctxt = new AsyncWebServiceContext(getEndpoint(),request);
AsyncProviderInvokerTube.LOGGER.fine("Invoking AsyncProvider Endpoint");
try {
getInvoker(request).invokeAsyncProvider(request, param, callback, ctxt);
} catch(Throwable e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
return doThrow(e);
}
synchronized(callback) {
if (resumer.response != null) {
// Only used by AsyncProvider<Packet>
// Implementation may pass Packet containing throwable; use both
ThrowableContainerPropertySet tc = resumer.response.getSatellite(ThrowableContainerPropertySet.class);
Throwable t = (tc != null) ? tc.getThrowable() : null;
return t != null ? doThrow(resumer.response, t) : doReturnWith(resumer.response);
}
// Suspend the Fiber. AsyncProviderCallback will resume the Fiber after
// it receives response.
callback.resumer = new FiberResumer();
return doSuspend();
}
}
private interface Resumer {
public void onResume(Packet response);
}
/*private*/ public class FiberResumer implements Resumer { // TODO public for DISI
private final Fiber fiber;
public FiberResumer() {
this.fiber = Fiber.current();
}
public void onResume(Packet response) {
// Only used by AsyncProvider<Packet>
// Implementation may pass Packet containing throwable; use both
ThrowableContainerPropertySet tc = response.getSatellite(ThrowableContainerPropertySet.class);
Throwable t = (tc != null) ? tc.getThrowable() : null;
fiber.resume(t, response);
}
}
private class NoSuspendResumer implements Resumer {
protected Packet response = null;
public void onResume(Packet response) {
this.response = response;
}
}
/*private*/ public class AsyncProviderCallbackImpl implements AsyncProviderCallback<T> { // TODO public for DISI
private final Packet request;
private Resumer resumer;
public AsyncProviderCallbackImpl(Packet request, Resumer resumer) {
this.request = request;
this.resumer = resumer;
}
public void send(@Nullable T param) {
if (param == null) {
if (request.transportBackChannel != null) {
request.transportBackChannel.close();
}
}
Packet packet = argsBuilder.getResponse(request, param, getEndpoint().getPort(), getEndpoint().getBinding());
synchronized(this) {
resumer.onResume(packet);
}
}
public void sendError(@NotNull Throwable t) {
Exception e;
if (t instanceof Exception) {
e = (Exception) t;
} else {
e = new RuntimeException(t);
}
Packet packet = argsBuilder.getResponse(request, e, getEndpoint().getPort(), getEndpoint().getBinding());
synchronized(this) {
resumer.onResume(packet);
}
}
}
/**
* The single {@link javax.xml.ws.WebServiceContext} instance injected into application.
*/
/*private static final*/ public class AsyncWebServiceContext extends AbstractWebServiceContext { // TODO public for DISI
final Packet packet;
public AsyncWebServiceContext(WSEndpoint endpoint, Packet packet) { // TODO public for DISI
super(endpoint);
this.packet = packet;
}
public @NotNull Packet getRequestPacket() {
return packet;
}
}
public @NotNull NextAction processResponse(@NotNull Packet response) {
return doReturnWith(response);
}
public @NotNull NextAction processException(@NotNull Throwable t) {
return doThrow(t);
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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.server.provider;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.message.Message;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
/**
* @author Kohsuke Kawaguchi
*/
final class MessageProviderArgumentBuilder extends ProviderArgumentsBuilder<Message> {
private final SOAPVersion soapVersion;
public MessageProviderArgumentBuilder(SOAPVersion soapVersion) {
this.soapVersion = soapVersion;
}
@Override
/*protected*/ public Message getParameter(Packet packet) {
return packet.getMessage();
}
@Override
protected Message getResponseMessage(Message returnValue) {
return returnValue;
}
@Override
protected Message getResponseMessage(Exception e) {
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
}

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.server.provider;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.SOAPVersion;
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.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
import javax.xml.ws.soap.SOAPBinding;
/**
* @author Jitendra Kotamraju
*/
public // TODO need this in the factory
abstract class ProviderArgumentsBuilder<T> {
/**
* Creates a fault {@link Message} from method invocation's exception
*/
protected abstract Message getResponseMessage(Exception e);
/**
* Creates {@link Message} from method invocation's return value
*/
protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) {
Message message = getResponseMessage(e);
Packet response = request.createServerResponse(message,port,null,binding);
return response;
}
/**
* Binds {@link com.sun.xml.internal.ws.api.message.Message} to method invocation parameter
* @param packet
*/
/*protected*/ public abstract T getParameter(Packet packet); // TODO public for DISI pluggable Provider
protected abstract Message getResponseMessage(T returnValue);
/**
* Creates {@link Packet} from method invocation's return value
*/
protected Packet getResponse(Packet request, @Nullable T returnValue, WSDLPort port, WSBinding binding) {
Message message = null;
if (returnValue != null) {
message = getResponseMessage(returnValue);
}
Packet response = request.createServerResponse(message,port,null,binding);
return response;
}
public static ProviderArgumentsBuilder<?> create(ProviderEndpointModel model, WSBinding binding) {
if (model.datatype == Packet.class)
return new PacketProviderArgumentsBuilder(binding.getSOAPVersion());
return (binding instanceof SOAPBinding) ? SOAPProviderArgumentBuilder.create(model, binding.getSOAPVersion())
: XMLProviderArgumentBuilder.createBuilder(model, binding);
}
private static class PacketProviderArgumentsBuilder extends ProviderArgumentsBuilder<Packet> {
private final SOAPVersion soapVersion;
public PacketProviderArgumentsBuilder(SOAPVersion soapVersion) {
this.soapVersion = soapVersion;
}
@Override
protected Message getResponseMessage(Exception e) {
// Will be called by AsyncProviderCallbackImpl.sendError
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
@Override
/*protected*/ public Packet getParameter(Packet packet) {
return packet;
}
@Override
protected Message getResponseMessage(Packet returnValue) {
// Should never be called
throw new IllegalStateException();
}
@Override
protected Packet getResponse(Packet request, @Nullable Packet returnValue, WSDLPort port, WSBinding binding) {
return returnValue;
}
}
}

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.server.provider;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.server.AsyncProvider;
import com.sun.xml.internal.ws.resources.ServerMessages;
import com.sun.xml.internal.ws.spi.db.BindingHelper;
import javax.activation.DataSource;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPBinding;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* Keeps the runtime information like Service.Mode and erasure of Provider class
* about Provider endpoint. It proccess annotations to find about Service.Mode
* It also finds about parameterized type(e.g. Source, SOAPMessage, DataSource)
* of endpoint class.
*
* @author Jitendra Kotamraju
* @author Kohsuke Kawaguchi
*/
final class ProviderEndpointModel<T> {
/**
* True if this is {@link AsyncProvider}.
*/
final boolean isAsync;
/**
* In which mode does this provider operate?
*/
@NotNull final Service.Mode mode;
/**
* T of {@link Provider}&lt;T>.
*/
@NotNull final Class datatype;
/**
* User class that extends {@link Provider}.
*/
@NotNull final Class implClass;
ProviderEndpointModel(Class<T> implementorClass, WSBinding binding) {
assert implementorClass != null;
assert binding != null;
implClass = implementorClass;
mode = getServiceMode(implementorClass);
Class otherClass = (binding instanceof SOAPBinding)
? SOAPMessage.class : DataSource.class;
isAsync = AsyncProvider.class.isAssignableFrom(implementorClass);
Class<? extends Object> baseType = isAsync ? AsyncProvider.class : Provider.class;
Type baseParam = BindingHelper.getBaseType(implementorClass, baseType);
if (baseParam==null)
throw new WebServiceException(ServerMessages.NOT_IMPLEMENT_PROVIDER(implementorClass.getName()));
if (!(baseParam instanceof ParameterizedType))
throw new WebServiceException(ServerMessages.PROVIDER_NOT_PARAMETERIZED(implementorClass.getName()));
ParameterizedType pt = (ParameterizedType)baseParam;
Type[] types = pt.getActualTypeArguments();
if(!(types[0] instanceof Class))
throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(implementorClass.getName(),types[0]));
datatype = (Class)types[0];
if (mode == Service.Mode.PAYLOAD && datatype!=Source.class) {
// Illegal to have PAYLOAD && SOAPMessage
// Illegal to have PAYLOAD && DataSource
throw new IllegalArgumentException(
"Illeagal combination - Mode.PAYLOAD and Provider<"+otherClass.getName()+">");
}
}
/**
* Is it PAYLOAD or MESSAGE ??
*
* @param c endpoint class
* @return Service.Mode.PAYLOAD or Service.Mode.MESSAGE
*/
private static Service.Mode getServiceMode(Class<?> c) {
ServiceMode mode = c.getAnnotation(ServiceMode.class);
return (mode == null) ? Service.Mode.PAYLOAD : mode.value();
}
}

View File

@@ -0,0 +1,65 @@
/*
* 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.server.provider;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.api.server.AsyncProvider;
import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.api.server.Invoker;
import com.sun.xml.internal.ws.api.server.ProviderInvokerTubeFactory;
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
import com.sun.xml.internal.ws.server.InvokerTube;
import javax.xml.ws.Provider;
/**
* This {@link Tube} is used to invoke the {@link Provider} and {@link AsyncProvider} endpoints.
*
* @author Jitendra Kotamraju
*/
public abstract class ProviderInvokerTube<T> extends InvokerTube<Provider<T>> {
protected ProviderArgumentsBuilder<T> argsBuilder;
/*package*/ ProviderInvokerTube(Invoker invoker, ProviderArgumentsBuilder<T> argsBuilder) {
super(invoker);
this.argsBuilder = argsBuilder;
}
public static <T> ProviderInvokerTube<T>
create(final Class<T> implType, final WSBinding binding, final Invoker invoker, final Container container) {
final ProviderEndpointModel<T> model = new ProviderEndpointModel<T>(implType, binding);
final ProviderArgumentsBuilder<?> argsBuilder = ProviderArgumentsBuilder.create(model, binding);
if (binding instanceof SOAPBindingImpl) {
//set portKnownHeaders on Binding, so that they can be used for MU processing
((SOAPBindingImpl) binding).setMode(model.mode);
}
return ProviderInvokerTubeFactory.create(null, container, implType, invoker, argsBuilder, model.isAsync);
}
}

View File

@@ -0,0 +1,162 @@
/*
* 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.server.provider;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.SOAPVersion;
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.Messages;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
import com.sun.xml.internal.ws.resources.ServerMessages;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author Jitendra Kotamraju
*/
abstract class SOAPProviderArgumentBuilder<T> extends ProviderArgumentsBuilder<T> {
protected final SOAPVersion soapVersion;
private SOAPProviderArgumentBuilder(SOAPVersion soapVersion) {
this.soapVersion = soapVersion;
}
static ProviderArgumentsBuilder create(ProviderEndpointModel model, SOAPVersion soapVersion) {
if (model.mode == Service.Mode.PAYLOAD) {
return new PayloadSource(soapVersion);
} else {
if(model.datatype==Source.class)
return new MessageSource(soapVersion);
if(model.datatype==SOAPMessage.class)
return new SOAPMessageParameter(soapVersion);
if(model.datatype==Message.class)
return new MessageProviderArgumentBuilder(soapVersion);
throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
}
}
private static final class PayloadSource extends SOAPProviderArgumentBuilder<Source> {
PayloadSource(SOAPVersion soapVersion) {
super(soapVersion);
}
/*protected*/ public Source getParameter(Packet packet) {
return packet.getMessage().readPayloadAsSource();
}
protected Message getResponseMessage(Source source) {
return Messages.createUsingPayload(source, soapVersion);
}
protected Message getResponseMessage(Exception e) {
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
}
private static final class MessageSource extends SOAPProviderArgumentBuilder<Source> {
MessageSource(SOAPVersion soapVersion) {
super(soapVersion);
}
/*protected*/ public Source getParameter(Packet packet) {
return packet.getMessage().readEnvelopeAsSource();
}
protected Message getResponseMessage(Source source) {
return Messages.create(source, soapVersion);
}
protected Message getResponseMessage(Exception e) {
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
}
private static final class SOAPMessageParameter extends SOAPProviderArgumentBuilder<SOAPMessage> {
SOAPMessageParameter(SOAPVersion soapVersion) {
super(soapVersion);
}
/*protected*/ public SOAPMessage getParameter(Packet packet) {
try {
return packet.getMessage().readAsSOAPMessage(packet, true);
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
protected Message getResponseMessage(SOAPMessage soapMsg) {
return Messages.create(soapMsg);
}
protected Message getResponseMessage(Exception e) {
return SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, e);
}
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
Packet response = super.getResponse(request, returnValue, port, binding);
// Populate SOAPMessage's transport headers
if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
MimeHeaders hdrs = returnValue.getMimeHeaders();
Map<String, List<String>> headers = new HashMap<String, List<String>>();
Iterator i = hdrs.getAllHeaders();
while(i.hasNext()) {
MimeHeader header = (MimeHeader)i.next();
if(header.getName().equalsIgnoreCase("SOAPAction"))
// SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
// so ignore this header.
continue;
List<String> list = headers.get(header.getName());
if (list == null) {
list = new ArrayList<String>();
headers.put(header.getName(), list);
}
list.add(header.getValue());
}
response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
}
return response;
}
}
}

View File

@@ -0,0 +1,101 @@
/*
* 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.server.provider;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.NextAction;
import com.sun.xml.internal.ws.api.pipe.ThrowableContainerPropertySet;
import com.sun.xml.internal.ws.api.server.Invoker;
import javax.xml.ws.Provider;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This tube is used to invoke the {@link Provider} endpoints.
*
* @author Jitendra Kotamraju
*/
public // TODO needed by factory
class SyncProviderInvokerTube<T> extends ProviderInvokerTube<T> {
private static final Logger LOGGER = Logger.getLogger(
com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server.SyncProviderInvokerTube");
public SyncProviderInvokerTube(Invoker invoker, ProviderArgumentsBuilder<T> argsBuilder) {
super(invoker, argsBuilder);
}
/*
* This binds the parameter for Provider endpoints and invokes the
* invoke() method of {@linke Provider} endpoint. The return value from
* invoke() is used to create a new {@link Message} that traverses
* through the Pipeline to transport.
*/
public NextAction processRequest(Packet request) {
WSDLPort port = getEndpoint().getPort();
WSBinding binding = getEndpoint().getBinding();
T param = argsBuilder.getParameter(request);
LOGGER.fine("Invoking Provider Endpoint");
T returnValue;
try {
returnValue = getInvoker(request).invokeProvider(request, param);
} catch(Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
Packet response = argsBuilder.getResponse(request,e,port,binding);
return doReturnWith(response);
}
if (returnValue == null) {
// Oneway. Send response code immediately for transports(like HTTP)
// Don't do this above, since close() may generate some exceptions
if (request.transportBackChannel != null) {
request.transportBackChannel.close();
}
}
Packet response = argsBuilder.getResponse(request,returnValue,port,binding);
// Only used by Provider<Packet>
// Implementation may pass Packet containing throwable; use both
ThrowableContainerPropertySet tc = response.getSatellite(ThrowableContainerPropertySet.class);
Throwable t = (tc != null) ? tc.getThrowable() : null;
return t != null ? doThrow(response, t) : doReturnWith(response);
}
public @NotNull NextAction processResponse(@NotNull Packet response) {
return doReturnWith(response);
}
public @NotNull NextAction processException(@NotNull Throwable t) {
return doThrow(t);
}
}

View File

@@ -0,0 +1,108 @@
/*
* 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.server.provider;
import com.sun.xml.internal.ws.api.SOAPVersion;
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.Messages;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.encoding.xml.XMLMessage;
import com.sun.xml.internal.ws.resources.ServerMessages;
import javax.activation.DataSource;
import javax.xml.transform.Source;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPException;
/**
* @author Jitendra Kotamraju
*/
abstract class XMLProviderArgumentBuilder<T> extends ProviderArgumentsBuilder<T> {
@Override
protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) {
Packet response = super.getResponse(request, e, port, binding);
if (e instanceof HTTPException) {
if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) {
response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode());
}
}
return response;
}
static XMLProviderArgumentBuilder createBuilder(ProviderEndpointModel model, WSBinding binding) {
if (model.mode == Service.Mode.PAYLOAD) {
return new PayloadSource();
} else {
if(model.datatype==Source.class)
return new PayloadSource();
if(model.datatype== DataSource.class)
return new DataSourceParameter(binding);
throw new WebServiceException(ServerMessages.PROVIDER_INVALID_PARAMETER_TYPE(model.implClass,model.datatype));
}
}
private static final class PayloadSource extends XMLProviderArgumentBuilder<Source> {
public Source getParameter(Packet packet) {
return packet.getMessage().readPayloadAsSource();
}
public Message getResponseMessage(Source source) {
return Messages.createUsingPayload(source, SOAPVersion.SOAP_11);
}
protected Message getResponseMessage(Exception e) {
return XMLMessage.create(e);
}
}
private static final class DataSourceParameter extends XMLProviderArgumentBuilder<DataSource> {
private final WSBinding binding;
DataSourceParameter(WSBinding binding) {
this.binding = binding;
}
public DataSource getParameter(Packet packet) {
Message msg = packet.getInternalMessage();
return (msg instanceof XMLMessage.MessageDataSource)
? ((XMLMessage.MessageDataSource) msg).getDataSource()
: XMLMessage.getDataSource(msg, binding.getFeatures());
}
public Message getResponseMessage(DataSource ds) {
return XMLMessage.create(ds, binding.getFeatures());
}
protected Message getResponseMessage(Exception e) {
return XMLMessage.create(e);
}
}
}