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,99 @@
/*
* 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.server;
import com.sun.istack.internal.Nullable;
import com.sun.istack.internal.localization.Localizable;
import com.sun.xml.internal.ws.api.server.InstanceResolver;
import com.sun.xml.internal.ws.api.server.ResourceInjector;
import com.sun.xml.internal.ws.api.server.WSEndpoint;
import com.sun.xml.internal.ws.resources.ServerMessages;
import com.sun.xml.internal.ws.server.ServerRtException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* Partial implementation of {@link InstanceResolver} with
* convenience methods to do the resource injection.
*
* @author Kohsuke Kawaguchi
* @since 2.2.6
*/
public abstract class AbstractInstanceResolver<T> extends InstanceResolver<T> {
protected static ResourceInjector getResourceInjector(WSEndpoint endpoint) {
ResourceInjector ri = endpoint.getContainer().getSPI(ResourceInjector.class);
if(ri==null)
ri = ResourceInjector.STANDALONE;
return ri;
}
/**
* Helper for invoking a method with elevated privilege.
*/
protected static void invokeMethod(final @Nullable Method method, final Object instance, final Object... args) {
if(method==null) return;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
try {
if (!method.isAccessible()) {
method.setAccessible(true);
}
MethodUtil.invoke(instance,method, args);
} catch (IllegalAccessException e) {
throw new ServerRtException("server.rt.err",e);
} catch (InvocationTargetException e) {
throw new ServerRtException("server.rt.err",e);
}
return null;
}
});
}
/**
* Finds the method that has the given annotation, while making sure that
* there's only at most one such method.
*/
protected final @Nullable Method findAnnotatedMethod(Class clazz, Class<? extends Annotation> annType) {
boolean once = false;
Method r = null;
for(Method method : clazz.getDeclaredMethods()) {
if (method.getAnnotation(annType) != null) {
if (once)
throw new ServerRtException(ServerMessages.ANNOTATION_ONLY_ONCE(annType));
if (method.getParameterTypes().length != 0)
throw new ServerRtException(ServerMessages.NOT_ZERO_PARAMETERS(method));
r = method;
once = true;
}
}
return r;
}
}

View File

@@ -0,0 +1,159 @@
/*
* 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.server;
import com.oracle.webservices.internal.api.message.PropertySet;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
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.Codec;
import com.sun.xml.internal.ws.util.Pool;
import java.io.IOException;
/**
* Partial server side async transport implementation. It manages pooling of
* {@link Codec} and other details.
*
* @author Jitendra Kotamraju
*/
public abstract class AbstractServerAsyncTransport<T> {
private final WSEndpoint endpoint;
private final CodecPool codecPool;
/**
* {@link WSEndpoint#setExecutor} should be called before creating the
* transport
*
* @param endpoint webservices requests are directed towards this endpoint
*/
public AbstractServerAsyncTransport(WSEndpoint endpoint) {
this.endpoint = endpoint;
codecPool = new CodecPool(endpoint);
}
/**
* decodes the transport data to Packet
*
* @param connection that carries the web service request
* @param codec for encoding/decoding {@link Message}
* @return decoded {@link Packet}
* @throws IOException if an i/o error happens while encoding/decoding
*/
protected Packet decodePacket(T connection, @NotNull Codec codec) throws IOException {
Packet packet = new Packet();
packet.acceptableMimeTypes = getAcceptableMimeTypes(connection);
packet.addSatellite(getPropertySet(connection));
packet.transportBackChannel = getTransportBackChannel(connection);
return packet;
}
/**
* Encodes the {@link Packet} to infoset and writes on the connection.
*
* @param connection that carries the web service request
* @param packet that needs to encoded to infoset
* @param codec that does the encoding of Packet
* @throws IOException if an i/o error happens while encoding/decoding
*/
protected abstract void encodePacket(T connection, @NotNull Packet packet, @NotNull Codec codec) throws IOException;
/**
* If the request has Accept header, return that value
*
* @param connection that carries the web service request
* @return Accept MIME types
*/
protected abstract @Nullable String getAcceptableMimeTypes(T connection);
/**
* {@link TransportBackChannel} used by jax-ws runtime to close the connection
* while the processing of the request is still continuing. In oneway HTTP case, a
* response code needs to be sent before invoking the endpoint.
*
* @param connection that carries the web service request
* @return TransportBackChannel instance using the connection
*/
protected abstract @Nullable TransportBackChannel getTransportBackChannel(T connection);
/**
* If there are any properties associated with the connection, those will
* be added to {@link Packet}
*
* @param connection that carries the web service request
* @return {@link PropertySet} for the connection
*/
protected abstract @NotNull PropertySet getPropertySet(T connection);
/**
* Return a {@link WebServiceContextDelegate} using the underlying connection.
*
* @param connection that carries the web service request
* @return non-null WebServiceContextDelegate instance
*/
protected abstract @NotNull WebServiceContextDelegate getWebServiceContextDelegate(T connection);
/**
* Reads and decodes infoset from the connection and invokes the endpoints. The
* response is encoded and written to the connection. The response could be
* written using a different thread.
*
* @param connection that carries the web service request
* @throws IOException if an i/o error happens while encoding/decoding
*/
protected void handle(final T connection) throws IOException {
final Codec codec = codecPool.take();
Packet request = decodePacket(connection, codec);
if (!request.getMessage().isFault()) {
endpoint.schedule(request, new WSEndpoint.CompletionCallback() {
public void onCompletion(@NotNull Packet response) {
try {
encodePacket(connection, response, codec);
} catch(IOException ioe) {
ioe.printStackTrace();
}
codecPool.recycle(codec);
}
});
}
}
private static final class CodecPool extends Pool<Codec> {
WSEndpoint endpoint;
CodecPool(WSEndpoint endpoint) {
this. endpoint = endpoint;
}
protected Codec create() {
return endpoint.createCodec();
}
}
}

View File

@@ -0,0 +1,186 @@
/*
* 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.server;
import com.sun.xml.internal.ws.api.config.management.Reconfigurable;
import com.sun.xml.internal.ws.api.Component;
import com.sun.xml.internal.ws.api.pipe.Codec;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.server.WSEndpoint.PipeHead;
import com.sun.xml.internal.ws.util.Pool;
/**
* Receives incoming messages from a transport (such as HTTP, JMS, etc)
* in a transport specific way, and delivers it to {@link WSEndpoint.PipeHead#process}.
*
* <p>
* Since this class mostly concerns itself with converting a
* transport-specific message representation to a {@link Packet},
* the name is the "adapter".
*
* <p>
* The purpose of this class is twofolds:
*
* <ol>
* <li>
* To hide the logic of converting a transport-specific connection
* to a {@link Packet} and do the other way around.
*
* <li>
* To manage thread-unsafe resources, such as {@link WSEndpoint.PipeHead},
* and {@link Codec}.
* </ol>
*
* <p>
* {@link Adapter}s are extended to work with each kind of transport,
* and therefore {@link Adapter} class itself is not all that
* useful by itself --- it merely provides a design template
* that can be followed.
*
* <p>
* For managing resources, an adapter uses an object called {@link Toolkit}
* (think of it as a tray full of tools that a dentist uses ---
* trays are identical, but each patient has to get one. You have
* a pool of them and you assign it to a patient.)
*
* {@link Adapter.Toolkit} can be extended by derived classes.
* That actual type is the {@code TK} type parameter this class takes.
*
* @author Kohsuke Kawaguchi
*/
public abstract class Adapter<TK extends Adapter.Toolkit>
implements Reconfigurable, Component {
protected final WSEndpoint<?> endpoint;
/**
* Object that groups all thread-unsafe resources.
*/
public class Toolkit {
/**
* For encoding/decoding infoset to/from the byte stream.
*/
public final Codec codec;
/**
* This object from {@link WSEndpoint} serves the request.
*/
public final PipeHead head;
public Toolkit() {
this.codec = endpoint.createCodec();
this.head = endpoint.createPipeHead();
}
}
/**
* Pool of {@link Toolkit}s.
*
* Instances of this pool may be replaced at runtime. Therefore, when you take
* an object out of the pool, you must make sure that it is recycled by the
* same instance of the pool.
*/
protected volatile Pool<TK> pool = new Pool<TK>() {
protected TK create() {
return createToolkit();
}
};
/**
* Creates an {@link Adapter} that delivers
* messages to the given endpoint.
*/
protected Adapter(WSEndpoint endpoint) {
assert endpoint!=null;
this.endpoint = endpoint;
// Enables other components to reconfigure this adapter
endpoint.getComponents().add(getEndpointComponent());
}
protected Component getEndpointComponent() {
return new Component() {
public <S> S getSPI(Class<S> spiType) {
if (spiType.isAssignableFrom(Reconfigurable.class)) {
return spiType.cast(Adapter.this);
}
return null;
}
};
}
/**
* The pool instance needs to be recreated to prevent reuse of old Toolkit instances.
*/
public void reconfigure() {
this.pool = new Pool<TK>() {
protected TK create() {
return createToolkit();
}
};
}
public <S> S getSPI(Class<S> spiType) {
if (spiType.isAssignableFrom(Reconfigurable.class)) {
return spiType.cast(this);
}
if (endpoint != null) {
return endpoint.getSPI(spiType);
}
return null;
}
/**
* Gets the endpoint that this {@link Adapter} is serving.
*
* @return
* always non-null.
*/
public WSEndpoint<?> getEndpoint() {
return endpoint;
}
/**
* Returns a reference to the pool of Toolkits for this adapter.
*
* The pool may be recreated during runtime reconfiguration and this method
* will then return a reference to a new instance. When you recycle a toolkit,
* you must make sure that you return it to the same pool instance that you
* took it from.
*
* @return
*/
protected Pool<TK> getPool() {
return pool;
}
/**
* Creates a {@link Toolkit} instance.
*
* <p>
* If the derived class doesn't have to add any per-thread state
* to {@link Toolkit}, simply implement this as {@code new Toolkit()}.
*/
protected abstract TK createToolkit();
}

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.server;
import com.sun.istack.internal.NotNull;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceContext;
import java.util.concurrent.Executor;
/**
* Asynchronous version of {@link Provider}.
*
* <p>
* Applications that use the JAX-WS RI can implement this interface instead of
* {@link Provider} to implement asynchronous web services (AWS.) AWS enables
* applications to perform operations with long latency without blocking a thread,
* and thus particularly suitable for highly scalable service implementation,
* at the expesnce of implementation complexity.
*
* <h2>Programming Model</h2>
* <p>
* Whenever a new reuqest arrives, the JAX-WS RI invokes the {@link #invoke} method
* to notify the application. Normally, the application then schedules an execution
* of this request, and exit from this method immediately (the point of AWS is not
* to use this calling thread for request processing.)
*
* <p>
* Unlike the synchronous version, which requires the response to be given as the return value,
* with AWS the JAX-WS RI will keep the connection with client open, until the application
* eventually notifies the JAX-WS RI via {@link AsyncProviderCallback}. When that
* happens that causes the JAX-WS RI to send back a response to the client.
*
* <p>
* The following code shows a very simple AWS example:
*
* <pre>
* &#64;WebService
* class MyAsyncEchoService implements AsyncProvider&lt;Source> {
* private static final {@link Executor} exec = ...;
*
* public void invoke( final Source request, final AsyncProviderCallback&lt;Source> callback, final WebServiceContext context) {
* exec.execute(new {@link Runnable}() {
* public void run() {
* Thread.sleep(1000); // kill time.
* callback.send(request); // just echo back
* }
* });
* }
* }
* </pre>
*
* <p>
* Please also check the {@link Provider} and its programming model for general
* provider programming model.
*
*
* <h2>WebServiceContext</h2>
* <p>
* In synchronous web services, the injected {@link WebServiceContext} instance uses
* the calling {@link Thread} to determine which request it should return information about.
* This no longer works with AWS, as you may need to call {@link WebServiceContext}
* much later, possibly from entirely different thread.
*
* <p>
* For this reason, {@link AsyncProvider} passes in {@link WebServiceContext} as
* a parameter. This object remains usable until you invoke {@link AsyncProviderCallback},
* and it can be invoked from any thread, even concurrently. AWS must not use the injected
* {@link WebServiceContext}, as its behavior is undefined.
*
* @see Provider
* @author Jitendra Kotamraju
* @author Kohsuke Kawaguchi
* @since 2.1
*/
public interface AsyncProvider<T> {
/**
* Schedules an execution of a request.
*
* @param request
* Represents the request message or payload.
* @param callback
* Application must notify this callback interface when the processing
* of a request is complete.
* @param context
* The web service context instance that can be used to retrieve
* context information about the given request.
*/
public void invoke(
@NotNull T request,
@NotNull AsyncProviderCallback<T> callback,
@NotNull WebServiceContext context);
}

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.api.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
/**
* Callback interface to signal JAX-WS RI that the processing of an asynchronous request is complete.
*
* <p>
* The application is responsible for invoking one of the two defined methods to
* indicate the result of the request processing.
*
* <p>
* Both methods will return immediately, and the JAX-WS RI will
* send out an actual response at some later point.
*
* @author Jitendra Kotamraju
* @author Kohsuke Kawaguchi
* @since 2.1
* @see AsyncProvider
*/
public interface AsyncProviderCallback<T> {
/**
* Indicates that a request was processed successfully.
*
* @param response
* Represents an object to be sent back to the client
* as a response. To indicate one-way, response needs to be null
*/
void send(@Nullable T response);
/**
* Indicates that an error had occured while processing a request.
*
* @param t
* The error is propagated to the client. For example, if this is
* a SOAP-based web service, the server will send back a SOAP fault.
*/
void sendError(@NotNull Throwable t);
}

