Hi, here are answers to your questions on writing a STAF Java Service.

- Is there a difference between a service request, and a message on the 
Queue for the service?

Yes, they are completely different.  Read on.

- Are requests to my service placed on the Queue for my service handle by 
STAFProc ?

No, service requests are not placed on a service's handle "queue".  Read 
on.

- Does STAFProc run my service on multiple threads to handle multiple 
requests?

Not exactly.  STAFProc does not "run your service on multiple threads". 
Read on for an example of STAF service request flow.  A service's 
acceptRequest() method is invoked on a different thread simultaneously. 
Note that a STAF Java service must implement the 
STAFServiceInterfaceLevel30 interface and provide init(), cceptRequest(), 
and term() methods.  Read section "3.0 Service Overview" in the "STAF 
Service Developer's Guide" at 
http://staf.sourceforge.net/current/stafsdg.html#Header_Intro for more 
information on the 5 phases in the life cycle of a STAF service. The STAF 
service proxies do not externalize all of these phases (for example, for 
Java services the construction and deconstruction phases are not 
externalized). When creating a custom STAF Java service, you will be 
adding code to the Initialization and Accepting Requests phases of the 
life cycle, and possibly the termination phase. 

- Is my service class instanciated at every request?

No.  Here's an example of STAF service request flow.  Say on machine A 
running Windows, a STAF request "GENERATE TYPE Build SUBTYPE MyProduct_V4" 
is initiated by a Perl program to the Event Java service on machine B 
running Linux. 
- Step 1:  The Perl interpreter passes the request to the Perl API layer 
of STAF.
- Step 2:  The Perl API layer passes the request to the C API layer of 
STAF.
- Step 3:  The C API layer makes the interprocess communication (IPC) 
request to the STAFProc daemon process. At this point the STAFProc daemon 
determines that the request is destined for another system, which 
initiates step 4.
- Step 4:  A network IPC request to the STAFProc daemon on machine B. The 
STAFProc daemon on machine B determines that the request is bound for the 
Event Java service. This leads to step 5.
- Step 5:  The request is passed to the Java service proxy layer
- Step 6:  The Java service proxy layer communicates directly with the JVM 
and sends it the request.
- Step 7:  The JVM invokes the corresponding method on the Event Java 
service object (i.e. acceptRequest() method).
- Step 8:  Upon receiving the request, the Event Java service's 
acceptRequest() method determines which request it is receiving and passes 
the request string to the STAF request parser for validation. At this 
point the Event Java service would perform the indicated request and steps 
1 through 7 would be reversed as the result was passed back to the Perl 
program on machine B. Note that this is the only step of this service 
request flow that your Java service is responsible for implementing.

- How does STAFProc internally handle 100's of requests say to my service?

- It handles each STAF service request as described above.

Of course, it won't be the Perl interpreter/ Perl API layer passing the 
request to the C API layer of STAF if a Perl program didn't initiate a 
STAF service request.  A STAF service request could be initiated instead 
from a Java, C/C++, Python, or Tcl program, or from a shell script, or the 
command line, or a via a STAX job (e.g via Java). 

- Can a service request have a time-out?

Some existing STAF service requests have implemented a time-out by 
implementing a TIMEOUT option (or a WAIT option), so your Java service 
could implement a time-out for a request it handles.  For example:
- The SEM service's REQUEST MUTEX request implements a TIMEOUT option. See 
the STAF User's Guide for more information. REQUEST MUTEX <Name> [TIMEOUT 
<Number>[s|m|h|d|w]].
-The FSExt service (an external Java service) implements a TIMEOUT 
<Timeout> for its WAITFORFILE request.  See the FSExt Service User's Guide 
at http://staf.sourceforge.net/current/FSExt.html#Header_23 for more 
information.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




clayton neal <clayton_n...@yahoo.co.uk> 
02/18/2010 06:38 AM

To
Sharon Lucas/Austin/i...@ibmus
cc
staf <staf-users@lists.sourceforge.net>
Subject
[staf-users] Writng Java Service : Questions







Hiya STAF people!

Ive a few questions regarding writing my own Java service:

- Is there a difference between a service request, and a message on the 
Queue for the service?

- Are requests to my service placed on the Queue for my service handle by 
STAFProc ?

- Does STAFProc run my service on multiple threads to handle multiple 
requests?

- Is my service class instanciated at every request?

- How does STAFProc internally handle 100's of requests say to my service?

- Can a service request have a time-out?

Thanks

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to