[Zoo-discuss] Doubts about java services

andrea antonello andrea.antonello at gmail.com
Tue Nov 11 12:46:24 PST 2014


Hi Gerald,
thanks for the reply.

I created a small and simple java wps service that has also a
dependency library.

You can find everything here:
http://ge.tt/1TmhSI42?c

The files are:

* dtm.asc
* dtm.prj
* dtm.sld

which is a very small raster file. It is small but works well. This
has to be used as input map.

* org.zip

which is the folder of the compiled service class ZooJavaWps.
I made ZooJavaWps on purpose inside a package, since that is the most
probable confguration in reality.

* zoo_java_dependency.jar

A jar library which represents the dependency. Inside here we have a
Class that is called from the ZooJavaWps class.

* ZooJavaBuilder.zcfg

The zoo configuration file.

I didn't implement the status update yet, because I didn't have a
compiles trunk version of zoo, so I was missing the necessary ZOO
class.

Please let me know if this is ok to be used as sample zoo-service.
I think there is everything in there.

Cheers,
Andrea










On Wed, Nov 5, 2014 at 1:34 PM, Fenoy Gerald <gerald.fenoy at geolabs.fr> wrote:
> Hello Andrea,
> sorry for answering this question lately.
>
>
>> Le 29 oct. 2014 à 01:12, andrea antonello <andrea.antonello at gmail.com> a écrit :
>>
>> Hi everyone,
>> I am trying to understand how to expose java modules as WPS service
>> and need some pointers to get started.
>>
>> In the docs related to java, I find a class and a config file, but no
>> real documentation about them.
>>
>
> I just quickly updated the Java documentation at [1] to reflect the latest modifications made for the Java support.
>
>> Given the class from the documentation:
>>
>> public class HelloJava {
>> 29    public static int HelloWorldJava(HashMap conf,HashMap inputs,
>> HashMap outputs) {
>> 30        HashMap hm1 = new HashMap();
>> 31        hm1.put("dataType","string");
>> 32        HashMap tmp=(HashMap)(inputs.get("S"));
>> 33        String v=tmp.get("value").toString();
>> 34        hm1.put("value","Hello "+v+" from JAVA World !!");
>> 35        outputs.put("Result",hm1);
>> 36        return 3;
>> 37  }
>> 38}
>>
>> I find in the config:
>>
>> 1[HelloWorldJava]
>> 2 Title = Display a string
>> 3 Abstract = Display a string which contains an hello message
>> 4 processVersion = 1
>> 5 storeSupported = true
>> 6 statusSupported = true
>> 7 serviceProvider = HelloJava
>> 8 serviceType = Java
>>
>> So line 1 seems to represent the method to execute, right? -> [HelloWorldJava]
>
> Correct.
>
>> While line 7 seems to represent the class name? -> serviceProvider = HelloJava
>
> Correct.
>
>> Does this mean that it is on line 7 that the fully qualified name goes
>> and that the example has been made without a package?
>> Ex: org.jgrasstoools.modules.whatevergisdoit
>
> Yes, it should work for package too.
> Note that the ZOO-Kernel define simply the CLASSPATH by using the directory of you ServiceProvioder (which can be the same directory as the ZOO-Kernel or subdirectory, for calling service using Identifier jgrasstools.MyService for MyService public method defined in a class located in the jgrasstools). You should probably use global environment variables to overwrite this value as it is doable in Python language (and required sometime like when using ZOO-Kernel on windows for instance).
>
>>
>> Also I figured there should be the possibility to pass the processing
>> progress on to the client. Can this be done from java, I do not see
>> any way in the class?
>
> So, the answer at the time you sent this email was no you cannot. But after discussing we decided to add this capability. So finally yes, from the Java language you can now use the ZOO-API to update the current status of a running process. I published a simple example (something similar to the longProcess example for other languages) here [2] illustrating its use.
>
>>
>> Last question. If I for example am simply reading a raster and
>> producing a new raster as output, then basically I will have no
>> output, right. There will be two string inputs defining the input and
>> output map (I am using geotools for IO, not gdal). Is that right?
>
> For each ZOO-Service, you need to define at least one process output, which can be simply a file name of the produced file for instance.
>
>>
>> Last last question.
>> storeSupported = true
>> statusSupported = true
>> what do these two mean. I have some idea, but would love to hear the truth. :-)
>>
>
> Well, this define if your ServiceProvider support to store its result (storeSupported). Indeed, WPS define the optional parameter storeExecuteResult which can take the value true or false and define if the WPS Server should store the result or not. I have to admit that whatever you will define here, as it is transparent to the Service implementation in the ZOO-Project implementation of WPS, the ZOO-Kernel will always be able to store the result and will do.
>
> For the second one, it should define if your Service is able to report its status. Nevertheless, one more time, ZOO-Kernel is handling status in a way that even if there is no update, it still works, so whatever you defined here, the client can call your service to be run as a background task (when both storeExecuteResponse and status are set to true).
>
>> Thanks,
>> Andrea
>>
>>
>> PS: on the page: http://zoo-project.org/docs/services/zcfg-reference.html
>> The link "ZOO-Project SVN source tree" is broken.
>
> Thanks for completeness, this was fixed in r529 [3].
>
> As you pointed out, I still have to fix this issue [4] for the Java support.
>
> Best regards,
>
>
> Gérald Fenoy
> http://wiki.osgeo.org/wiki/User:Djay
>
>
>
>
> [1] http://www.zoo-project.org/docs/services/howtos.html#java
> [2] http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/hello-java/HelloJava.java#L38
> [3] http://zoo-project.org/trac/changeset/529
> [4] http://zoo-project.org/trac/ticket/105


More information about the Zoo-discuss mailing list