|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esri.adf.web.data.GISResource
public class GISResource
The GISResource is the base class that all resources supported by the ADF must extend. Out of the
box resources such as AGSMapResource
, AGSGeocodeResource
, AIMSMapResource
,
etc. all extend this class.
The GISResource
also maintains a java.util.Map
of named
GISFunctionality
s supported by this instance of the resource. Users can add a
functionality programmatically as such:
AGSMapResource ags1 = ...; <b>ags1.addFunctionality("map", new AGSMapFunctionality());</b>
It can also be added declaratively in JSF managed bean configuration files as such:
<managed-bean> <managed-bean-name>agsMap</managed-bean-name> <managed-bean-class>com.esri.adf.web.ags.data.AGSMapFunctionality</managed-bean-class> <managed-bean-scope>none</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>ags1</managed-bean-name> <managed-bean-class>com.esri.adf.web.ags.data.AGSMapResource</managed-bean-class> <managed-bean-scope>none</managed-bean-scope> ... <managed-property> <property-name>functionalities</property-name> ... <map-entries> <map-entry> <key>map</key> <value>#{agsMap}</value> </map-entry> </map-entries> </managed-property> </managed-bean>
This class implements callback methods declared in the WebContextInitialize
and
WebLifecycle
interfaces which get called at different phases of the ADF lifeycle.
Please refer to the documentation for these two interfaces for more detail. Sub-classes that want to do custom work
in addition to the work done by this class must do so by overriding the callbacks and making the super
calls appropriately. Here's a typical way to override the callback methods:
public class MyGISResource extends GISResource { .. public void init(WebContext context) { myInit(); super.init(context); } public void destroy() { myDestroy(); super.destroy(); } public void activate() { super.activate(); myActivate(); } public void passivate() { myPassivate(); super.passivate(); } .. }
The basic premise is that you want the super-class to initialize and activate itself first before you do your custom initialization and activation. And you want to do your custom cleanup (destroy) and passivation before letting the super-class cleanup and passivate itself.
Field Summary | |
---|---|
protected String |
alias
A reader friendly name for this resource |
protected WebContext |
context
The WebContext that maintains a reference to this resource |
protected WebSpatialReference |
defaultSpatialReference
The spatial reference associated with this resource. |
protected Map<String,GISFunctionality> |
functionalities
A named java.util.Map of GISFunctionality s supported by this instance of the resource. |
protected boolean |
hasFailedFunctionalities
|
protected boolean |
init
true if this resource has already been initialized |
Constructor Summary | |
---|---|
GISResource()
|
Method Summary | |
---|---|
void |
activate()
This method is called by the associated WebContext when the context itself is being activated. |
void |
addFunctionality(String name,
GISFunctionality functionality)
Adds the given functionality to the existing Map of functionalities. |
void |
destroy()
The cleanup (final) chores of the resource like releasing held resources must be performed in this method. |
String |
getAlias()
Returns a reader friendly name for this resource. |
WebSpatialReference |
getDefaultSpatialReference()
Returns the spatial reference associated with this resource. |
Map<String,GISFunctionality> |
getFunctionalities()
Returns the java.util.Map of named GISFunctionality s maintained by this resource. |
GISFunctionality |
getFunctionality(String name)
Returns the GISFunctionality maintained by this resource and referenced by the given name . |
WebContext |
getWebContext()
Returns the WebContext that maintains a reference to this resource. |
void |
init(WebContext webContext)
This method is called by the WebContext to initialize the resource. |
void |
passivate()
This method is called by the associated WebContext when the context itself is being passivated. |
void |
setAlias(String alias)
Sets a reader friendly name for this resource. |
void |
setFunctionalities(Map<String,? extends GISFunctionality> functionalities)
Sets the java.util.Map of named GISFunctionality s maintained by this resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected WebContext context
The WebContext
that maintains a reference to this resource
protected Map<String,GISFunctionality> functionalities
java.util.Map
of GISFunctionality
s supported by this instance of the resource.
protected boolean hasFailedFunctionalities
protected boolean init
true
if this resource has already been initialized
protected String alias
protected WebSpatialReference defaultSpatialReference
The spatial reference associated with this resource.
Resources should set this property in their respective init(WebContext)
methods.
Typically when geometries are passed to the GISFunctionality
s, they should be in the default spatial
reference of their resource. However, the functionalities themselves should also ensure that they are working with
geometries in the correct spatial reference. Or else they should use the project()
method on the
WebGeometry
to project it to the correct spatial reference before working on
it.
Also, MapFunctionality
s should ensure that they export the map in the spatial reference of the
WebMap
if set.
Constructor Detail |
---|
public GISResource()
Method Detail |
---|
public String getAlias()
Returns a reader friendly name for this resource.
It is a good practice for users to explicitly set an alias when the resource is created programmatically or declaratively. Resource providers should provide an auto-generated alias anyway in case users don't explicitly set an alias themselves.
public void setAlias(String alias)
Sets a reader friendly name for this resource.
It is a good practice for users to explicitly set an alias when the resource is created programmatically or declaratively. Resource providers should provide an auto-generated alias anyway in case users don't explicitly set an alias themselves.
alias
- a reader friendly name for this resourcepublic void init(WebContext webContext)
This method is called by the WebContext
to initialize the resource. This is typically called when the
context itself is initialized or when users add a new resource to the context by using the
WebContext.addResource(String, GISResource)
method. A GISResource
is usable
only after this method has been called.
This method iterates through all its supported GISFunctionality
s and calls the
GISFunctionality.initFunctionality(GISResource)
on them all.
Sub-classes that want to do custom initialization should override this method and make the super
call
first before doing the custom stuff:
public void init(WebContext context) { super.init(context); myInit(); }
init
in interface WebContextInitialize
webContext
- the WebContext
that maintains a reference to this resourceWebContextInitialize.init(com.esri.adf.web.data.WebContext)
,
GISFunctionality.initFunctionality(GISResource)
,
WebContext.init(WebContext)
,
WebContext.addResource(String, GISResource)
public void destroy()
The cleanup (final) chores of the resource like releasing held resources must be performed in this method. This is
typically called when the context itself is being destroyed or when users remove this resource from the context by
using the WebContext.removeResource(GISResource)
method. A GISResource
is unusable after this
method has been called.
This method iterates through all its supported GISFunctionality
s and calls the
GISFunctionality.destroyFunctionality()
on them all.
Sub-classes that want to do custom cleanup chores should override this method and do the custom cleanup first
before making the super
call:
public void destroy() { myDestroy(); super.destroy(); }
destroy
in interface WebContextInitialize
WebContextInitialize.destroy()
,
GISFunctionality.destroyFunctionality()
,
WebContext.destroy()
,
WebContext.removeResource(GISResource)
public void activate()
This method is called by the associated WebContext
when the context itself is being activated. This
typically happens when a new user request is received to perform a set of operations. A GISResource
is
available for the execution of these operations only after this method has been called.
This method iterates through all its supported GISFunctionality
s and calls the activate()
method on those functionalities that implement WebLifecycle
.
Sub-classes that want to do custom activation should override this method and make the super
call
first before doing the custom stuff:
public void activate() { super.activate(); myActivate(); }
activate
in interface WebLifecycle
WebLifecycle.activate()
,
WebContext.activate()
public void passivate()
This method is called by the associated WebContext
when the context itself is being passivated. This
typically happens after a user request to perform a set of operations has been serviced. A GISResource
is
unavailable for the execution of more operations after this method has been called.
This method iterates through all its supported GISFunctionality
s and calls the passivate()
method on those functionalities that implement WebLifecycle
.
Sub-classes that want to do custom passivation should override this method and do the custom passivation first
before making the super
call:
public void passivate() { myPassivate(); super.passivate(); }
passivate
in interface WebLifecycle
WebLifecycle.passivate()
,
WebContext.passivate()
public GISFunctionality getFunctionality(String name)
Returns the GISFunctionality
maintained by this resource and referenced by the given name
.
name
- the name of the GISFunctionality
to return
GISFunctionality
maintained by this resource and referenced by the given name
public Map<String,GISFunctionality> getFunctionalities()
Returns the java.util.Map
of named GISFunctionality
s maintained by this resource.
java.util.Map
of named GISFunctionality
s maintained by this resourcepublic void setFunctionalities(Map<String,? extends GISFunctionality> functionalities)
Sets the java.util.Map
of named GISFunctionality
s maintained by this resource.
Typically this java.util.Map
is set either declaratively in a JSF managed bean configuration file or
programmatically before this resource is initialized. Once the resource has been initialized, you should use the
addFunctionality(String, GISFunctionality)
method instead.
functionalities
- the java.util.Map
of named GISFunctionality
s maintained by this
resourceaddFunctionality(String, GISFunctionality)
public void addFunctionality(String name, GISFunctionality functionality)
Adds the given functionality to the existing Map of functionalities.
If the resource is already initialized, it also calls the initFunctionality(this)
method on this
functionality and passes it a reference to itself. If a functionality with the same name already exists, it logs a
warning message and replaces the existing functionality with this new functionality.
name
- the name of the GISFunctionality
functionality
- the GISFunctionality
to add to this resourcepublic WebContext getWebContext()
Returns the WebContext
that maintains a reference to this resource.
WebContext
that maintains a reference to this resourcepublic WebSpatialReference getDefaultSpatialReference()
Returns the spatial reference associated with this resource.
Resources should set this property in their respective init(WebContext)
methods.
Typically when geometries are passed to the GISFunctionality
s, they should be in the default spatial
reference of their resource. However, the functionalities themselves should also ensure that they are working with
geometries in the correct spatial reference. Or else they should use the project()
method on the
WebGeometry
to project it to the correct spatial reference before working on
it.
Also, MapFunctionality
s should ensure that they export the map in the spatial reference of the
WebMap
if set.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |