com.esri.adf.web.data
Class WebContext

java.lang.Object
  extended by com.esri.adf.web.data.WebContext
All Implemented Interfaces:
WebContextInitialize, WebLifecycle, Serializable

public class WebContext
extends Object
implements WebContextInitialize, WebLifecycle, Serializable

The WebContext maintains references to the GISResources as well as to attributes (GIS business objects) such as WebMap, WebGraphics, WebQuery, etc.

Additionally, the WebContext is responsible for making the callback methods implemented by the resources and attributes at appropriate junctures of the ADF application. The callback methods are declared in the WebContextInitialize, WebContextObserver and WebLifecycle interfaces.

Users can add custom GIS business objects to the context as attributes of the WebContext programmatically:

 WebContext ctx = ...;
 MyAttribute myAttr = new MyAttribute();
 ctx.setAttribute("myAttr", myAttr);
 

Users can also register attributes on the context in JSF managed bean configuration files as such:

 <managed-bean>
   <managed-bean-name>myAttr</managed-bean-name>
   <managed-bean-class>myPackage.MyAttribute</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
 </managed-bean>
 
 <managed-bean>
   <managed-bean-name>myContext</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
   ...
   <managed-property>
     <property-name>attributes</property-name>
     ...
     <map-entries>
       <map-entry>
         <key>myAttr</key>
         <value>#{myAttr}</value>
       </map-entry>
     </map-entries>
   </managed-property>
 </managed-bean>
 

Once you have registered your object as an attribute of the context, the WebContext will make the appropriate callbacks into your object as it does with all attributes.

The WebContext also defines methods to dynamically add and remove GISResources from the context.

 WebContext ctx = ...;
 AGSMapResource ags = new AGSMapResource();
 ags.setEndPointURL("http://myserver/mywebservice");
 ags.addFunctionality("map", new AGSMapFunctionality());
 ctx.addResource("ags1", ags, 0);
 ...
 ...
 ctx.removeResource(ags);
 

Users can work with multiple contexts in the same session. All contexts are stored in a WebSession object which ensures that all WebContexts it maintains are cleanly destroyed when the user session terminates.

See Also:
Serialized Form

Field Summary
protected  Map<String,Object> attributes
           The GIS business objects maintained by this WebContext
static String DEFAULT_GRAPHICS_RESOURCE_KEY
           The key for the default GraphicsResource.
protected  WebGeocode geocode
           The WebGeocode referenced by this context.
protected  WebGraphics graphics
           The WebGraphics referenced by this context.
protected  boolean init
           true if this context has already been initialized.
protected  WebMap map
           The WebMap referenced by this context.
protected  String name
           
protected  List<WebContextObserver> observers
           The List of WebContextObservers registered with this context.
protected  WebOverview overview
           The WebOverview referenced by this context.
protected  WebQuery query
           The WebQuery referenced by this context.
protected  Map<String,GISResource> resources
           The List of GISResources maintained by this context.
protected  WebResults results
           The WebResults referenced by this context.
protected  WebSession session
           The WebSession that maintains a reference to this context.
protected  WebSpatialReference spatialReference
           The spatial reference associated with this context.
protected  boolean supportMultipleSRs
          If true, this context supports GISResources in different spatial references.
protected  WebToc toc
           The WebToc referenced by this context.
static String WEB_GEOCODE_KEY
           The key for the WebGeocode attribute of the WebContext in the attributes Map.
static String WEB_GRAPHICS_KEY
           The key for the WebGraphics attribute of the WebContext in the attributes Map.
static String WEB_MAP_KEY
           The key for the WebMap attribute of the WebContext in the attributes Map.
static String WEB_OVERVIEW_KEY
           The key for the WebOverview attribute of the WebContext in the attributes Map.
static String WEB_QUERY_KEY
           The key for the WebQuery attribute of the WebContext in the attributes Map.
static String WEB_RESULTS_KEY
           The key for the WebResults attribute of the WebContext in the attributes Map.
static String WEB_TOC_KEY
           The key for the WebToc attribute of the WebContext in the attributes Map.
 