View File

@@ -0,0 +1,78 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.Component;
import java.net.URI;
/**
* Represents the {@link WSEndpoint} bound to a particular transport.
*
* @see Module#getBoundEndpoints()
* @author Kohsuke Kawaguchi
*/
public interface BoundEndpoint extends Component {
/**
* The endpoint that was bound.
*
* <p>
* Multiple {@link BoundEndpoint}s may point to the same {@link WSEndpoint},
* if it's bound to multiple transports.
*
* @return the endpoint
*/
@NotNull WSEndpoint getEndpoint();
/**
* The address of the bound endpoint.
*
* <p>
* For example, if this endpoint is bound to a servlet endpoint
* "http://foobar/myapp/myservice", then this method should
* return that address.
*
* @return address of the endpoint
*/
@NotNull URI getAddress();
/**
* The address of the bound endpoint using the base address. Often
* times, baseAddress is only avaialble during the request.
*
* <p>
* If the endpoint is bound to a servlet endpoint, the base address
* won't include the url-pattern, so the base address would be
* "http://host:port/context". This method would include url-pattern
* for the endpoint and return that address
* for e.g. "http://host:port/context/url-pattern"
*
* @param baseAddress that is used in computing the full address
* @return address of the endpoint
*/
@NotNull URI getAddress(String baseAddress);
}

View File

@@ -0,0 +1,114 @@
/*
* 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.server;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.Component;
import com.sun.xml.internal.ws.api.ComponentEx;
import com.sun.xml.internal.ws.api.ComponentRegistry;
/**
* Root of the SPI implemented by the container
* (such as application server.)
*
* <p>
* Often technologies that are built on top of JAX-WS
* (such as Tango) needs to negotiate private contracts between
* them and the container. This interface allows such technologies
* to query the negotiated SPI by using the {@link #getSPI(Class)}.
*
* <p>
* For example, if a security pipe needs to get some information
* from a container, they can do the following:
* <ol>
* <li>Negotiate an interface with the container and define it.
* (let's call it <tt>ContainerSecuritySPI</tt>.)
* <li>The container will implement <tt>ContainerSecuritySPI</tt>.
* <li>At the runtime, a security pipe gets
* {@link WSEndpoint} and then to {@link Container}.
* <li>It calls <tt>container.getSPI(ContainerSecuritySPI.class)</tt>
* <li>The container returns an instance of <tt>ContainerSecuritySPI</tt>.
* <li>The security pipe talks to the container through this SPI.
* </ol>
*
* <p>
* This protects JAX-WS from worrying about the details of such contracts,
* while still providing the necessary service of hooking up those parties.
*
* <p>
* Technologies that run inside JAX-WS server runtime can access this object through
* {@link WSEndpoint#getContainer()}. In the client runtime, it can be accessed from
* {@link ContainerResolver#getContainer()}
*
* @author Kohsuke Kawaguchi
* @see WSEndpoint
*/
public abstract class Container implements ComponentRegistry, ComponentEx {
private final Set<Component> components = new CopyOnWriteArraySet<Component>();
/**
* For derived classes.
*/
protected Container() {
}
/**
* Constant that represents a "no {@link Container}",
* which always returns null from {@link #getSPI(Class)}.
*/
public static final Container NONE = new NoneContainer();
private static final class NoneContainer extends Container {
}
public <S> S getSPI(Class<S> spiType) {
if (components == null) return null;
for (Component c : components) {
S s = c.getSPI(spiType);
if (s != null)
return s;
}
return null;
}
public Set<Component> getComponents() {
return components;
}
public @NotNull <E> Iterable<E> getIterableSPI(Class<E> spiType) {
E item = getSPI(spiType);
if (item != null) {
Collection<E> c = Collections.singletonList(item);
return c;
}
return Collections.emptySet();
}
}

View File

@@ -0,0 +1,88 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
/**
* This class determines an instance of {@link Container} for the runtime.
* It applies for both server and client runtimes(for e.g in Servlet could
* be accessing a Web Service).
*
* A client that is invoking a web service may be running in a
* container(for e.g servlet). T
*
* <p>
* ContainerResolver uses a static field to keep the instance of the resolver object.
* Typically appserver may set its custom container resolver using the static method
* {@link #setInstance(ContainerResolver)}
*
* @author Jitendra Kotamraju
*/
public abstract class ContainerResolver {
private static final ThreadLocalContainerResolver DEFAULT = new ThreadLocalContainerResolver();
private static volatile ContainerResolver theResolver = DEFAULT;
/**
* Sets the custom container resolver which can be used to get client's
* {@link Container}.
*
* @param resolver container resolver
*/
public static void setInstance(ContainerResolver resolver) {
if(resolver==null)
resolver = DEFAULT;
theResolver = resolver;
}
/**
* Returns the container resolver which can be used to get client's {@link Container}.
*
* @return container resolver instance
*/
public static @NotNull ContainerResolver getInstance() {
return theResolver;
}
/**
* Returns the default container resolver which can be used to get {@link Container}.
*
* @return default container resolver
*/
public static ThreadLocalContainerResolver getDefault() {
return DEFAULT;
}
/**
* Returns the {@link Container} context in which client is running.
*
* @return container instance for the client
*/
public abstract @NotNull Container getContainer();
}

View File

@@ -0,0 +1,78 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
/**
* Resolves relative references among {@link SDDocument}s.
*
* <p>
* This interface is implemented by the caller of
* {@link SDDocument#writeTo} method so
* that the {@link SDDocument} can correctly produce references
* to other documents.
*
* <p>
* This mechanism allows the user of {@link WSEndpoint} to
* assign logical URLs to each {@link SDDocument} (which is often
* necessarily done in a transport-dependent way), and then
* serve description documents.
*
*
*
* <h2>Usage Example 1</h2>
* <p>
* HTTP servlet transport chose to expose those metadata documents
* to HTTP GET requests where each {@link SDDocument} is identified
* by a simple query string "?<i>ID</i>". (HTTP servlet transport
* assigns such IDs by itself.)
*
* <p>
* In this nameing scheme, when {@link SDDocument} X refers to
* {@link SDDocument} Y, it can put a reference as "?<i>IDofY</i>".
* By implementing {@link DocumentAddressResolver} it can do so.
*
* @author Kohsuke Kawaguchi
*/
public interface DocumentAddressResolver {
/**
* Produces a relative reference from one document to another.
*
* @param current
* The document that is being generated.
* @param referenced
* The document that is referenced.
* @return
* The reference to be put inside {@code current} to refer to
* {@code referenced}. This can be a relative URL as well as
* an absolute. If null is returned, then the {@link SDDocument}
* will produce a "implicit reference" (for example, &lt;xs:import>
* without the @schemaLocation attribute, etc).
*/
@Nullable String getRelativeAddressFor(@NotNull SDDocument current, @NotNull SDDocument referenced);
}

View File

@@ -0,0 +1,44 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.pipe.Codec;
/**
* Implemented by {@link Codec}s that want to have access to
* {@link WSEndpoint} object.
*
* @author Kohsuke Kawaguchi
* @since 2.1.1
*/
public interface EndpointAwareCodec extends Codec {
/**
* Called by the {@link WSEndpoint} implementation
* when the codec is associated with an endpoint.
*/
void setEndpoint(@NotNull WSEndpoint endpoint);
}

View File

