ArcGIS Server Java ADF case study 41

Source: Internet
Author: User
Chapter 1 extended ArcGIS Server

This chapter does not actually have much to do with the ADF. It is also in the ArcGIS Server development chapter with the help of ArcGIS. Considering that the feature requirements for developing with the ADF are a little more, you may be concerned about how to expand the ArcGIS Server. In any case, the ADF is almost finished. This chapter is an end.

Starting from 9.3.1, ArcGIS Server provides more scalability for Java developers. By extending ArcGIS Server, you can make some custom functions more comprehensive and powerful, make some of your work more modular, and work well together with ArcGIS Server. Next let's take a look at how ArcGIS Server can be expanded.

Utility objects

Utility objects is mainly used to improve the performance of some operations of ArcGIS Server in local connection. Before that, let's first understand the process and features of calling the AO object on the server side by using the ADF.

Figure
29. Process of calling server-side objects using the ADF

As shown in Figure 29, when a user requests, the ADF will first interact with SOM (1 in the figure); som will assign a so based on the server situation to process the user's request, at the same time, the so proxy is returned to the ADF (2 in the figure below). Then, the ADF interacts with the so of the server through this proxy (3 in the figure, note, this is the interaction between the ADF application and the GIS server, which is cross-process). When the request is complete, the ADF releases the corresponding resources for other users (figure 4 ).

Cross-process calls consume a large amount of system resources, resulting in slow response. When the ADF application and GIS server are deployed separately, there is also a corresponding network overhead. Therefore, when your ADF application has a large number of fine-grained operations and frequently calls the server-side AO object, the performance will be very low. Utility objects was born to solve this problem.

The principle of utility objects is to merge the operations in the processes of the ADF and GIS servers into the ArcGIS Server for execution, which can greatly reduce the communication overhead between processes. Utility objects is not complex in implementation. You only need to encapsulate the functions directly implemented in the ADF into a class that implements the custom interface, then, you can call this custom function class in the ADF. Let's take a look at this general process. In the help of ArcGIS Server, an example is provided: encapsulate the function of calculating the total area of all polygon in a featurelayer into a utility object.

First, we need to define an interface icalculatearea and use the calcareautil class to implement this interface. Note that the utility object interfaces and classes must be declared using the "@ arcgisextension" Note:

@ Arcgisextension

Public
Interface
Icalculatearea

{

Public
Double
Calculatearea (ifeaturelayer featurelayer)

Throws
Ioexception, automationexception;

}

@ Arcgisextension

Public
Class
CalcareautilImplements
Icalculatearea

{

Public
Double
Calculatearea (ifeaturelayer featurelayer)

{

Double
Totalarea = 0;

Ifeatureclass featureclass = featurelayer. getfeatureclass ();

Int
Numfeatures = featureclass. featurecount (Null
);

Ifeaturecursor featurecursor = featurelayer. Search (Null
,True
);

Ifeature feature =Null
;

Polygon polygon =Null
;

For
(Int
I = 0; I <numfeatures; I ++)

{

Feature = featurecursor. nextfeature ();

Polygon = (polygon) feature. getshape ();

Totalarea + = polygon. getarea ();

}

Return
Totalarea;

}

}

There are two ways to deploy this utility object. Of course, as a lazy person, I prefer a relatively simple and green method: Compile the class implemented above into a jar package, copy the jar package to the % arcgishome %/Java/lib/EXT directory on the server. Another method is more complicated and seems a little dirty to me. If you are interested, you can find it in the help document.

Okay. Now we can use this utility object:

Ifeaturelayer featurelayer = mapserver. getlayer ("", 2 );

Icalculatearea calarea = (icalculatearea)

Com. ESRI. ArcGIS. server. servercontext. Createobject (calcareautil.Class
);

Double
Totalarea = calarea. calculatearea (featurelayer );

In this code, we can see that the function of "calculating the total area of polygon in a featurelayer" is all implemented by the calcareautil class on the GIS server. In the ADF, you only need to use iservercontext to instantiate this class, call the corresponding method.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.