Constructor Summary
WebContext()
           
 
Method Summary
 void activate()
           This method should be called when this context is to be activated.
 void addObserver(WebContextObserver observer)
           Adds a WebContextObserver to this context.
 void addResource(String resourceId, GISResource resource)
           Adds a new GISResource to this context.
 void addResource(String resourceId, GISResource resource, int index)
           Adds a new GISResource to this context.
 void destroy()
           This method should be called when this context is to be destroyed.
 Object getAttribute(String attrName)
           Returns the attribute of this context referenced by the key name
 Map<String,Object> getAttributes()
           Returns the attributes associated with this context.
 String getDateFormat()
           
 GraphicsResource getDefaultGraphicsResource()
          Returns the default graphics resource that available in this object.
 String getName()
           
 String getNullValueDisplay()
           
 GISResource getResourceById(String resourceId)
          Returns the resource from WebContext object based on the specified resource id.
 String getResourceId(GISResource resource)
           
 Map<String,GISResource> getResources()
           Returns the Map of GISResources associated with this context
 WebSpatialReference getSpatialReference()
           Returns the spatial reference associated with this context.
 String getSpatialReferenceDefinitionString()
           Returns the definition string of the spatial reference associated with this context.
 int getSpatialReferenceId()
           Returns the ID of the spatial reference associated with this context.
 String getSpatialReferenceResourceId()
          Returns the ID of the resource whose spatial reference should be used by the WebContext
 GroupThreadPool getThreadPool()
           Returns the GroupThreadPool associated with this context.
 int getThreadPoolSize()
           Returns the size of the thread pool to execute parallel group tasks.
 WebGeocode getWebGeocode()
           Returns the WebGeocode referenced by this context.
 WebGraphics getWebGraphics()
           Returns the WebGraphics referenced by this context.
 WebMap getWebMap()
           Returns the WebMap referenced by this context.
 WebOverview getWebOverview()
           Returns the WebOverview referenced by this context.
 WebQuery getWebQuery()
           The WebQuery referenced by this context.
 WebResults getWebResults()
           The WebResults referenced by this context.
 WebSession getWebSession()
           Returns the WebSession that maintains a reference to this context.
 WebToc getWebToc()
           Returns the WebToc referenced by this context.
 void init(WebContext context)
           Initializes all the GISResources (which in turn also intializes the GISFunctionalitys that it maintains) maintained by this context
 boolean isInit()
           Return true if this context has already been initialized
 boolean isSupportMultipleSRs()
           Returns true if this context supports GISResources in different spatial references.
 void moveResource(int toIndex, GISResource resource)
           Moves a GISResource in this context to the specified index and then re-initializes all the WebContextInitialize attributes currently associated with the context.
 void passivate()
           This method should be called when this context is to be passivated.
 WebGeometry project(WebGeometry geometry)
           Convenience method which projects the given WebGeometry to the spatial reference of this context only if this context supports multiple SRs
 WebGeometry project(WebGeometry geometry, WebSpatialReference toSpatialReference)
           Convenience method which projects the given WebGeometry only if this context supports multiple SRs
 WebExtent projectExtent(WebExtent extent)
           Convenience method which projects the given WebExtent to the spatial reference of this context only if this context supports multiple SRs
 WebExtent projectExtent(WebExtent extent, WebSpatialReference toSpatialReference)
           Convenience method which projects the given WebExtent only if this context supports multiple SRs
 WebPoint projectPoint(WebPoint point)
           Convenience method which projects the given WebPoint to the spatial reference of this context only if this context supports multiple SRs
 WebPoint projectPoint(WebPoint point, WebSpatialReference toSpatialReference)
           Convenience method which projects the given WebPoint only if this context supports multiple SRs
 void refresh()
           Refreshes this context by updating all registered WebContextObservers.
 void refresh(Object arg)
           Refreshes this context by updating all registered WebContextObservers with arg as the argument.
 boolean removeObserver(WebContextObserver observer)
           Removes the observer from the set of WebContextObservers associated with this context.
 boolean removeResource(GISResource resource)
           Removes a GISResource from this context.
 void setAttribute(String attrName, Object attrValue)
           Sets value as an attribute of this context.
 void setAttributes(Map<String,?> attributes)
           Adds these attributes to the Map of attributes maintained by this context.
 void setDateFormat(String dateFormat)
           
 void setGeometryOperations(GeometryOperations operations)
          Specifies which implementation of GeometryOperations should be used.
 void setInit(boolean init)
           If true it initializes all the GISResources (which in turn also intializes the GISFunctionalitys that it maintains) and attributes referenced by this context.
 void setName(String name)
           
 void setNullValueDisplay(String nullValueDisplay)
           
 void setResources(Map<String,GISResource> resources)
           Sets the Map of GISResources associated with this context
 void setSpatialReference(WebSpatialReference spatialReference)
           Sets the spatial reference associated with this context.
 void setSpatialReferenceDefinitionString(String definitionString)
           Sets the spatial reference associated with this context by its definition string.
 void setSpatialReferenceId(int id)
           Sets the spatial reference associated with this context by its ID.
 void setSpatialReferenceResourceId(String spatialReferenceResourceId)
          Sets the ID of the resource whose spatial reference should be used by the WebContext.
 void setSupportMultipleSRs(boolean supportsMultipleSRs)
           If true, this context supports GISResources in different spatial references.
 void setThreadPool(GroupThreadPool pool)
           
 void setThreadPoolSize(int poolSize)
           Sets the size of the thread pool to execute parallel group tasks
 void setWebGeocode(WebGeocode geocode)
           Sets the WebGeocode referenced by this context.
 void setWebGraphics(WebGraphics graphics)
           Sets the WebGraphics referenced by this context.
 void setWebMap(WebMap map)
           Sets the WebMap referenced by this context.
 void setWebOverview(WebOverview overview)
           Sets the WebOverview referenced by this context.
 void setWebQuery(WebQuery query)
           The WebQuery referenced by this context.
 void setWebResults(WebResults results)
           The WebResults referenced by this context.
 void setWebSession(WebSession session)
           Sets the WebSession that maintains a reference to this context.
 void setWebToc(WebToc toc)
           Sets the WebToc referenced by this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEB_MAP_KEY

public static final String WEB_MAP_KEY

The key for the WebMap attribute of the WebContext in the attributes Map.

The WebMap attribute can also be accessed using the setWebMap(WebMap) and getWebMap() methods.

See Also:
Constant Field Values

WEB_GEOCODE_KEY

public static final String WEB_GEOCODE_KEY

The key for the WebGeocode attribute of the WebContext in the attributes Map.

The WebGeocode attribute can also be accessed using the setWebGeocode(WebGeocode) and getWebGeocode() methods.

See Also:
Constant Field Values

WEB_OVERVIEW_KEY

public static final String WEB_OVERVIEW_KEY

The key for the WebOverview attribute of the WebContext in the attributes Map.

The WebOverview attribute can also be accessed using the setWebOverview(WebOverview) and getWebOverview() methods.

See Also:
Constant Field Values

WEB_TOC_KEY

public static final String WEB_TOC_KEY

The key for the WebToc attribute of the WebContext in the attributes Map.

The WebToc attribute can also be accessed using the setWebToc(WebToc) and getWebToc() methods.

See Also:
Constant Field Values

WEB_GRAPHICS_KEY

public static final String WEB_GRAPHICS_KEY

The key for the WebGraphics attribute of the WebContext in the attributes Map.

The WebGraphics attribute can also be accessed using the setWebGraphics(WebGraphics) and getWebGraphics() methods.

See Also:
Constant Field Values

WEB_RESULTS_KEY

public static final String WEB_RESULTS_KEY

The key for the WebResults attribute of the WebContext in the attributes Map.

The WebResults attribute can also be accessed using the setWebResults(WebResults) and getWebResults() methods.

See Also:
Constant Field Values

WEB_QUERY_KEY

public static final String WEB_QUERY_KEY

The key for the WebQuery attribute of the WebContext in the attributes Map.

The WebQuery attribute can also be accessed using the setWebQuery(WebQuery) and getWebQuery() methods.

See Also:
Constant Field Values

DEFAULT_GRAPHICS_RESOURCE_KEY

public static final String DEFAULT_GRAPHICS_RESOURCE_KEY

The key for the default GraphicsResource.

The default graphics resource can be accessed using the getDefaultGraphicsResource().

See Also:
Constant Field Values

attributes

protected Map<String,Object> attributes

The GIS business objects maintained by this WebContext

Out of the box attributes (such as WebMap, WebGraphics, WebQuery, etc.) as well as custom business objects can be maintained by the context.


session

protected WebSession session

The WebSession that maintains a reference to this context.

Users can work with multiple contexts in the same session. All contexts are stored in a WebSession object which ensures that all WebContexts it maintains are cleanly destroyed when the user session terminates.


map

protected WebMap map

The WebMap referenced by this context.

The WebMap can be accessed using the setWebMap(WebMap) and getWebMap() methods or as an attribute of the context (WebMap)context.getAttribute("map");


geocode

protected WebGeocode geocode

The WebGeocode referenced by this context.

The WebGeocode can be accessed using the setWebGeocode(WebGeocode) and getWebGeocode() methods or as an attribute of the context (WebGeocode)context.getAttribute("geocode");


toc

protected WebToc toc

The WebToc referenced by this context.

The WebToc can be accessed using the setWebToc(WebToc) and getWebToc() methods or as an attribute of the context (WebToc)context.getAttribute("toc");


overview

protected WebOverview overview

The WebOverview referenced by this context.