@@ -0,0 +1,54 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.Component;
/**
* Interface that allows components around {@link WSEndpoint} to hook up
* with each other.
*
* @author Kohsuke Kawaguchi
* @since 2.1.2
* @see WSEndpoint#getComponentRegistry()
* @deprecated replaced by {@link Component}
*/
public interface EndpointComponent {
/**
* Gets the specified SPI.
*
* <p>
* This method works as a kind of directory service
* for SPIs, allowing various components to define private contract
* and talk to each other.
*
* @return
* null if such an SPI is not provided by this object.
*/
@Nullable <T> T getSPI(@NotNull Class<T> spiType);
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2009, 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.server;
import javax.xml.namespace.QName;
/**
* @author Jitendra Kotamraju
*/
public abstract class EndpointData {
public abstract String getNamespace();
public abstract String getServiceName();
public abstract String getPortName();
public abstract String getImplClass();
}

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.api.server;
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
import com.sun.xml.internal.ws.api.pipe.ServerTubeAssemblerContext;
import com.sun.istack.internal.Nullable;
import javax.xml.namespace.QName;
/**
* Implementations of this class can contribute properties associated with an Endpoint. The properties appear as
* extensibility elements inside the EndpointReference of the endpoint. If any EPR extensibility elements are configured
* for an endpoint, the EndpointReference is published inside the WSDL.
*
* @since JAX-WS 2.2
* @author Rama Pulavarthi
*/
public abstract class EndpointReferenceExtensionContributor {
/**
*
* @param extension EPRExtension is passed if an extension with same QName is already configured on the endpoint
* via other means (one possible way is by embedding EndpointReference in WSDL).
*
* @return EPRExtension that should be finally configured on an Endpoint.
*/
public abstract WSEndpointReference.EPRExtension getEPRExtension(WSEndpoint endpoint, @Nullable WSEndpointReference.EPRExtension extension );
/**
*
* @return QName of the extensibility element that is contributed by this extension.
*/
public abstract QName getQName();
}

View File

@@ -0,0 +1,64 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.transport.http.HttpAdapter;
/**
* Light-weight http server transport for {@link WSEndpoint}.
* It provides a way to start the transport at a local http address and
* to stop the transport.
*
* @author Jitendra Kotamraju
*/
public abstract class HttpEndpoint {
/**
* Factory to deploy {@link WSEndpoint} on light-weight
* http server container.
*
* @param endpoint that needs to be deployed at http server
* @return transport object for the endpoint
*/
public static HttpEndpoint create(@NotNull WSEndpoint endpoint) {
return new com.sun.xml.internal.ws.transport.http.server.HttpEndpoint(null, HttpAdapter.createAlone(endpoint));
}
/**
* Publishes this endpoint at a localhost's http address.
*
* @param address endpoint's http address
* for e.g http://localhost:8080/ctxt/pattern
*/
public abstract void publish(@NotNull String address);
/**
* Stops the published endpoint
*/
public abstract void stop();
}

View File

@@ -0,0 +1,260 @@
/*
* 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.server;
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.resources.ServerMessages;
import com.sun.xml.internal.ws.resources.WsservletMessages;
import com.sun.xml.internal.ws.server.ServerRtException;
import com.sun.xml.internal.ws.server.SingletonResolver;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Determines the instance that serves
* the given request packet.
*
* <p>
* The JAX-WS spec always use a singleton instance
* to serve all the requests, but this hook provides
* a convenient way to route messages to a proper receiver.
*
* <p>
* Externally, an instance of {@link InstanceResolver} is
* associated with {@link WSEndpoint}.
*
* <h2>Possible Uses</h2>
* <p>
* One can use WS-Addressing message properties to
* decide which instance to deliver a message. This
* would be an important building block for a stateful
* web services.
*
* <p>
* One can associate an instance of a service
* with a specific WS-RM session.
*
* @author Kohsuke Kawaguchi
*/
public abstract class InstanceResolver<T> {
/**
* Decides which instance of 'T' serves the given request message.
*
* <p>
* This method is called concurrently by multiple threads.
* It is also on a criticail path that affects the performance.
* A good implementation should try to avoid any synchronization,
* and should minimize the amount of work as much as possible.
*
* @param request
* Always non-null. Represents the request message to be served.
* The caller may not consume the {@link Message}.
*/
public abstract @NotNull T resolve(@NotNull Packet request);
/**
* Called by the default {@link Invoker} after the method call is done.
* This gives {@link InstanceResolver} a chance to do clean up.
*
* <p>
* Alternatively, one could override {@link #createInvoker()} to
* create a custom invoker to do this in more flexible way.
*
* <p>
* The default implementation is a no-op.
*
* @param request
* The same request packet given to {@link #resolve(Packet)} method.
* @param servant
* The object returned from the {@link #resolve(Packet)} method.
* @since 2.1.2
*/
public void postInvoke(@NotNull Packet request, @NotNull T servant) {
}
/**
* Called by {@link WSEndpoint} when it's set up.
*
* <p>
* This is an opportunity for {@link InstanceResolver}
* to do a endpoint-specific initialization process.
*
* @param wsc
* The {@link WebServiceContext} instance to be injected
* to the user instances (assuming {@link InstanceResolver}
*/
public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint) {
// backward compatibility
start(wsc);
}
/**
* @deprecated
* Use {@link #start(WSWebServiceContext,WSEndpoint)}.
*/
public void start(@NotNull WebServiceContext wsc) {}
/**
* Called by {@link WSEndpoint}
* when {@link WSEndpoint#dispose()} is called.
*
* This allows {@link InstanceResolver} to do final clean up.
*
* <p>
* This method is guaranteed to be only called once by {@link WSEndpoint}.
*/
public void dispose() {}
/**
* Creates a {@link InstanceResolver} implementation that always
* returns the specified singleton instance.
*/
public static <T> InstanceResolver<T> createSingleton(T singleton) {
assert singleton!=null;
InstanceResolver ir = createFromInstanceResolverAnnotation(singleton.getClass());
if(ir==null)
ir = new SingletonResolver<T>(singleton);
return ir;
}
/**
* @deprecated
* This is added here because a Glassfish integration happened
* with this signature. Please do not use this. Will be removed
* after the next GF integration.
*/
public static <T> InstanceResolver<T> createDefault(@NotNull Class<T> clazz, boolean bool) {
return createDefault(clazz);
}
/**
* Creates a default {@link InstanceResolver} that serves the given class.
*/
public static <T> InstanceResolver<T> createDefault(@NotNull Class<T> clazz) {
InstanceResolver<T> ir = createFromInstanceResolverAnnotation(clazz);
if(ir==null)
ir = new SingletonResolver<T>(createNewInstance(clazz));
return ir;
}
/**
* Checks for {@link InstanceResolverAnnotation} and creates an instance resolver from it if any.
* Otherwise null.
*/
public static <T> InstanceResolver<T> createFromInstanceResolverAnnotation(@NotNull Class<T> clazz) {
for( Annotation a : clazz.getAnnotations() ) {
InstanceResolverAnnotation ira = a.annotationType().getAnnotation(InstanceResolverAnnotation.class);
if(ira==null) continue;
Class<? extends InstanceResolver> ir = ira.value();
try {
return ir.getConstructor(Class.class).newInstance(clazz);
} catch (InstantiationException e) {
throw new WebServiceException(ServerMessages.FAILED_TO_INSTANTIATE_INSTANCE_RESOLVER(
ir.getName(),a.annotationType(),clazz.getName()));
} catch (IllegalAccessException e) {
throw new WebServiceException(ServerMessages.FAILED_TO_INSTANTIATE_INSTANCE_RESOLVER(
ir.getName(),a.annotationType(),clazz.getName()));
} catch (InvocationTargetException e) {
throw new WebServiceException(ServerMessages.FAILED_TO_INSTANTIATE_INSTANCE_RESOLVER(
ir.getName(),a.annotationType(),clazz.getName()));
} catch (NoSuchMethodException e) {
throw new WebServiceException(ServerMessages.FAILED_TO_INSTANTIATE_INSTANCE_RESOLVER(
ir.getName(),a.annotationType(),clazz.getName()));
}
}
return null;
}
protected static <T> T createNewInstance(Class<T> cl) {
try {
return cl.newInstance();
} catch (InstantiationException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ServerRtException(
WsservletMessages.ERROR_IMPLEMENTOR_FACTORY_NEW_INSTANCE_FAILED(cl));
} catch (IllegalAccessException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ServerRtException(
WsservletMessages.ERROR_IMPLEMENTOR_FACTORY_NEW_INSTANCE_FAILED(cl));
}
}
/**
* Wraps this {@link InstanceResolver} into an {@link Invoker}.
*/
public @NotNull Invoker createInvoker() {
return new Invoker() {
@Override
public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint) {
InstanceResolver.this.start(wsc,endpoint);
}
@Override
public void dispose() {
InstanceResolver.this.dispose();
}
@Override
public Object invoke(Packet p, Method m, Object... args) throws InvocationTargetException, IllegalAccessException {
T t = resolve(p);
try {
return MethodUtil.invoke(t, m, args );
} finally {
postInvoke(p,t);
}
}
@Override
public <U> U invokeProvider(@NotNull Packet p, U arg) {
T t = resolve(p);
try {
return ((Provider<U>) t).invoke(arg);
} finally {
postInvoke(p,t);
}
}
public String toString() {
return "Default Invoker over "+InstanceResolver.this.toString();
}
};
}
private static final Logger logger =
Logger.getLogger(
com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server");
}

View File

