com.sun.xml.ws.client
Class RequestContext

java.lang.Object
  extended by com.sun.xml.ws.api.PropertySet
      extended by com.sun.xml.ws.client.RequestContext

public final class RequestContext
extends PropertySet

Request context implementation.

Why a custom map?

The JAX-WS spec exposes properties as a Map, but if we just use an ordinary HashMap for this, it doesn't work as fast as we'd like it to be. Hence we have this class.

We expect the user to set a few properties and then use that same setting to make a bunch of invocations. So we'd like to take some hit when the user actually sets a property to do some computation, then use that computed value during a method invocation again and again.

For this goal, we use PropertySet and implement some properties as virtual properties backed by methods. This allows us to do the computation in the setter, and store it in a field.

These fields are used by Stub.process(com.sun.xml.ws.api.message.Packet, com.sun.xml.ws.client.RequestContext, com.sun.xml.ws.client.ResponseContextReceiver) to populate a Packet.

How it works?

We make an assumption that a request context is mostly used to just get and put values, not really for things like enumerating or size.

So we start by maintaining state as a combination of others bag and strongly-typed fields. As long as the application uses just Map.put(K, V), Map.get(java.lang.Object), and Map.putAll(java.util.Map), we can do things in this way. In this mode a Map we return works as a view into RequestContext, and by itself it maintains no state.

If RequestContext is in this mode, its state can be copied efficiently into Packet.

Once the application uses any other Map method, we move to the "fallback" mode, where the data is actually stored in a HashMap, this is necessary for implementing the map interface contract correctly.

To be safe, once we fallback, we'll never come back to the efficient state.

Caution

Once we are in the fallback mode, none of the strongly typed field will be used, and they may contain stale values. So the only method the code outside this class can safely use is copy(), fill(Packet), and constructors. Do not access the strongly typed fields nor others directly.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.xml.ws.api.PropertySet
PropertySet.Accessor, PropertySet.Property, PropertySet.PropertyMap
 
Field Summary
 ContentNegotiation contentNegotiation
          The value of ContentNegotiation.PROPERTY property.
 
Constructor Summary
RequestContext()
          Creates an empty RequestContext.
 
Method Summary
 RequestContext copy()
           
 void fill(Packet packet)
          Fill a Packet with values of this RequestContext.
 Object get(Object key)
          The efficient get method that reads from RequestContext.
 String getContentNegotiationString()
           
 EndpointAddress getEndpointAddress()
           
 String getEndPointAddressString()
          Deprecated. always access endpointAddress.
 Map<String,Object> getMapView()
          Gets the Map view of this request context.
protected  PropertySet.PropertyMap getPropertyMap()
          Map representing the Fields and Methods annotated with PropertySet.Property.
 String getSoapAction()
           
 Object put(String key, Object value)
          The efficient put method that updates RequestContext.
 void setContentNegotiationString(String s)
           
 void setEndpointAddress(EndpointAddress epa)
           
 void setEndPointAddressString(String s)
           
 void setSoapAction(String sAction)
           
 
Methods inherited from class com.sun.xml.ws.api.PropertySet
containsKey, createMapView, parse, remove, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentNegotiation

public ContentNegotiation contentNegotiation
The value of ContentNegotiation.PROPERTY property.

Constructor Detail

RequestContext

RequestContext()
Creates an empty RequestContext.

Method Detail

getEndPointAddressString

public String getEndPointAddressString()
Deprecated. always access endpointAddress.

Creates BindingProvider.ENDPOINT_ADDRESS_PROPERTY view on top of endpointAddress.


setEndPointAddressString

public void setEndPointAddressString(String s)

setEndpointAddress

public void setEndpointAddress(@NotNull
                               EndpointAddress epa)

getEndpointAddress

@NotNull
public EndpointAddress getEndpointAddress()

getContentNegotiationString

public String getContentNegotiationString()

setContentNegotiationString

public void setContentNegotiationString(String s)

getSoapAction

public String getSoapAction()

setSoapAction

public void setSoapAction(String sAction)

get

public Object get(Object key)
The efficient get method that reads from RequestContext.

Overrides:
get in class PropertySet
Parameters:
key - This field is typed as Object to follow the Map.get(Object) convention, but if anything but String is passed, this method just returns null.

put

public Object put(String key,
                  Object value)
The efficient put method that updates RequestContext.

Overrides:
put in class PropertySet
See Also:
PropertySet.Property

getMapView

public Map<String,Object> getMapView()
Gets the Map view of this request context.

Returns:
Always same object. Returned map is live.

fill

public void fill(Packet packet)
Fill a Packet with values of this RequestContext.


copy

public RequestContext copy()

getPropertyMap

protected PropertySet.PropertyMap getPropertyMap()
Description copied from class: PropertySet
Map representing the Fields and Methods annotated with PropertySet.Property. Model of PropertySet class.

At the end of the derivation chain this method just needs to be implemented as:

 private static final PropertyMap model;
 static {
   model = parse(MyDerivedClass.class);
 }
 protected PropertyMap getPropertyMap() {
   return model;
 }
 

Specified by:
getPropertyMap in class PropertySet