The WebOverview can be accessed using the setWebOverview(WebOverview) and getWebOverview() methods or as an attribute of the context (WebOverview)context.getAttribute("overview");


graphics

protected WebGraphics graphics

The WebGraphics referenced by this context.

The WebGraphics can be accessed using the setWebGraphics(WebGraphics) and getWebGraphics() methods or as an attribute of the context (WebGraphics)context.getAttribute("graphics");


results

protected WebResults results

The WebResults referenced by this context.

The WebResults can be accessed using the setWebResults(WebResults) and getWebResults() methods or as an attribute of the context (WebResults)context.getAttribute("results");


query

protected WebQuery query

The WebQuery referenced by this context.

The WebQuery can be accessed using the setWebQuery(WebQuery) and getWebQuery() methods or as an attribute of the context (WebQuery)context.getAttribute("query");


init

protected boolean init

true if this context has already been initialized.

The context is typically initialized by the ContextControl when it calls the setInit(boolean) method.


observers

protected List<WebContextObserver> observers

The List of WebContextObservers registered with this context.

Users can register and unregister observers by using the addObserver(WebContextObserver) and removeObserver(WebContextObserver) methods respectively.


resources

protected Map<String,GISResource> resources

The List of GISResources maintained by this context.

Users can add and remove resources from this context by calling the addResource(String, GISResource) and removeResource(GISResource) methods respectively.


supportMultipleSRs

protected boolean supportMultipleSRs
If true, this context supports GISResources in different spatial references. true by default.


spatialReference

protected WebSpatialReference spatialReference

The spatial reference associated with this context.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.


name

protected String name
Constructor Detail

WebContext

public WebContext()
Method Detail

isInit

public boolean isInit()

Return true if this context has already been initialized

The context is typically initialized by the ContextControl when it calls the setInit(boolean) method.

Returns:
true if this context has already been initialized

setInit

public void setInit(boolean init)

If true it initializes all the GISResources (which in turn also intializes the GISFunctionalitys that it maintains) and attributes referenced by this context.

Note that if the context has already been initialized, i.e. if isInit() is true, this method does none of the above.

Parameters:
init - if true and if isInit() is false, this context will be initialized

init

public void init(WebContext context)

Initializes all the GISResources (which in turn also intializes the GISFunctionalitys that it maintains) maintained by this context

This method is typically called by the setInit(boolean) method.

Specified by:
init in interface WebContextInitialize
Parameters:
context - this WebContext
See Also:
WebContextInitialize.init(com.esri.adf.web.data.WebContext)

addResource

public void addResource(String resourceId,
                        GISResource resource,
                        int index)

Adds a new GISResource to this context.

If this resource already exists, it does nothing and simply returns. Otherwise, it adds the resource, initializes it and then re-initializes all the WebContextInitialize attributes currently associated with the context. If the index is within bounds, it adds the new resource at that position. Otherwise it adds it at the bottom.

Parameters:
resourceId - the ID of the GISResource to add to this context
resource - the GISResource to add to this context
index - the position where to add the resource
Throws:
NullPointerException - if the resource is null
See Also:
WebContextInitialize.init(com.esri.adf.web.data.WebContext)

addResource

public void addResource(String resourceId,
                        GISResource resource)

Adds a new GISResource to this context.

If this resource already exists, it does nothing and simply returns. Otherwise, it adds the resource, initializes it and then re-initializes all the WebContextInitialize attributes currently associated with the context. This method adds the resource at the very bottom.

Same effect as calling addResource(resource, -1)

Parameters:
resourceId - the ID of the GISResource to add to this context
resource - the GISResource to add to this context
See Also:
WebContextInitialize.init(com.esri.adf.web.data.WebContext)

removeResource

public boolean removeResource(GISResource resource)

Removes a GISResource from this context.

If this resource does not exist, it returns false. Otherwise, it calls the GISResource.destroy() method on the resource, removes the resource, re-initializes all the WebContextInitialize attributes currently associated with the context and then returns true.

Parameters:
resource - the GISResource to remove from this context
Returns:
true if the resource was successfully removed
Throws:
NullPointerException - if the resource is null
See Also:
WebContextInitialize.init(com.esri.adf.web.data.WebContext)

moveResource

public void moveResource(int toIndex,
                         GISResource resource)

Moves a GISResource in this context to the specified index and then re-initializes all the WebContextInitialize attributes currently associated with the context.

Parameters:
toIndex - the index to which the resource is moved
resource - the GISResource to be moved
Throws:
IndexOutOfBoundsException - if the toIndex is not in range
IllegalArgumentException - if the resource is not found in this context
See Also:
WebContextInitialize.init(com.esri.adf.web.data.WebContext)