@@ -0,0 +1,59 @@
/*
* 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.server;
import java.lang.annotation.Documented;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
/**
* Meta annotation for selecting instance resolver.
*
* <p>
* When service class is annotated with an annotation that has
* {@link InstanceResolverAnnotation} as meta annotation, the JAX-WS RI
* runtime will use the instance resolver class specified on {@link #value()}.
*
* <p>
* The {@link InstanceResolver} class must have the public constructor that
* takes {@link Class}, which represents the type of the service.
*
* <p>
* See {@link com.sun.xml.internal.ws.developer.Stateful} for a real example. This annotation is only for
* advanced users of the JAX-WS RI.
*
* @since JAX-WS 2.1
* @see com.sun.xml.internal.ws.developer.Stateful
* @author Kohsuke Kawaguchi
*/
@Target(ANNOTATION_TYPE)
@Retention(RUNTIME)
@Documented
public @interface InstanceResolverAnnotation {
Class<? extends InstanceResolver> value();
}

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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.message.Packet;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceContext;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Hides the detail of calling into application endpoint implementation.
*
* <p>
* Typical host of the JAX-WS RI would want to use
* {@link InstanceResolver#createDefault(Class)} and then
* use <tt>{@link InstanceResolver#createInvoker()} to obtain
* the default invoker implementation.
*
*
* @author Jitendra Kotamraju
* @author Kohsuke Kawaguchi
*/
public abstract class Invoker extends com.sun.xml.internal.ws.server.sei.Invoker {
/**
* Called by {@link WSEndpoint} when it's set up.
*
* <p>
* This is an opportunity for {@link Invoker}
* to do a endpoint-specific initialization process.
*
* @param wsc
* The {@link WebServiceContext} instance that can be injected
* to the user instances.
* @param endpoint
*/
public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint) {
// backward compatibility
start(wsc);
}
/**
* @deprecated
* Use {@link #start(WSWebServiceContext,WSEndpoint)}
*/
public void start(@NotNull WebServiceContext wsc) {
throw new IllegalStateException("deprecated version called");
}
/**
* Called by {@link WSEndpoint}
* when {@link WSEndpoint#dispose()} is called.
*
* This allows {@link InstanceResolver} to do final clean up.
*
* <p>
* This method is guaranteed to be only called once by {@link WSEndpoint}.
*/
public void dispose() {}
/**
* Invokes {@link Provider#invoke(Object)}
*/
public <T> T invokeProvider( @NotNull Packet p, T arg ) throws IllegalAccessException, InvocationTargetException {
// default slow implementation that delegates to the other invoke method.
return (T)invoke(p,invokeMethod,arg);
}
/**
* Invokes {@link AsyncProvider#invoke(Object, AsyncProviderCallback, WebServiceContext)}
*/
public <T> void invokeAsyncProvider( @NotNull Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt ) throws IllegalAccessException, InvocationTargetException {
// default slow implementation that delegates to the other invoke method.
invoke(p, asyncInvokeMethod, arg, cbak, ctxt);
}
private static final Method invokeMethod;
static {
try {
invokeMethod = Provider.class.getMethod("invoke",Object.class);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
private static final Method asyncInvokeMethod;
static {
try {
asyncInvokeMethod = AsyncProvider.class.getMethod("invoke",Object.class, AsyncProviderCallback.class, WebServiceContext.class);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
}

View File

@@ -0,0 +1,224 @@
/*
* Copyright (c) 2011, 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.server;
import com.sun.xml.internal.ws.server.WSEndpointImpl;
import java.util.HashSet;
import java.util.Set;
import com.sun.org.glassfish.external.amx.AMXGlassfish;
import com.sun.org.glassfish.external.amx.MBeanListener;
import com.sun.org.glassfish.gmbal.ManagedObjectManager;
/**
* The lazy provider is intended to defer Gmbal API calls until there is a JMX connection. The provider is scope
* (environment) aware and behaves accordingly to actual scope. The default behaviour does not defers Gmbal API calls.
*
* There are two kind of method allowing registration of an object as a listener. One is for {@code WSEndpointImpl}
* instances (implementing {@code WSEndpointScopeChangeListener}) and the other is for arbitrary objects
* (implementing {@code DefaultScopeChangeListener}) that want to be notified about scope changes. The distinction is made
* because of the fact that endpoints should be registered first and other objects (e.g. dependants on endpoints) must
* be registered after all the endpoints are processed so no inconsistency is present.
*
* Glassfish:
* {@link WebServicesContainer} is one of two classes for which a {@link ManagedObjectManager} instance (see Gmbal API)
* is created when a webservice application is deployed into the Glassfish. For the purpose of postponing Gmbal API calls
* the {@code WebServicesContainer} extends {@link MBeanListener.CallbackImpl} so it can register itself as a listener of
* {@link AMXGlassfish} and receive a notification about a connection of a JMX client to the Glassfish server (see
* {@code WebServicesContainer#postConstruct} for registration details). The moment the JMX client is connected a notification
* is sent to the listeners of {@code AMXGlassfish}. When this event is received by {@code WebServiceContainer} (see the
* callback method {@code mbeanRegistered}) a {@code ManagedObjectManager} instance is created and no further deferring
* of Gmbal API calls is needed.
*
* Metro/JAX-WS:
* The situation in Metro/JAX-WS is slightly different from the one described above. Metro/JAX-WS can be used as standalone
* libraries (outside of Glassfish) so no notification from the Glassfish server can be expected in this case. This leads
* to a situation when Metro/JAX-WS has to be aware of context in which it is used and acts appropriately. There are 3
* scopes an application using Metro/JAX-WS can be in: {@code STANDALONE}, {@code GLASSFISH_NO_JMX}, {@code GLASSFISH_JMX}
* ({@link LazyMOMProvider#scope}). The default scope is {@code STANDALONE} and all Gmbal API calls are invoked as they
* are requested. The other two scopes are applied only when an application is deployed into a Glassfish server. The
* {@code GLASSFISH_NO_JMX} is set at the moment the application is deployed (see below) and its purpose is to defer Gmbal
* API calls for as long as possible. For some classes e.g. {@code ManagedObjectManager} proxy classes were introduced to
* avoid the necessity of creating the real Gmbal objects but if a method is invoked on these proxies the creation of real
* Gmbal objects is forced even in this scope. The {@code GLASSFISH_JMX} scope is set when a JMX client is connected to
* the Glassfish server and it processes Gmbal API calls without deferring (as if the application was in the
* {@code STANDALONE} scope). The entry point for postponing the Gmbal API calls / creating Gmbal objects in Metro/JAX-WS
* is {@link LazyMOMProvider}. This class is capable of receiving notifications from the Glassfish server
* ({@code LazyMOMProvider.initMOMForScope}) about the scope change and it also spread this information to its listeners.
* The listeners of {@code LazyMOMProvider} are of two kinds: {@link LazyMOMProvider.WSEndpointScopeChangeListener} and
* {@link LazyMOMProvider.DefaultScopeChangeListener}. Extensions of {@link WSEndpoint} (e.g. {@link WSEndpointImpl})
* should implement the {@code LazyMOMProvider.WSEndpointScopeChangeListener} and register themselves as endpoint listeners
* of {@code LazyMOMProvider}. Other classes should implement the latter mentioned interface and register themselves as
* a non-endpoint listener. The differences between these two kind of listeners are described in {@code LazyMOMProvider}
* class comment. An implementation of {@code LazyMOMProvider.DefaultScopeChangeListener} is provided in Metro
* ({@link WSEndpointCollectionBasedMOMListener}). As mentioned above this listener register itself as a non-endpoint
* listener of {@code LazyMOMProvider} ({@code WSEndpointCollectionBasedMOMListener.init}). An instance of this class is
* used in these factories: {@link SessionManager}, {@link NonceManager} and {@link SequenceManagerFactory}.
* {@code SessionManager}, {@code NonceManager}, {@code PersistentSequenceManager} and {@code InVmSequenceManager} also
* (indirectly) implement {@link MOMRegistrationAware} for providing information whether a manager is registered at
* {@code ManagedObjectManager} or not. Registration of a manager at {@code ManagedObjectManager} can be processed directly
* (if {@code WSEndpointCollectionBasedMOMListener.canRegisterAtMOM} returns {@code true}) via
* {@code WSEndpointCollectionBasedMOMListener.registerAtMOM} or is deferred by putting the manager into
* {@code WSEndpointCollectionBasedMOMListener.registrationAwareMap}. Managers stored in for deferred registration are
* processed at the moment the {@code LazyMOMProvider} notifies the {@code WSEndpointCollectionBasedMOMListener} about
* the scope change.
* The mentioned postponing of Gmbal API calls applies only to the server side of the webservice application.
*/
public enum LazyMOMProvider {
INSTANCE;
/**
* Possible scopes (environments) in which the provider (and object associated with it) could be in.
* Default scope is STANDALONE - applied during initialization of classes. For now, only possible scope change for a
* object can be in this direction: STANDALONE -> GLASSFISH_NO_JMX -> GLASSFISH_JMX.
*/
public static enum Scope {
//** Default scope where lazy flag is not applied and all Gmbal API calls are processed immediately. */
STANDALONE,
/** In this scope almost all Gmbal API call are deferred until a JMX connection to a Glassfish server is created */
GLASSFISH_NO_JMX,
/** Same as STANDALONE. Gmbal API calls are processed immediately. */
GLASSFISH_JMX
}
/**
* Interface for all object that want to be notified about scope change, introducing required methods.
*/
public static interface ScopeChangeListener {
void scopeChanged(Scope scope);
}
/**
* Default interface for all object that want to be notified about scope change. This interface should not be
* implemented directly.
*/
public static interface DefaultScopeChangeListener extends ScopeChangeListener {
}
/**
* Interface used for distinguishing between a registration of a WSEndpointImpl rather than of other classes.
* Webservice Endpoints should get a notification about scope change sooner than the rest of the registered listeners
* (there is a possibility that other listeners are dependant on Webservice Endpoints).
*/
public static interface WSEndpointScopeChangeListener extends ScopeChangeListener {
}
private final Set<WSEndpointScopeChangeListener> endpointsWaitingForMOM = new HashSet<WSEndpointScopeChangeListener>();
private final Set<DefaultScopeChangeListener> listeners = new HashSet<DefaultScopeChangeListener>();
private volatile Scope scope = Scope.STANDALONE;
/**
* Initializes this provider with a given scope. If the given scope is different than the one this provider is
* currently in and the transition between scopes is valid then a event is fired to all registered listeners.
*
* @param scope a scope to initialize this provider with
*/
public void initMOMForScope(LazyMOMProvider.Scope scope) {
// cannot go backwards between scopes, for possible scope changes see #Scope
if ((this.scope == Scope.GLASSFISH_JMX)
|| (scope == Scope.STANDALONE && (this.scope == Scope.GLASSFISH_JMX || this.scope == Scope.GLASSFISH_NO_JMX))
|| this.scope == scope) {
return;
}
this.scope = scope;
fireScopeChanged();
}
/**
* Notifies the registered listeners about the scope change.
*/
private void fireScopeChanged() {
for (ScopeChangeListener wsEndpoint : endpointsWaitingForMOM) {
wsEndpoint.scopeChanged(this.scope);
}
for (ScopeChangeListener listener : listeners) {
listener.scopeChanged(this.scope);
}
}
/**
* Registers the given object as a listener.
*
* @param listener a listener to be registered
*/
public void registerListener(DefaultScopeChangeListener listener) {
listeners.add(listener);
if (!isProviderInDefaultScope()) {
listener.scopeChanged(this.scope);
}
}
/**
* Returns {@code true} if this provider is in the default scope.
*
* @return {@code true} if this provider is in the default scope,
* {@code false} otherwise
*/
private boolean isProviderInDefaultScope() {
return this.scope == Scope.STANDALONE;
}
public Scope getScope() {
return scope;
}
/**
* Registers a Webservice Endpoint as a listener.
* Webservice Endpoints should rather register through this method than through LazyMOMProvider#registerListener
* because generally they need to be notified sooner than arbitrary listener (i.e. object that is dependant on
* Webservice Endpoint)
*
* @param wsEndpoint a Webservice Endpoint to be registered
*/
public void registerEndpoint(WSEndpointScopeChangeListener wsEndpoint) {
endpointsWaitingForMOM.add(wsEndpoint);
if (!isProviderInDefaultScope()) {
wsEndpoint.scopeChanged(this.scope);
}
}
/**
* Unregisters a Webservice Endpoint from the list of listeners.
*
* @param wsEndpoint a Webservice Endpoint to be unregistered
*/
public void unregisterEndpoint(WSEndpointScopeChangeListener wsEndpoint) {
endpointsWaitingForMOM.remove(wsEndpoint);
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (c) 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.server;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
* to java.lang,reflect.Method.invoke()
*
* Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
*/
class MethodUtil {
private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
private static final Method INVOKE_METHOD;
static {
Method method;
try {
Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
}
} catch (Throwable t) {
method = null;
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
}
}
INVOKE_METHOD = method;
}
static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
if (INVOKE_METHOD != null) {
// sun.reflect.misc.MethodUtil.invoke(method, owner, args)
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
}
try {
return INVOKE_METHOD.invoke(null, method, target, args);
} catch (InvocationTargetException ite) {
// unwrap invocation exception added by reflection code ...
throw unwrapException(ite);
}
} else {
// other then Oracle JDK ...
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
}
return method.invoke(target, args);
}
}
private static InvocationTargetException unwrapException(InvocationTargetException ite) {
Throwable targetException = ite.getTargetException();
if (targetException != null && targetException instanceof InvocationTargetException) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
}
return (InvocationTargetException) targetException;
} else {
return ite;
}
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.Component;
import com.sun.xml.internal.ws.transport.http.HttpAdapterList;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
import java.util.List;
/**
* Represents an object scoped to the current "module" (like a JavaEE web appliation).
*
* <p>
* This object can be obtained from {@link Container#getSPI(Class)}.
*
* <p>
* The scope of the module is driven by {@link W3CEndpointReferenceBuilder#build()}'s
* requirement that we need to identify a {@link WSEndpoint} that has a specific
* service/port name.
*
* <p>
* For JavaEE containers this should be scoped to a JavaEE application. For
* other environment, this could be scoped to any similar notion. If no such
* notion is available, the implementation of {@link Container} can return
* a new {@link Module} object each time {@link Container#getSPI(Class)} is invoked.
*
* <p>
* There's a considerable overlap between this and {@link HttpAdapterList}.
* The SPI really needs to be reconsidered
*
*
* @see Container
* @author Kohsuke Kawaguchi
* @since 2.1 EA3
*/
public abstract class Module implements Component {
/**
* Gets the list of {@link BoundEndpoint} deployed in this module.
*
* <p>
* From the point of view of the {@link Module} implementation,
* it really only needs to provide a {@link List} object as a data store.
* JAX-WS will update this list accordingly.
*
* @return
* always return the same non-null instance.
*/
public abstract @NotNull List<BoundEndpoint> getBoundEndpoints();
public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
return null;
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import javax.xml.namespace.QName;
/**
* Resolves port address for an endpoint. A WSDL may contain multiple
* endpoints, and some of the endpoints may be packaged in a single WAR file.
* If an endpoint is serving the WSDL, it would be nice to fill the port addresses
* of other endpoints in the WAR.
*
* <p>
* This interface is implemented by the caller of
* {@link SDDocument#writeTo} method so
* that the {@link SDDocument} can correctly fills the addresses of known
* endpoints.
*
*
* @author Jitendra Kotamraju
*/
public abstract class PortAddressResolver {
/**
* Gets the endpoint address for a WSDL port
*
* @param serviceName
* WSDL service name(wsd:service in WSDL) for which address is needed. Always non-null.
* @param portName
* WSDL port name(wsdl:port in WSDL) for which address is needed. Always non-null.
* @return
* The address needs to be put in WSDL for port element's location
* attribute. Can be null. If it is null, existing port address
* is written as it is (without any patching).
*/
public abstract @Nullable String getAddressFor(@NotNull QName serviceName, @NotNull String portName);
/**
* Gets the endpoint address for a WSDL port
*
* @param serviceName
* WSDL service name(wsd:service in WSDL) for which address is needed. Always non-null.
* @param portName
* WSDL port name(wsdl:port in WSDL) for which address is needed. Always non-null.
* @param currentAddress
* Whatever current address specified for the port in the WSDL
* @return
* The address needs to be put in WSDL for port element's location
* attribute. Can be null. If it is null, existing port address
* is written as it is (without any patching).
*/
public @Nullable String getAddressFor(@NotNull QName serviceName, @NotNull String portName, String currentAddress) {
return getAddressFor(serviceName, portName);
}
}

View File

@@ -0,0 +1,110 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.server.provider.AsyncProviderInvokerTube;
import com.sun.xml.internal.ws.server.provider.ProviderArgumentsBuilder;
import com.sun.xml.internal.ws.server.provider.ProviderInvokerTube;
import com.sun.xml.internal.ws.server.provider.SyncProviderInvokerTube;
import com.sun.xml.internal.ws.util.ServiceFinder;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Factory for Provider invoker tubes that know how to handle specific
* types of Providers (i.e., javax.xml.ws.Provider).
*
*/
public abstract class ProviderInvokerTubeFactory<T> {
/**
*
*/
protected abstract ProviderInvokerTube<T> doCreate(@NotNull final Class<T> implType,
@NotNull final Invoker invoker,
@NotNull final ProviderArgumentsBuilder<?> argsBuilder,
final boolean isAsync);
private static final ProviderInvokerTubeFactory DEFAULT = new DefaultProviderInvokerTubeFactory();
private static class DefaultProviderInvokerTubeFactory<T> extends ProviderInvokerTubeFactory<T> {
@Override
public ProviderInvokerTube<T> doCreate(@NotNull final Class<T> implType,
@NotNull final Invoker invoker,
@NotNull final ProviderArgumentsBuilder<?> argsBuilder,
final boolean isAsync)
{
return createDefault(implType, invoker, argsBuilder, isAsync);
}
}
/**
* @param classLoader
* @param container
* @param implType
* @param invoker
* @param argsBuilder
* @param isAsync
*
* @return
*/
public static <T> ProviderInvokerTube<T> create(@Nullable final ClassLoader classLoader,
@NotNull final Container container,
@NotNull final Class<T> implType,
@NotNull final Invoker invoker,
@NotNull final ProviderArgumentsBuilder<?> argsBuilder,
final boolean isAsync)
{
for (ProviderInvokerTubeFactory factory : ServiceFinder.find(ProviderInvokerTubeFactory.class,
classLoader, container))
{
ProviderInvokerTube<T> tube = factory.doCreate(implType, invoker, argsBuilder, isAsync);
if (tube != null) {
if (logger.isLoggable(Level.FINE)) {
ProviderInvokerTubeFactory.logger.log(Level.FINE, "{0} successfully created {1}", new Object[]{factory.getClass(), tube});
}
return tube;
}
}
return DEFAULT.createDefault(implType, invoker, argsBuilder, isAsync);
}
protected ProviderInvokerTube<T> createDefault(@NotNull final Class<T> implType,
@NotNull final Invoker invoker,
@NotNull final ProviderArgumentsBuilder<?> argsBuilder,
final boolean isAsync)
{
return
isAsync
? new AsyncProviderInvokerTube(invoker, argsBuilder)
: new SyncProviderInvokerTube (invoker, argsBuilder);
}
private static final Logger logger = Logger.getLogger(ProviderInvokerTubeFactory.class.getName());
}

View File

@@ -0,0 +1,73 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.server.DefaultResourceInjector;
import javax.annotation.PostConstruct;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
/**
* Represents a functionality of the container to inject resources
* to application service endpoint object (usually but not necessarily as per JavaEE spec.)
*
* <p>
* If {@link Container#getSPI(Class)} returns a valid instance of {@link ResourceInjector},
* The JAX-WS RI will call the {@link #inject} method for each service endpoint
* instance that it manages.
*
* <p>
* The JAX-WS RI will be responsible for calling {@link PostConstruct} callback,
* so implementations of this class need not do so.
*
* @author Kohsuke Kawaguchi
* @see Container
*/
public abstract class ResourceInjector {
/**
* Performs resource injection.
*
* @param context
* {@link WebServiceContext} implementation to be injected into the instance.
* @param instance
* Instance of the service endpoint class to which resources will be injected.
*
* @throws WebServiceException
* If the resource injection fails.
*/
public abstract void inject(@NotNull WSWebServiceContext context, @NotNull Object instance);
/**
* Fallback {@link ResourceInjector} implementation used when the {@link Container}
* doesn't provide one.
*
* <p>
* Just inject {@link WSWebServiceContext} and done.
*/
public static final ResourceInjector STANDALONE = new DefaultResourceInjector();
}

View File

@@ -0,0 +1,180 @@
/*
* 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.server;
import com.sun.istack.internal.Nullable;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.namespace.QName;
import java.io.OutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Set;
import com.sun.org.glassfish.gmbal.ManagedAttribute;
import com.sun.org.glassfish.gmbal.ManagedData;
/**
* Represents an individual document that forms a {@link ServiceDefinition}.
*
* <pre>
* TODO:
* how does those documents refer to each other?
*
* </pre>
*
* @author Jitendra Kotamraju
*/
@ManagedData
public interface SDDocument {
/**
* Gets the root tag name of this document.
*
* <p>
* This can be used to identify a kind of document quickly
* (such as schema, WSDL, ...)
*
* @return
* always non-null.
*/
@ManagedAttribute
QName getRootName();
/**
* Returns true if this document is WSDL.
*/
@ManagedAttribute
boolean isWSDL();
/**
* Returns true if this document is schema.
*/
@ManagedAttribute
boolean isSchema();
/**
* returns the referenced documents
*/
@ManagedAttribute
Set<String> getImports();
/**
* Gets the system ID of the document where it's taken from. Generated documents
* use a fake URL that can be used to resolve relative URLs. So donot use this URL
* for reading or writing.
*/
@ManagedAttribute
URL getURL();
/**
* Writes the document to the given {@link OutputStream}.
*
* <p>
* Since {@link ServiceDefinition} doesn't know which endpoint address
* {@link Adapter} is serving to, (and often it serves multiple URLs
* simultaneously), this method takes the PortAddressResolver as a parameter,
* so that it can produce the corret address information in the generated WSDL.
*
* @param portAddressResolver
* An endpoint address resolver that gives endpoint address for a WSDL
* port. Can be null.
* @param resolver
* Used to resolve relative references among documents.
* @param os
* The {@link OutputStream} that receives the generated document.
*
* @throws IOException
* if there was a failure reported from the {@link OutputStream}.
*/
void writeTo(@Nullable PortAddressResolver portAddressResolver,
DocumentAddressResolver resolver, OutputStream os) throws IOException;
/**
* Writes the document to the given {@link XMLStreamWriter}.
*
* <p>
* The same as {@link #writeTo(PortAddressResolver,DocumentAddressResolver,OutputStream)} except
* it writes to an {@link XMLStreamWriter}.
*
* <p>
* The implementation must not call {@link XMLStreamWriter#writeStartDocument()}
* nor {@link XMLStreamWriter#writeEndDocument()}. Those are the caller's
* responsibility.
*
* @throws XMLStreamException
* if the {@link XMLStreamWriter} reports an error.
*/
void writeTo(PortAddressResolver portAddressResolver,
DocumentAddressResolver resolver, XMLStreamWriter out) throws XMLStreamException, IOException;
/**
* {@link SDDocument} that represents an XML Schema.
*/
interface Schema extends SDDocument {
/**
* Gets the target namepsace of this schema.
*/
@ManagedAttribute
String getTargetNamespace();
}
/**
* {@link SDDocument} that represents a WSDL.
*/
interface WSDL extends SDDocument {
/**
* Gets the target namepsace of this schema.
*/
@ManagedAttribute
String getTargetNamespace();
/**
* This WSDL has a portType definition
* that matches what {@link WSEndpoint} is serving.
*
* TODO: does this info needs to be exposed?
*/
@ManagedAttribute
boolean hasPortType();
/**
* This WSDL has a service definition
* that matches the {@link WSEndpoint}.
*
* TODO: does this info need to be exposed?
*/
@ManagedAttribute
boolean hasService();
/**
* All &lt;service> names that were in this WSDL, or empty set if there was none.
* Used for error diagnostics.
*/
@ManagedAttribute
Set<QName> getAllServices();
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.server;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
/**
* Provides a way to filter {@link SDDocument} infoset while writing it. These
* filter objects can be added to {@link ServiceDefinition} using
* {@link ServiceDefinition#addFilter(SDDocumentFilter)}
*
* @author Kohsuke Kawaguchi
* @author Jitendra Kotamraju
*/
public interface SDDocumentFilter {
/**
* Returns a wrapped XMLStreamWriter on top of passed-in XMLStreamWriter.
* It works like any filtering API for e.g. {@link java.io.FilterOutputStream}.
* The method returns a XMLStreamWriter that calls the same methods on original
* XMLStreamWriter with some modified events. The end result is some infoset
* is filtered before it reaches the original writer and the infoset writer
* doesn't have to change any code to incorporate this filter.
*
* @param doc gives context for the filter. This should only be used to query
* read-only information. Calling doc.writeTo() may result in infinite loop.
* @param w Original XMLStreamWriter
* @return Filtering {@link XMLStreamWriter}
*/
XMLStreamWriter filter(SDDocument doc, XMLStreamWriter w) throws XMLStreamException, IOException;
}

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.server;
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
import com.sun.xml.internal.ws.streaming.TidyXMLStreamReader;
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
/**
* SPI that provides the source of {@link SDDocument}.
*
* <p>
* This abstract class could be implemented by appliations, or one of the
* {@link #create} methods can be used.
*
* @author Kohsuke Kawaguchi
*/
public abstract class SDDocumentSource {
/**
* Returns the {@link XMLStreamReader} that reads the document.
*
* <p>
* This method maybe invoked multiple times concurrently.
*
* @param xif
* The implementation may choose to use this object when it wants to
* create a new parser (or it can just ignore this parameter completely.)
* @return
* The caller is responsible for closing the reader to avoid resource leak.
*
* @throws XMLStreamException
* if something goes wrong while creating a parser.
* @throws IOException
* if something goes wrong trying to read the document.
*/
public abstract XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException;
/**
* Returns the {@link XMLStreamReader} that reads the document.
*
* <p>
* This method maybe invoked multiple times concurrently.
*
* @return
* The caller is responsible for closing the reader to avoid resource leak.
*
* @throws XMLStreamException
* if something goes wrong while creating a parser.
* @throws IOException
* if something goes wrong trying to read the document.
*/
public abstract XMLStreamReader read() throws IOException, XMLStreamException;
/**
* System ID of this document.
*/
public abstract URL getSystemId();
/**
* Creates {@link SDDocumentSource} from an URL.
*/
public static SDDocumentSource create(final URL url) {
return new SDDocumentSource() {
private final URL systemId = url;
public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException {
InputStream is = url.openStream();
return new TidyXMLStreamReader(
xif.createXMLStreamReader(systemId.toExternalForm(),is), is);
}
public XMLStreamReader read() throws IOException, XMLStreamException {
InputStream is = url.openStream();
return new TidyXMLStreamReader(
XMLStreamReaderFactory.create(systemId.toExternalForm(),is,false), is);
}
public URL getSystemId() {
return systemId;
}
};
}
/**
* Creates a {@link SDDocumentSource} from {@link XMLStreamBuffer}.
*/
public static SDDocumentSource create(final URL systemId, final XMLStreamBuffer xsb) {
return new SDDocumentSource() {
public XMLStreamReader read(XMLInputFactory xif) throws XMLStreamException {
return xsb.readAsXMLStreamReader();
}
public XMLStreamReader read() throws XMLStreamException {
return xsb.readAsXMLStreamReader();
}
public URL getSystemId() {
return systemId;
}
};
}
}

View File

@@ -0,0 +1,99 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.pipe.Pipe;
import com.sun.xml.internal.ws.api.pipe.ServerPipeAssemblerContext;
import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterPipeImpl;
/**
* Allow the container (primarily Glassfish) to inject
* their own pipes into the pipeline.
*
* <p>
* This interface has a rather ad-hoc set of methods, because
* we didn't want to define an autonomous pipe-assembly process.
* (We thought this is a smaller evil compared to that.)
*
* <p>
* JAX-WS obtains this through {@link Container#getSPI(Class)}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class ServerPipelineHook {
/**
* Called during the pipeline construction process once to allow a container
* to register a pipe for monitoring.
*
* This pipe will be injected to a point very close to the transport, allowing
* it to measure the time it takes for processing as well as detecting errors.
*
* @param ctxt
* Represents abstraction of SEI, WSDL abstraction etc. Context can be used
* whether add a new pipe to the head or not.
*
* @param tail
* Head of the partially constructed pipeline. If the implementation
* wishes to add new pipes, it should do so by extending
* {@link AbstractFilterPipeImpl} and making sure that this {@link Pipe}
* eventually processes messages.
*
* @return
* The default implementation just returns <tt>tail</tt>, which means
* no additional pipe is inserted. If the implementation adds
* new pipes, return the new head pipe.
*/
public @NotNull Pipe createMonitoringPipe(ServerPipeAssemblerContext ctxt, @NotNull Pipe tail) {
return tail;
}
/**
* Called during the pipeline construction process once to allow a container
* to register a pipe for security.
*
* This pipe will be injected to a point very close to the transport, allowing
* it to do some security operations.
*
* @param ctxt
* Represents abstraction of SEI, WSDL abstraction etc. Context can be used
* whether add a new pipe to the head or not.
*
* @param tail
* Head of the partially constructed pipeline. If the implementation
* wishes to add new pipes, it should do so by extending
* {@link AbstractFilterPipeImpl} and making sure that this {@link Pipe}
* eventually processes messages.
*
* @return
* The default implementation just returns <tt>tail</tt>, which means
* no additional pipe is inserted. If the implementation adds
* new pipes, return the new head pipe.
*/
public @NotNull Pipe createSecurityPipe(ServerPipeAssemblerContext ctxt, @NotNull Pipe tail) {
return tail;
}
}

View File

@@ -0,0 +1,79 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLModel;
/**
* Root of the unparsed WSDL and other resources referenced from it.
* This object represents the description of the service
* that a {@link WSEndpoint} offers.
*
* <p>
* A description consists of a set of {@link SDDocument}, which
* each represents a single XML document that forms a part of the
* descriptor (for example, WSDL might refer to separate schema documents,
* or a WSDL might refer to another WSDL.)
*
* <p>
* {@link ServiceDefinition} and its descendants are immutable
* read-only objects. Once they are created, they always return
* the same value.
*
* <h2>Expected Usage</h2>
* <p>
* This object is intended to be used for serving the descriptors
* to remote clients (such as by MEX, or other protocol-specific
* metadata query, such as HTTP GET with "?wsdl" query string.)
*
* <p>
* This object is <b>NOT</b> intended to be used by other
* internal components to parse them. For that purpose, use
* {@link WSDLModel} instead.
*
* @author Kohsuke Kawaguchi
*/
public interface ServiceDefinition extends Iterable<SDDocument> {
/**
* Gets the "primary" {@link SDDocument} that represents a WSDL.
*
* <p>
* This WSDL eventually refers to all the other {@link SDDocument}s.
*
* @return
* always non-null.
*/
@NotNull SDDocument getPrimary();
/**
* Adds a filter that is called while writing {@link SDDocument}'s infoset. This
* filter is applied to the all the other reachable {@link SDDocument}s.
*
* @param filter that is called while writing the document
*/
void addFilter(@NotNull SDDocumentFilter filter);
}

View File

@@ -0,0 +1,106 @@
/*
* 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.server;
import java.util.concurrent.Executor;
/**
* ContainerResolver based on {@link ThreadLocal}.
* <p>
* The ThreadLocalContainerResolver is the default implementation available
* from the ContainerResolver using {@link ContainerResolver#getDefault()}. Code
* sections that run with a Container must use the following pattern:
* <pre>
* public void m() {
* Container old = ContainerResolver.getDefault().enterContainer(myContainer);
* try {
* // ... method body
* } finally {
* ContainerResolver.getDefault().exitContainer(old);
* }
* }
* </pre>
* @since 2.2.7
*/
public class ThreadLocalContainerResolver extends ContainerResolver {
private ThreadLocal<Container> containerThreadLocal = new ThreadLocal<Container>() {
@Override
protected Container initialValue() {
return Container.NONE;
}
};
public Container getContainer() {
return containerThreadLocal.get();
}
/**
* Enters container
* @param container Container to set
* @return Previous container; must be remembered and passed to exitContainer
*/
public Container enterContainer(Container container) {
Container old = containerThreadLocal.get();
containerThreadLocal.set(container);
return old;
}
/**
* Exits container
* @param old Container returned from enterContainer
*/
public void exitContainer(Container old) {
containerThreadLocal.set(old);
}
/**
* Used by {@link com.sun.xml.internal.ws.api.pipe.Engine} to wrap asynchronous {@link com.sun.xml.internal.ws.api.pipe.Fiber} executions
* @param container Container
* @param ex Executor to wrap
* @return an Executor that will set the container during executions of Runnables
*/
public Executor wrapExecutor(final Container container, final Executor ex) {
if (ex == null)
return null;
return new Executor() {
@Override
public void execute(final Runnable command) {
ex.execute(new Runnable() {
@Override
public void run() {
Container old = enterContainer(container);
try {
command.run();
} finally {
exitContainer(old);
}
}
});
}
};
}
}

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.server;
import com.sun.xml.internal.ws.api.message.Packet;
import com.sun.xml.internal.ws.api.server.WSEndpoint.PipeHead;
/**
* Represents a transport back-channel.
*
* <p>
* When the JAX-WS runtime finds out that the request
* {@link Packet} being processed is known not to produce
* a response, it invokes the {@link #close()} method
* to indicate that the transport does not need to keep
* the channel for the response message open.
*
* <p>
* This allows the transport to close down the communication
* channel sooner than wainting for
* {@link PipeHead#process}
* method to return, thereby improving the overall throughput
* of the system.
*
* @author Kohsuke Kawaguchi
* @author Jitu
*/
public interface TransportBackChannel {
/**
* See the class javadoc for the discussion.
*
* <p>
* JAX-WS is not guaranteed to call this method for all
* operations that do not have a response. This is merely
* a hint.
*
* <p>
* When the implementation of this method fails to close
* the connection successfuly, it should record the error,
* and return normally. Do not throw any exception.
*/
void close();
}

View File

@@ -0,0 +1,714 @@
/*
* 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.server;
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.Component;
import com.sun.xml.internal.ws.api.ComponentRegistry;
import com.sun.xml.internal.ws.api.SOAPVersion;
import com.sun.xml.internal.ws.api.WSBinding;
import com.sun.xml.internal.ws.api.config.management.EndpointCreationAttributes;
import com.sun.xml.internal.ws.api.config.management.ManagedEndpointFactory;
import com.sun.xml.internal.ws.api.databinding.MetadataReader;
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.api.model.wsdl.WSDLPort;
import com.sun.xml.internal.ws.api.pipe.Codec;
import com.sun.xml.internal.ws.api.pipe.Engine;
import com.sun.xml.internal.ws.api.pipe.FiberContextSwitchInterceptor;
import com.sun.xml.internal.ws.api.pipe.ServerTubeAssemblerContext;
import com.sun.xml.internal.ws.api.pipe.ThrowableContainerPropertySet;
import com.sun.xml.internal.ws.api.pipe.Tube;
import com.sun.xml.internal.ws.policy.PolicyMap;
import com.sun.xml.internal.ws.server.EndpointAwareTube;
import com.sun.xml.internal.ws.server.EndpointFactory;
import com.sun.xml.internal.ws.util.ServiceFinder;
import com.sun.xml.internal.ws.util.xml.XmlUtil;
import com.sun.xml.internal.ws.wsdl.OperationDispatcher;
import com.sun.org.glassfish.gmbal.ManagedObjectManager;
import org.xml.sax.EntityResolver;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
import javax.xml.ws.Binding;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
/**
* Root object that hosts the {@link Packet} processing code
* at the server.
*
* <p>
* One instance of {@link WSEndpoint} is created for each deployed service
* endpoint. A hosted service usually handles multiple concurrent
* requests. To do this efficiently, an endpoint handles incoming
* {@link Packet} through {@link PipeHead}s, where many copies can be created
* for each endpoint.
*
* <p>
* Each {@link PipeHead} is thread-unsafe, and request needs to be
* serialized. A {@link PipeHead} represents a sizable resource
* (in particular a whole pipeline), so the caller is expected to
* reuse them and avoid excessive allocations as much as possible.
* Making {@link PipeHead}s thread-unsafe allow the JAX-WS RI internal to
* tie thread-local resources to {@link PipeHead}, and reduce the total
* resource management overhead.
*
* <p>
* To abbreviate this resource management (and for a few other reasons),
* JAX-WS RI provides {@link Adapter} class. If you are hosting a JAX-WS
* service, you'll most likely want to send requests to {@link WSEndpoint}
* through {@link Adapter}.
*
* <p>
* {@link WSEndpoint} is ready to handle {@link Packet}s as soon as
* it's created. No separate post-initialization step is necessary.
* However, to comply with the JAX-WS spec requirement, the caller
* is expected to call the {@link #dispose()} method to allow an
* orderly shut-down of a hosted service.
*
*
*
* <h3>Objects Exposed From Endpoint</h3>
* <p>
* {@link WSEndpoint} exposes a series of information that represents
* how an endpoint is configured to host a service. See the getXXX methods
* for more details.
*
*
*
* <h3>Implementation Notes</h3>
* <p>
* {@link WSEndpoint} owns a {@link WSWebServiceContext} implementation.
* But a bulk of the work is delegated to {@link WebServiceContextDelegate},
* which is passed in as a parameter to {@link PipeHead#process(Packet, WebServiceContextDelegate, TransportBackChannel)}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class WSEndpoint<T> implements ComponentRegistry {
/**
* Gets the Endpoint's codec that is used to encode/decode {@link Message}s. This is a
* copy of the master codec and it shouldn't be shared across two requests running
* concurrently(unless it is stateless).
*
* @return codec to encode/decode
*/
public abstract @NotNull Codec createCodec();
/**
* Gets the application endpoint's serviceName. It could be got from DD or annotations
*
* @return same as wsdl:service QName if WSDL exists or generated
*/
public abstract @NotNull QName getServiceName();
/**
* Gets the application endpoint's portName. It could be got from DD or annotations
*
* @return same as wsdl:port QName if WSDL exists or generated
*/
public abstract @NotNull QName getPortName();
/**
* Gets the application endpoint {@link Class} that eventually serves the request.
*
* <p>
* This is the same value given to the {@link #create} method.
*/
public abstract @NotNull Class<T> getImplementationClass();
/**
* Represents the binding for which this {@link WSEndpoint}
* is created for.
*
* @return
* always same object.
*/
public abstract @NotNull WSBinding getBinding();
/**
* Gets the {@link Container} object.
*
* <p>
* The components inside {@link WSEndpoint} uses this reference
* to communicate with the hosting environment.
*
* @return
* always same object. If no "real" {@link Container} instance
* is given, {@link Container#NONE} will be returned.
*/
public abstract @NotNull Container getContainer();
/**
* Gets the port that this endpoint is serving.
*
* <p>
* A service is not required to have a WSDL, and when it doesn't,
* this method returns null. Otherwise it returns an object that
* describes the port that this {@link WSEndpoint} is serving.
*
* @return
* Possibly null, but always the same value.
*/
public abstract @Nullable WSDLPort getPort();
/**
* Set this {@link Executor} to run asynchronous requests using this executor.
* This executor is set on {@link Engine} and must be set before
* calling {@link #schedule(Packet,CompletionCallback) } and
* {@link #schedule(Packet,CompletionCallback,FiberContextSwitchInterceptor)} methods.
*
* @param exec Executor to run async requests
*/
public abstract void setExecutor(@NotNull Executor exec);
/**
* This method takes a {@link Packet} that represents
* a request, run it through a {@link Tube}line, eventually
* pass it to the user implementation code, which produces
* a reply, then run that through the tubeline again,
* and eventually return it as a return value through {@link CompletionCallback}.
*
* <p>
* This takes care of pooling of {@link Tube}lines and reuses
* tubeline for requests. Same instance of tubeline is not used concurrently
* for two requests.
*
* <p>
* If the transport is capable of asynchronous execution, use this
* instead of using {@link PipeHead#process}.
*
* <p>
* Before calling this method, set the executor using {@link #setExecutor}. The
* executor may used multiple times to run this request in a asynchronous fashion.
* The calling thread will be returned immediately, and the callback will be
* called in a different a thread.
*
* <p>
* {@link Packet#transportBackChannel} should have the correct value, so that
* one-way message processing happens correctly. {@link Packet#webServiceContextDelegate}
* should have the correct value, so that some {@link WebServiceContext} methods correctly.
*
* @see Packet#transportBackChannel
* @see Packet#webServiceContextDelegate
*
* @param request web service request
* @param callback callback to get response packet
*/
public final void schedule(@NotNull Packet request, @NotNull CompletionCallback callback ) {
schedule(request,callback,null);
}
/**
* Schedule invocation of web service asynchronously.
*
* @see #schedule(Packet, CompletionCallback)
*
* @param request web service request
* @param callback callback to get response packet(exception if there is one)
* @param interceptor caller's interceptor to impose a context of execution
*/
public abstract void schedule(@NotNull Packet request, @NotNull CompletionCallback callback, @Nullable FiberContextSwitchInterceptor interceptor );
public void process(@NotNull Packet request, @NotNull CompletionCallback callback, @Nullable FiberContextSwitchInterceptor interceptor ) {
schedule(request,callback,interceptor);
}
/**
* Returns {@link Engine} for this endpoint
* @return Engine
*/
public Engine getEngine() {
throw new UnsupportedOperationException();
}
/**
* Callback to notify that jax-ws runtime has finished execution of a request
* submitted via schedule().
*/
public interface CompletionCallback {
/**
* Indicates that the jax-ws runtime has finished execution of a request
* submitted via schedule().
*
* <p>
* Since the JAX-WS RI runs asynchronously,
* this method maybe invoked by a different thread
* than any of the threads that started it or run a part of tubeline.
*
* @param response {@link Packet}
*/
void onCompletion(@NotNull Packet response);
}
/**
* Creates a new {@link PipeHead} to process
* incoming requests.
*
* <p>
* This is not a cheap operation. The caller is expected
* to reuse the returned {@link PipeHead}. See
* {@link WSEndpoint class javadoc} for details.
*
* @return
* A newly created {@link PipeHead} that's ready to serve.
*/
public abstract @NotNull PipeHead createPipeHead();
/**
* Represents a resource local to a thread.
*
* See {@link WSEndpoint} class javadoc for more discussion about
* this.
*/
public interface PipeHead {
/**
* Processes a request and produces a reply.
*
* <p>
* This method takes a {@link Packet} that represents
* a request, run it through a {@link Tube}line, eventually
* pass it to the user implementation code, which produces
* a reply, then run that through the pipeline again,
* and eventually return it as a return value.
*
* @param request
* Unconsumed {@link Packet} that represents
* a request.
* @param wscd
* {@link WebServiceContextDelegate} to be set to {@link Packet}.
* (we didn't have to take this and instead just ask the caller to
* set to {@link Packet#webServiceContextDelegate}, but that felt
* too error prone.)
* @param tbc
* {@link TransportBackChannel} to be set to {@link Packet}.
* See the {@code wscd} parameter javadoc for why this is a parameter.
* Can be null.
* @return
* Unconsumed {@link Packet} that represents
* a reply to the request.
*
* @throws WebServiceException
* This method <b>does not</b> throw a {@link WebServiceException}.
* The {@link WSEndpoint} must always produce a fault {@link Message}
* for it.
*
* @throws RuntimeException
* A {@link RuntimeException} thrown from this method, including
* {@link WebServiceException}, must be treated as a bug in the
* code (including JAX-WS and all the pipe implementations), not
* an operator error by the user.
*
* <p>
* Therefore, it should be recorded by the caller in a way that
* allows developers to fix a bug.
*/
@NotNull Packet process(
@NotNull Packet request, @Nullable WebServiceContextDelegate wscd, @Nullable TransportBackChannel tbc);
}
/**
* Indicates that the {@link WSEndpoint} is about to be turned off,
* and will no longer serve any packet anymore.
*
* <p>
* This method needs to be invoked for the JAX-WS RI to correctly
* implement some of the spec semantics (TODO: pointer.)
* It's the responsibility of the code that hosts a {@link WSEndpoint}
* to invoke this method.
*
* <p>
* Once this method is called, the behavior is undefed for
* all in-progress {@link PipeHead#process} methods (by other threads)
* and future {@link PipeHead#process} method invocations.
*/
public abstract void dispose();
/**
* Gets the description of the service.
*
* <p>
* A description is a set of WSDL/schema and other documents that together
* describes a service.
* A service is not required to have a description, and when it doesn't,
* this method returns null.
*
* @return
* Possibly null, always the same value under ordinary circumstances but
* may change if the endpoint is managed.
*/
public abstract @Nullable ServiceDefinition getServiceDefinition();
/**
* Gets the list of {@link BoundEndpoint} that are associated
* with this endpoint.
*
* @return
* always return the same set.
*/
public List<BoundEndpoint> getBoundEndpoints() {
Module m = getContainer().getSPI(Module.class);
return m != null ? m.getBoundEndpoints() : null;
}
/**
* Gets the list of {@link EndpointComponent} that are associated
* with this endpoint.
*
* <p>
* Components (such as codec, tube, handler, etc) who wish to provide
* some service to other components in the endpoint can iterate the
* registry and call its {@link EndpointComponent#getSPI(Class)} to
* establish a private contract between components.
* <p>
* Components who wish to subscribe to such a service can add itself
* to this set.
*
* @return
* always return the same set.
* @deprecated
*/
public abstract @NotNull Set<EndpointComponent> getComponentRegistry();
public @NotNull Set<Component> getComponents() {
return Collections.emptySet();
}
public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
Set<Component> componentRegistry = getComponents();
if (componentRegistry != null) {
for (Component c : componentRegistry) {
S s = c.getSPI(spiType);
if (s != null)
return s;
}
}
return getContainer().getSPI(spiType);
}
/**
* Gets the {@link com.sun.xml.internal.ws.api.model.SEIModel} that represents the relationship
* between WSDL and Java SEI.
*
* <p>
* This method returns a non-null value if and only if this
* endpoint is ultimately serving an application through an SEI.
*
* @return
* maybe null. See above for more discussion.
* Always the same value.
*/
public abstract @Nullable SEIModel getSEIModel();
/**
* Gives the PolicMap that captures the Policy for the endpoint
*
* @return PolicyMap
*
* @deprecated
* Do not use this method as the PolicyMap API is not final yet and might change in next few months.
*/
public abstract PolicyMap getPolicyMap();
/**
* Get the ManagedObjectManager for this endpoint.
*/
public abstract @NotNull ManagedObjectManager getManagedObjectManager();
/**
* Close the ManagedObjectManager for this endpoint.
* This is used by the Web Service Configuration Management system so that it
* closes the MOM before it creates a new WSEndpoint. Then it calls dispose
* on the existing endpoint and then installs the new endpoint.
* The call to dispose also calls closeManagedObjectManager, but is a noop
* if that method has already been called.
*/
public abstract void closeManagedObjectManager();
/**
* This is only needed to expose info for monitoring.
*/
public abstract @NotNull ServerTubeAssemblerContext getAssemblerContext();
/**
* Creates an endpoint from deployment or programmatic configuration
*
* <p>
* This method works like the following:
* <ol>
* <li>{@link ServiceDefinition} is modeleed from the given SEI type.
* <li>{@link Invoker} that always serves <tt>implementationObject</tt> will be used.
* </ol>
* @param implType
* Endpoint class(not SEI). Enpoint class must have @WebService or @WebServiceProvider
* annotation.
* @param processHandlerAnnotation
* Flag to control processing of @HandlerChain on Impl class
* if true, processes @HandlerChain on Impl
* if false, DD might have set HandlerChain no need to parse.
* @param invoker
* Pass an object to invoke the actual endpoint object. If it is null, a default
* invoker is created using {@link InstanceResolver#createDefault}. Appservers
* could create its own invoker to do additional functions like transactions,
* invoking the endpoint through proxy etc.
* @param serviceName
* Optional service name(may be from DD) to override the one given by the
* implementation class. If it is null, it will be derived from annotations.
* @param portName
* Optional port name(may be from DD) to override the one given by the
* implementation class. If it is null, it will be derived from annotations.
* @param container
* Allows technologies that are built on top of JAX-WS(such as WSIT) needs to
* negotiate private contracts between them and the container
* @param binding
* JAX-WS implementation of {@link Binding}. This object can be created by
* {@link BindingID#createBinding()}. Usually the binding can be got from
* DD, {@link javax.xml.ws.BindingType}.
*
*
* TODO: DD has a configuration for MTOM threshold.
* Maybe we need something more generic so that other technologies
* like Tango can get information from DD.
*
* TODO: does it really make sense for this to take EntityResolver?
* Given that all metadata has to be given as a list anyway.
*
* @param primaryWsdl
* The {@link ServiceDefinition#getPrimary() primary} WSDL.
* If null, it'll be generated based on the SEI (if this is an SEI)
* or no WSDL is associated (if it's a provider.)
* TODO: shouldn't the implementation find this from the metadata list?
* @param metadata
* Other documents that become {@link SDDocument}s. Can be null.
* @param resolver
* Optional resolver used to de-reference resources referenced from
* WSDL. Must be null if the {@code url} is null.
* @param isTransportSynchronous
* If the caller knows that the returned {@link WSEndpoint} is going to be
* used by a synchronous-only transport, then it may pass in <tt>true</tt>
* to allow the callee to perform an optimization based on that knowledge
* (since often synchronous version is cheaper than an asynchronous version.)
* This value is visible from {@link ServerTubeAssemblerContext#isSynchronous()}.
*
* @return newly constructed {@link WSEndpoint}.
* @throws WebServiceException
* if the endpoint set up fails.
*/
public static <T> WSEndpoint<T> create(
@NotNull Class<T> implType,
boolean processHandlerAnnotation,
@Nullable Invoker invoker,
@Nullable QName serviceName,
@Nullable QName portName,
@Nullable Container container,
@Nullable WSBinding binding,
@Nullable SDDocumentSource primaryWsdl,
@Nullable Collection<? extends SDDocumentSource> metadata,
@Nullable EntityResolver resolver,
boolean isTransportSynchronous) {
return create(implType, processHandlerAnnotation, invoker, serviceName, portName, container, binding, primaryWsdl, metadata, resolver, isTransportSynchronous, true);
}
public static <T> WSEndpoint<T> create(
@NotNull Class<T> implType,
boolean processHandlerAnnotation,
@Nullable Invoker invoker,
@Nullable QName serviceName,
@Nullable QName portName,
@Nullable Container container,
@Nullable WSBinding binding,
@Nullable SDDocumentSource primaryWsdl,
@Nullable Collection<? extends SDDocumentSource> metadata,
@Nullable EntityResolver resolver,
boolean isTransportSynchronous,
boolean isStandard)
{
final WSEndpoint<T> endpoint =
EndpointFactory.createEndpoint(
implType,processHandlerAnnotation, invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,isTransportSynchronous,isStandard);
final Iterator<ManagedEndpointFactory> managementFactories = ServiceFinder.find(ManagedEndpointFactory.class).iterator();
if (managementFactories.hasNext()) {
final ManagedEndpointFactory managementFactory = managementFactories.next();
final EndpointCreationAttributes attributes = new EndpointCreationAttributes(
processHandlerAnnotation, invoker, resolver, isTransportSynchronous);
WSEndpoint<T> managedEndpoint = managementFactory.createEndpoint(endpoint, attributes);
if (endpoint.getAssemblerContext().getTerminalTube() instanceof EndpointAwareTube) {
((EndpointAwareTube)endpoint.getAssemblerContext().getTerminalTube()).setEndpoint(managedEndpoint);
}
return managedEndpoint;
}
return endpoint;
}
/**
* Deprecated version that assumes <tt>isTransportSynchronous==false</tt>
*/
@Deprecated
public static <T> WSEndpoint<T> create(
@NotNull Class<T> implType,
boolean processHandlerAnnotation,
@Nullable Invoker invoker,
@Nullable QName serviceName,
@Nullable QName portName,
@Nullable Container container,
@Nullable WSBinding binding,
@Nullable SDDocumentSource primaryWsdl,
@Nullable Collection<? extends SDDocumentSource> metadata,
@Nullable EntityResolver resolver) {
return create(implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,false);
}
/**
* The same as
* {@link #create(Class, boolean, Invoker, QName, QName, Container, WSBinding, SDDocumentSource, Collection, EntityResolver)}
* except that this version takes an url of the <tt>jax-ws-catalog.xml</tt>.
*
* @param catalogUrl
* if not null, an {@link EntityResolver} is created from it and used.
* otherwise no resolution will be performed.
*/
public static <T> WSEndpoint<T> create(
@NotNull Class<T> implType,
boolean processHandlerAnnotation,
@Nullable Invoker invoker,
@Nullable QName serviceName,
@Nullable QName portName,
@Nullable Container container,
@Nullable WSBinding binding,
@Nullable SDDocumentSource primaryWsdl,
@Nullable Collection<? extends SDDocumentSource> metadata,
@Nullable URL catalogUrl) {
return create(
implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,
XmlUtil.createEntityResolver(catalogUrl),false);
}
/**
* Gives the wsdl:service default name computed from the endpoint implementaiton class
*/
public static @NotNull QName getDefaultServiceName(Class endpointClass){
return getDefaultServiceName(endpointClass, true, null);
}
public static @NotNull QName getDefaultServiceName(Class endpointClass, MetadataReader metadataReader){
return getDefaultServiceName(endpointClass, true, metadataReader);
}
public static @NotNull QName getDefaultServiceName(Class endpointClass, boolean isStandard){
return getDefaultServiceName(endpointClass, isStandard, null);
}
public static @NotNull QName getDefaultServiceName(Class endpointClass, boolean isStandard, MetadataReader metadataReader){
return EndpointFactory.getDefaultServiceName(endpointClass, isStandard, metadataReader);
}
/**
* Gives the wsdl:service/wsdl:port default name computed from the endpoint implementaiton class
*/
public static @NotNull QName getDefaultPortName(@NotNull QName serviceName, Class endpointClass) {
return getDefaultPortName(serviceName, endpointClass, null);
}
public static @NotNull QName getDefaultPortName(@NotNull QName serviceName, Class endpointClass, MetadataReader metadataReader) {
return getDefaultPortName(serviceName, endpointClass, true, metadataReader);
}
public static @NotNull QName getDefaultPortName(@NotNull QName serviceName, Class endpointClass, boolean isStandard) {
return getDefaultPortName(serviceName, endpointClass, isStandard, null);
}
public static @NotNull QName getDefaultPortName(@NotNull QName serviceName, Class endpointClass, boolean isStandard, MetadataReader metadataReader){
return EndpointFactory.getDefaultPortName(serviceName, endpointClass, isStandard, metadataReader);
}
/**
* Return EndpointReference instance, based on passed parameters and spec version represented by clazz
* @param <T>
* @param clazz represents spec version
* @param address endpoint address
* @param wsdlAddress wsdl address
* @param referenceParameters any reference parameters to be added to the instance
* @return EndpointReference instance based on passed parameters and values obtained from current instance
*/
public abstract <T extends EndpointReference> T getEndpointReference(Class<T> clazz, String address, String wsdlAddress, Element... referenceParameters);
/**
*
* @param <T>
* @param clazz
* @param address
* @param wsdlAddress
* @param metadata
* @param referenceParameters
* @return EndpointReference instance based on passed parameters and values obtained from current instance
*/
public abstract <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
String address, String wsdlAddress, List<Element> metadata,
List<Element> referenceParameters);
/**
* Used for managed endpoints infrastructure to compare equality of proxies vs proxied endpoints.
* @param endpoint
* @return true if the proxied endpoint instance held by this instance equals to 'endpoint', otherwise return false.
*/
public boolean equalsProxiedInstance(WSEndpoint endpoint) {
if (endpoint == null) return false;
return this.equals(endpoint);
}
/**
* Nullable when there is no associated WSDL Model
* @return
*/
public abstract @Nullable OperationDispatcher getOperationDispatcher();
/**
* This is used by WsaServerTube and WSEndpointImpl to create a Packet with SOAPFault message from a Java exception.
*/
public abstract Packet createServiceResponseForException(final ThrowableContainerPropertySet tc,
final Packet responsePacket,
final SOAPVersion soapVersion,
final WSDLPort wsdlPort,
final SEIModel seiModel,
final WSBinding binding);
}

View File

@@ -0,0 +1,52 @@
/*
* 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.server;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.ws.api.message.Packet;
import javax.xml.ws.WebServiceContext;
/**
* {@link WebServiceContext} that exposes JAX-WS RI specific additions.
*
* <p>
* {@link WebServiceContext} instances that JAX-WS injects always
* implement this interface.
*
* <p>
* The JAX-WS RI may add methods on this interface, so do not implement
* this interface in your code, or risk {@link LinkageError}.
*
* @author Kohsuke Kawaguchi
*/
public interface WSWebServiceContext extends WebServiceContext {
/**
* Obtains the request packet that is being processed.
* @return Packet for the request
*/
@Nullable Packet getRequestPacket();
}

View File

@@ -0,0 +1,56 @@
/*
* 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.server;
import com.sun.istack.internal.NotNull;
/**
* {@link Module} that is an HTTP container.
*
* @author Kohsuke Kawaguchi
* @since 2.1 EA3
*/
public abstract class WebModule extends Module {
/**
* Gets the host, port, and context path portion of this module.
*
* <p>
* For example, if this is an web appliation running in a servlet
* container "http://myhost/myapp", then this method should return
* this URI.
*
* <p>
* This method follows the convention of the <tt>HttpServletRequest.getContextPath()</tt>,
* and accepts strings like "http://myhost" (for web applications that are deployed
* to the root context path), or "http://myhost/foobar" (for web applications
* that are deployed to context path "/foobar")
*
* <p>
* Notice that this method involves in determining the machine name
* without relying on HTTP "Host" header.
*/
public abstract @NotNull String getContextPath();
}

View File

@@ -0,0 +1,151 @@
/*
* 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.server;
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.Pipe;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
import java.security.Principal;
/**
* This object is set to {@link Packet#webServiceContextDelegate}
* to serve {@link WebServiceContext} methods for a {@link Packet}.
*
* <p>
* When the user application calls a method on {@link WebServiceContext},
* the JAX-WS RI goes to the {@link Packet} that represents the request,
* then check {@link Packet#webServiceContextDelegate}, and forwards
* the method calls to {@link WebServiceContextDelegate}.
*
* <p>
* All the methods defined on this interface takes {@link Packet}
* (whose {@link Packet#webServiceContextDelegate} points to
* this object), so that a single stateless {@link WebServiceContextDelegate}
* can be used to serve multiple concurrent {@link Packet}s,
* if the implementation wishes to do so.
*
* <p>
* (It is also allowed to create one instance of
* {@link WebServiceContextDelegate} for each packet,
* and thus effectively ignore the packet parameter.)
*
* <p>
* Attaching this on a {@link Packet} allows {@link Pipe}s to
* intercept and replace them, if they wish.
*
*
* @author Kohsuke Kawaguchi
*/
public interface WebServiceContextDelegate {
/**
* Implements {@link WebServiceContext#getUserPrincipal()}
* for the given packet.
*
* @param request
* Always non-null. See class javadoc.
* @see WebServiceContext#getUserPrincipal()
*/
Principal getUserPrincipal(@NotNull Packet request);
/**
* Implements {@link WebServiceContext#isUserInRole(String)}
* for the given packet.
*
* @param request
* Always non-null. See class javadoc.
* @see WebServiceContext#isUserInRole(String)
*/
boolean isUserInRole(@NotNull Packet request,String role);
/**
* Gets the address of the endpoint.
*
* <p>
* The "address" of endpoints is always affected by a particular
* client being served, hence it's up to transport to provide this
* information.
*
* @param request
* Always non-null. See class javadoc.
* @param endpoint
* The endpoint whose address will be returned.
*
* @throws WebServiceException
* if this method could not compute the address for some reason.
* @return
* Absolute URL of the endpoint. This shold be an address that the client
* can use to talk back to this same service later.
*
* @see WebServiceContext#getEndpointReference
*/
@NotNull String getEPRAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
/**
* Gets the address of the primary WSDL.
*
* <p>
* If a transport supports publishing of WSDL by itself (instead/in addition to MEX),
* then it should implement this method so that the rest of the JAX-WS RI can
* use that information.
*
* For example, HTTP transports often use the convention {@code getEPRAddress()+"?wsdl"}
* for publishing WSDL on HTTP.
*
* <p>
* Some transports may not have such WSDL publishing mechanism on its own.
* Those transports may choose to return null, indicating that WSDL
* is not published. If such transports are always used in conjunction with
* other transports that support WSDL publishing (such as SOAP/TCP used
* with Servlet transport), then such transport may
* choose to find the corresponding servlet endpoint by {@link Module#getBoundEndpoints()}
* and try to obtain the address from there.
*
* <p>
* This information is used to put a metadata reference inside an EPR,
* among other things. Clients that do not support MEX rely on this
* WSDL URL to retrieve metadata, it is desirable for transports to support
* this, but not mandatory.
*
* <p>
* This method will be never invoked if the {@link WSEndpoint}
* does not have a corresponding WSDL to begin with
* (IOW {@link WSEndpoint#getServiceDefinition() returning null}.
*
* @param request
* Always non-null. See class javadoc.
* @param endpoint
* The endpoint whose address will be returned.
*
* @return
* null if the implementation does not support the notion of
* WSDL publishing.
*/
@Nullable String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
}

View File

@@ -0,0 +1,31 @@
/*
* 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.
*/
/**
* APIs for hosting JAX-WS services.
*
* If you are new to the code, start with {@link com.sun.xml.internal.ws.api.server.WSEndpoint}.
*/
package com.sun.xml.internal.ws.api.server;