examples.wslauncher4
Class WebserviceLauncherImpl

java.lang.Object
  extended byde.fhg.igd.semoa.service.AbstractService
      extended byexamples.wslauncher4.WebserviceLauncherImpl
All Implemented Interfaces:
Service, WebserviceLauncher

public class WebserviceLauncherImpl
extends AbstractService
implements WebserviceLauncher

This service launches agent(s) via webservice. Dependent of the given XML-based control structure one agent migrates to the given list of web service delegates in a sequencial manner resp. agents migrate to the given web service delegates in parallel (see methode launch()).

Version:
$Id: WebserviceLauncherImpl.java 1913 2007-08-08 02:41:53Z jpeters $
Author:
C. Nickel, M. Sommer, J. Peters

Field Summary
private static String ADDITIONAL_EXCLUDES
          Additional package prefixes which shall not be imported into the agent
private static String AGENT_
          The class of the agent which shall be launched
private  Object lock_
          Lock object for synchronization.
private  Map syncmap_
          The syncmap_ is needed to coordinate the webservices and the agents.
private  long TIMEOUT
          Timeout for each thread to wait for the agent's return.
private static int TOKEN_LENGTH
          Length of the token which is used to synchronize agent and webservice.
 
Fields inherited from class de.fhg.igd.semoa.service.AbstractService
REV_POSTFIX, REV_PREFIX
 
Fields inherited from interface examples.wslauncher4.WebserviceLauncher
WHATIS, WS_NAME
 
Constructor Summary
WebserviceLauncherImpl()
          Constructor
 
Method Summary
 String author()
          Returns the name of the author of the service.
private  void callbackWS(String xmlControl, String ws_results, long docId)
           
 String info()
          Returns the informative string which should describe the service's essence in a sentence.
 void launch(String xmlControl, String xmlDoc, long docId)
          This method generates a token and stores it in the agent's properties as well as in the syncmap_.
static void main(String[] argv)
           
 void response(String answ, String token)
          Checks if the token is a key in the syncmap.
 String revision()
          Returns the revision number of this class as a string.
 
Methods inherited from class de.fhg.igd.semoa.service.AbstractService
checkDependencies, dependencies, docs, doPrivileged, doPrivileged, getACC, getEnvironment, majorVersion, minorVersion, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOKEN_LENGTH

private static int TOKEN_LENGTH
Length of the token which is used to synchronize agent and webservice. The token is a random string.


AGENT_

private static String AGENT_
The class of the agent which shall be launched


ADDITIONAL_EXCLUDES

private static String ADDITIONAL_EXCLUDES
Additional package prefixes which shall not be imported into the agent


TIMEOUT

private long TIMEOUT
Timeout for each thread to wait for the agent's return.


syncmap_

private Map syncmap_
The syncmap_ is needed to coordinate the webservices and the agents. When several webservices are running it ensures that the agent gives his response to the right one. The keys in the syncmap_ are the different tokens which are also stored in the properties of the agent. The values are the answers reported by the agents.


lock_

private Object lock_
Lock object for synchronization.

Constructor Detail

WebserviceLauncherImpl

public WebserviceLauncherImpl()
Constructor

Method Detail

launch

public void launch(String xmlControl,
                   String xmlDoc,
                   long docId)
This method generates a token and stores it in the agent's properties as well as in the syncmap_. It launches the agent named in AGENT_. Webservice and agent are synchronized via the token. To combine the request with the answer, the answer is assigned to the token in the syncmap_. The xmlDocument must be valid. It must contain the delegation properties. Example: concurrent raw://146.140.8.144:47471 http://PC1019:8080/webservice/services/Hello sayHello 12345 content The whole document except the conf-tag content will be the first parameter of the webservice. Within the conf-tag the delegation properties are defined. ws-flow: either "concurrent" (n Agent for n delegation - parallel) or "roundtrip" (1 Agent for n delegation - serial) ws-delegate: defines one webservice delegation as follow ws-host: SeMoA-conform address of the target host the agent should jump to ws-url: the webservice the agent should call from defined ws-host ws-method: method of the webservice to call ws-param: further parameters for the method; all parameter values must be inside a named tag even the name has no further relevance; parameters will be handed to the method in the given order

Specified by:
launch in interface WebserviceLauncher
See Also:
examples.wslauncher4.WebserviceLauncher#launch(String)

response

public void response(String answ,
                     String token)
Checks if the token is a key in the syncmap. The method then stores the answer in the resultmap under this key. It notifies the waiting webservice if and only if all results in the map are not null e.g. if all agents of the webservice-call did already receive.

Specified by:
response in interface WebserviceLauncher
Parameters:
answ - answer from the agent
token - token for the synchronization of the agent and the webservice launcher

callbackWS

private void callbackWS(String xmlControl,
                        String ws_results,
                        long docId)

info

public String info()
Description copied from class: AbstractService
Returns the informative string which should describe the service's essence in a sentence.

Specified by:
info in interface Service
Specified by:
info in class AbstractService
Returns:
the String with the service's short description.

author

public String author()
Description copied from class: AbstractService
Returns the name of the author of the service. The format to be used should be John Doe <jdoe@zilch.net>.

Specified by:
author in interface Service
Specified by:
author in class AbstractService
Returns:
the String with the author's name.

revision

public String revision()
Description copied from class: AbstractService
Returns the revision number of this class as a string. This class provides default implementations of methods majorVersion(), minorVersion based on the assumption that this method returns a revision string as generated by rcs(1) for the template "$Revision: 1.7 $/$Date: 2007-08-08 04:41:53 +0200 (Wed, 08 Aug 2007) $".

Specified by:
revision in class AbstractService

main

public static void main(String[] argv)
                 throws Exception
Throws:
Exception


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.