getResources

public Map<String,GISResource> getResources()

Returns the Map of GISResources associated with this context

Returns:
the Map of GISResources associated with this context

setResources

public void setResources(Map<String,GISResource> resources)

Sets the Map of GISResources associated with this context

Typically this Map is set either declaratively in a JSF managed bean configuration file or programmatically before this context is initialized. Once the context has been initialized, you should use the addResource(String, GISResource) and removeResource(GISResource) methods instead

Parameters:
resources - the Map of GISResources associated with this context
See Also:
addResource(String, GISResource), removeResource(GISResource)

getThreadPoolSize

public int getThreadPoolSize()

Returns the size of the thread pool to execute parallel group tasks.

Returns:
the size of the thread pool to execute parallel group tasks
See Also:
GroupThreadPool

setThreadPoolSize

public void setThreadPoolSize(int poolSize)

Sets the size of the thread pool to execute parallel group tasks

Setting a new pool size will nullify the current GroupThreadPool and will result in the creation of a new GroupThreadPool.

Parameters:
poolSize - the size of the thread pool to execute parallel group tasks
See Also:
GroupThreadPool

getThreadPool

public GroupThreadPool getThreadPool()

Returns the GroupThreadPool associated with this context.

Users should typically use this pool to execute similar tasks across multiple GISResources in parallel. Below is a code snippet illustrating a typical use case. For more details see the documentation for the GroupThreadPool class

      WebContext ctx = ...;
      GroupThreadPool pool = ctx.getThreadPool();
      pool.execute(runnableTask1); //every call to execute() will submit a new task to the pool
      pool.execute(runnableTask2); //the pool then executes these tasks according to its policies
      ...
      pool.execute(runnableTaskN);
      <b>pool.awaitTermination();</b> //this call will block until all submitted tasks are completed
 

Returns:
the GroupThreadPool associated with this context
See Also:
GroupThreadPool, GroupThreadPool.awaitTermination()

setThreadPool

public void setThreadPool(GroupThreadPool pool)

getWebSession

public WebSession getWebSession()

Returns the WebSession that maintains a reference to this context.

Users can work with multiple contexts in the same session. All contexts are stored in a WebSession object which ensures that all WebContexts it maintains are cleanly destroyed when the user session terminates.

Returns:
the WebSession that maintains a reference to this context

setWebSession

public void setWebSession(WebSession session)

Sets the WebSession that maintains a reference to this context.

This method generates a new ID for this context and puts this context in the session

Users can work with multiple contexts in the same session. All contexts are stored in a WebSession object which ensures that all WebContexts it maintains are cleanly destroyed when the user session terminates.

Parameters:
session - the WebSession that maintains a reference to this context

setWebMap

public void setWebMap(WebMap map)

Sets the WebMap referenced by this context.

The WebMap can be accessed using the setWebMap(WebMap) and getWebMap() methods or as an attribute of the context (WebMap)context.getAttribute("map");

Parameters:
map - the WebMap referenced by this context

getWebMap

public WebMap getWebMap()

Returns the WebMap referenced by this context.

The WebMap can be accessed using the setWebMap(WebMap) and getWebMap() methods or as an attribute of the context (WebMap)context.getAttribute("map");

Returns:
the WebMap referenced by this context

setWebGeocode

public void setWebGeocode(WebGeocode geocode)

Sets the WebGeocode referenced by this context.

The WebGeocode can be accessed using the setWebGeocode(WebGeocode) and getWebGeocode() methods or as an attribute of the context (WebGeocode)context.getAttribute("geocode");

Parameters:
geocode - the WebGeocode referenced by this context

getWebGeocode

public WebGeocode getWebGeocode()

Returns the WebGeocode referenced by this context.

The WebGeocode can be accessed using the setWebGeocode(WebGeocode) and getWebGeocode() methods or as an attribute of the context (WebGeocode)context.getAttribute("geocode");

Returns:
the WebGeocode referenced by this context

setWebToc

public void setWebToc(WebToc toc)

Sets the WebToc referenced by this context.

The WebToc can be accessed using the setWebToc(WebToc) and getWebToc() methods or as an attribute of the context (WebToc)context.getAttribute("toc");

Parameters:
toc - the WebToc referenced by this context

getWebToc

public WebToc getWebToc()

Returns the WebToc referenced by this context.

The WebToc can be accessed using the setWebToc(WebToc) and getWebToc() methods or as an attribute of the context (WebToc)context.getAttribute("toc");

Returns:
the WebToc referenced by this context

setWebOverview

public void setWebOverview(WebOverview overview)

Sets the WebOverview referenced by this context.

The WebOverview can be accessed using the setWebOverview(WebOverview) and getWebOverview() methods or as an attribute of the context (WebOverview)context.getAttribute("overview");

Parameters:
overview - the WebOverview referenced by this context

getWebOverview

public WebOverview getWebOverview()

Returns the WebOverview referenced by this context.

The WebOverview can be accessed using the setWebOverview(WebOverview) and getWebOverview() methods or as an attribute of the context (WebOverview)context.getAttribute("overview");

Returns:
the WebOverview referenced by this context

setAttribute

public void setAttribute(String attrName,
                         Object attrValue)

Sets value as an attribute of this context. The attribute so set can be accessed with name as its key.

The WebContext.WEB_<NAME>_KEY constants defined on the WebContext are reserved for attributes of the corresponding type. So the WebMap attribute is reserved under the name WEB_MAP_KEY, the WebGeocode attribute is reserved under the name WEB_GEOCODE_KEY, and so on. Attempting to set attributes of a wrong type under these reserved keys will result in ClassCastExceptions

A null value will remove the named attribute from this context.

Once you have registered your object as an attribute of the context, the WebContext will make the appropriate callbacks into your object as it does with all attributes. The callback methods for context attributes are declared in the WebContextInitialize, WebContextObserver and WebLifecycle interfaces.

Parameters:
attrName - the attribute name
attrValue - the value of the attribute
Throws:
IllegalArgumentException - if name is null
See Also:
WebContextInitialize, WebContextObserver, WebLifecycle

getAttribute

public Object getAttribute(String attrName)

Returns the attribute of this context referenced by the key name

Parameters:
attrName - the attribute name
Returns:
the attribute of this context referenced by the key name
Throws:
IllegalArgumentException - is name is null
See Also:
setAttribute(String, Object)

setAttributes

public void setAttributes(Map<String,?> attributes)

Adds these attributes to the Map of attributes maintained by this context.

Typically the attributes are set either declaratively in a JSF managed bean configuration file or programmatically before this context is initialized. Once the context has been initialized, you should use the setAttribute(String, Object) and getAttribute(String) methods instead

Once you have registered objects as attributes of the context, the WebContext will make the appropriate callbacks into your object as it does with all attributes. The callback methods for context attributes are declared in the WebContextInitialize, WebContextObserver and WebLifecycle interfaces.

Parameters:
attributes - the attributes to be maintained by this context
See Also:
setAttribute(String, Object), WebContextInitialize, WebContextObserver, WebLifecycle

getAttributes

public Map<String,Object> getAttributes()

Returns the attributes associated with this context.

Returns:
the attributes associated with this context
See Also:
setAttributes(Map), getAttribute(String)

addObserver

public void addObserver(WebContextObserver observer)

Adds a WebContextObserver to this context.

The WebContext will call the WebContextObserver.update(WebContext, Object) methods on all its registered observers when someone call the refresh() or refresh(Object) methods on this context. This gives all observers of this context an opportunity to update themselves accordingly when the context is refreshed and in doing so keep themselves in sync with the other observers of the context

Parameters:
observer - the WebContextObserver to be registered
See Also:
WebContextObserver.update(WebContext, Object), refresh(), refresh(Object), removeObserver(WebContextObserver)

removeObserver

public boolean removeObserver(WebContextObserver observer)

Removes the observer from the set of WebContextObservers associated with this context.

The WebContext will no longer call the observer's update() method once this call is made.

Parameters:
observer - the WebContextObserver to be removed
Returns:
true if the observer was successfully removed

refresh

public void refresh()

Refreshes this context by updating all registered WebContextObservers.

Users call this method when they have changed the state of one of the attributes (be it out of the box attributes such as WebMap or custom ones) and want other attributes of the context to react to this change. As a result of calling this method, the update(this, null) of all registered observers will get called.

Same as refresh(null)}

See Also:
refresh(Object), WebContextObserver

refresh

public void refresh(Object arg)

Refreshes this context by updating all registered WebContextObservers with arg as the argument. Observers can lookup this arg and update themselves accordingly.

Users call this method when they have changed the state of one of the attributes (be it out of the box attributes such as WebMap or custom ones) and want other attributes of the context to react to this change. As a result of calling this method, the update(this, arg) of all registered observers will get called.

Parameters:
arg - the argument passed to the update() method of the registered WebContextObservers

destroy

public void destroy()

This method should be called when this context is to be destroyed. This method is typically called by the WebSession when the session is terminated.

This method does the following 3 things to destroy the context:

  1. Calls destroy() on all attributes that implement WebContextInitialize
  2. Unregisters all the registered WebContextObservers
  3. Calls destroy() on all the referenced GISResources

The WebContext is no longer usable once it has been destroyed.

Specified by:
destroy in interface WebContextInitialize
See Also:
WebContextInitialize.destroy(), GISResource.destroy()

activate

public void activate()

This method should be called when this context is to be activated. This method is typically called by the ADF when it starts to service a user request.

This method does the following 2 things to activate the context:

  1. Calls activate() on all the referenced GISResources
  2. Calls activate() on all attributes that implement WebLifecycle

The WebContext is usable to service a request only after it has been activated.

Specified by:
activate in interface WebLifecycle
See Also:
WebLifecycle.activate(), GISResource.activate()

passivate

public void passivate()

This method should be called when this context is to be passivated. This method is typically called by the ADF once it is done servicing a user request.

This method does the following 2 things to passivate the context:

  1. Calls passivate() on all attributes that implement WebLifecycle
  2. Calls passivate() on all the referenced GISResources

The WebContext is not usable once it has been passivated. To make it usable again one needs to reactivate it by calling the activate() method.

Specified by:
passivate in interface WebLifecycle
See Also:
WebLifecycle.passivate(), GISResource.passivate()

setWebGraphics

public void setWebGraphics(WebGraphics graphics)

Sets the WebGraphics referenced by this context.

The WebGraphics can be accessed using the setWebGraphics(WebGraphics) and getWebGraphics() methods or as an attribute of the context (WebGraphics)context.getAttribute("graphics");

Parameters:
graphics - the WebGraphics referenced by this context

getWebGraphics

public WebGraphics getWebGraphics()

Returns the WebGraphics referenced by this context.

The WebGraphics can be accessed using the setWebGraphics(WebGraphics) and getWebGraphics() methods or as an attribute of the context (WebGraphics)context.getAttribute("graphics");

Returns:
the WebGraphics referenced by this context

setWebResults

public void setWebResults(WebResults results)

The WebResults referenced by this context.

The WebResults can be accessed using the setWebResults(WebResults) and getWebResults() methods or as an attribute of the context (WebResults)context.getAttribute("results");

Parameters:
results - the WebResults referenced by this context

getWebResults

public WebResults getWebResults()

The WebResults referenced by this context.

The WebResults can be accessed using the setWebResults(WebResults) and getWebResults() methods or as an attribute of the context (WebResults)context.getAttribute("results");

Returns:
the WebResults referenced by this context

setWebQuery

public void setWebQuery(WebQuery query)

The WebQuery referenced by this context.

The WebQuery can be accessed using the setWebQuery(WebQuery) and getWebQuery() methods or as an attribute of the context (WebQuery)context.getAttribute("query");

Parameters:
query - the WebQuery referenced by this context

getWebQuery

public WebQuery getWebQuery()

The WebQuery referenced by this context.

The WebQuery can be accessed using the setWebQuery(WebQuery) and getWebQuery() methods or as an attribute of the context (WebQuery)context.getAttribute("query");

Returns:
the WebQuery referenced by this context

getSpatialReference

public WebSpatialReference getSpatialReference()

Returns the spatial reference associated with this context.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

Returns:
the spatial reference associated with this context

setSpatialReference

public void setSpatialReference(WebSpatialReference spatialReference)

Sets the spatial reference associated with this context.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

The following code snippet uses this method to change the spatial reference of the context and update the map and overview :
   WebContext context = ...;
   WebMap map = context.getWebMap();
   WebOverview overview = context.getWebOverview();
   WebSpatialReference newSR = WebSpatialReference.getWebSpatialReference(this.getProjectionId());
   context.setSpatialReference(newSR);
 
   map.init(context);
   WebPolygon horizon = newSR.getHorizon(false);
   if (horizon != null) {
    WebExtent horizonRect = null;
    if (horizon != null) {
      horizonRect = GeometryUtil.computeWebExtent(horizon);
      horizonRect.setSpatialReference(horizon.getSpatialReference());
      horizonRect = WebUtil.reaspect(horizonRect, map.getWidth(), map.getHeight());
      map.setFullExtent(horizonRect);
      map.setInitExtent(horizonRect);
    }
   }
   overview.exportImage();
   context.refresh();
 

Parameters:
spatialReference - the spatial reference associated with this context

setSpatialReferenceId

public void setSpatialReferenceId(int id)

Sets the spatial reference associated with this context by its ID.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

Parameters:
id - the ID of the spatial reference associated with this context

getSpatialReferenceId

public int getSpatialReferenceId()

Returns the ID of the spatial reference associated with this context.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

Returns:
the ID of the spatial reference associated with this context

setSpatialReferenceDefinitionString

public void setSpatialReferenceDefinitionString(String definitionString)

Sets the spatial reference associated with this context by its definition string.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

Parameters:
definitionString - the definition string of the spatial reference associated with this context

getSpatialReferenceDefinitionString

public String getSpatialReferenceDefinitionString()

Returns the definition string of the spatial reference associated with this context.

If set and if supportMultipleSRs is true, the map image exported by the WebMap should be in this SR.

Returns:
the definition string of the spatial reference associated with this context

isSupportMultipleSRs

public boolean isSupportMultipleSRs()

Returns true if this context supports GISResources in different spatial references. true by default.

Returns:
if true, this context supports GISResources in different spatial references. true by default.

setSupportMultipleSRs

public void setSupportMultipleSRs(boolean supportsMultipleSRs)

If true, this context supports GISResources in different spatial references. true by default.

Parameters:
supportsMultipleSRs - if true, this context supports GISResources in different spatial references. true by default.

projectExtent

public WebExtent projectExtent(WebExtent extent,
                               WebSpatialReference toSpatialReference)

Convenience method which projects the given WebExtent only if this context supports multiple SRs

Parameters:
extent - the WebExtent to be projected
toSpatialReference - the WebSpatialReference to project the extent to
Returns:
the projected WebExtent

projectExtent

public WebExtent projectExtent(WebExtent extent)

Convenience method which projects the given WebExtent to the spatial reference of this context only if this context supports multiple SRs

Parameters:
extent - the WebExtent to be projected
Returns:
the WebExtent projected in the SR of this context

projectPoint

public WebPoint projectPoint(WebPoint point,
                             WebSpatialReference toSpatialReference)

Convenience method which projects the given WebPoint only if this context supports multiple SRs

Parameters:
point - the WebPoint to be projected
toSpatialReference - the WebSpatialReference to project the point to
Returns:
the projected WebPoint

projectPoint

public WebPoint projectPoint(WebPoint point)

Convenience method which projects the given WebPoint to the spatial reference of this context only if this context supports multiple SRs

Parameters:
point - the WebPoint to be projected
Returns:
the WebPoint projected in the SR of this context

project

public WebGeometry project(WebGeometry geometry,
                           WebSpatialReference toSpatialReference)

Convenience method which projects the given WebGeometry only if this context supports multiple SRs

Parameters:
geometry - the WebGeometry to be projected
toSpatialReference - the WebSpatialReference to project the extent to
Returns:
the projected WebGeometry

project

public WebGeometry project(WebGeometry geometry)

Convenience method which projects the given WebGeometry to the spatial reference of this context only if this context supports multiple SRs

Parameters:
geometry - the WebGeometry to be projected
Returns:
the WebGeometry projected in the SR of this context

setName

public void setName(String name)

getName

public String getName()

getResourceId

public String getResourceId(GISResource resource)

getResourceById

public GISResource getResourceById(String resourceId)
Returns the resource from WebContext object based on the specified resource id.

Parameters:
resourceId - the resource id
Returns:
GISResource the resource

getDefaultGraphicsResource

public GraphicsResource getDefaultGraphicsResource()
Returns the default graphics resource that available in this object.

Returns:
the default GraphicsResource

getSpatialReferenceResourceId

public String getSpatialReferenceResourceId()
Returns the ID of the resource whose spatial reference should be used by the WebContext

Returns:
the ID of the resource whose spatial reference should be used by the WebContext

setDateFormat

public void setDateFormat(String dateFormat)
Parameters:
dateFormat - the dateFormat to set

getDateFormat

public String getDateFormat()
Returns:
the dateFormat

setNullValueDisplay

public void setNullValueDisplay(String nullValueDisplay)
Parameters:
nullValueDisplay - the nullValueDisplay to set

getNullValueDisplay

public String getNullValueDisplay()
Returns:
the nullValueDisplay

setSpatialReferenceResourceId

public void setSpatialReferenceResourceId(String spatialReferenceResourceId)
Sets the ID of the resource whose spatial reference should be used by the WebContext. The WebContext by default uses the spatial reference of the bottom-most resource. If instead, you want it to use the spatial reference of any other resource, you can use this method to set that ID of that resource.

Parameters:
spatialReferenceResourceId - the ID of the resource whose spatial reference should be used by the WebContext

setGeometryOperations

public void setGeometryOperations(GeometryOperations operations)
Specifies which implementation of GeometryOperations should be used. By default it uses an instance of WebGeometryOperations.

Parameters:
operations - the instance used for performing geometric operations