org.iids.aos.webservices.wsgateway
Class WSGatewayAgentModule.WSGatewayAgent

java.lang.Object
  extended by org.iids.aos.agent.Agent
      extended by org.iids.aos.webservices.wsgateway.WSGatewayAgentModule.WSGatewayAgent
All Implemented Interfaces:
java.io.Serializable, SystemService, WSGateway
Enclosing class:
WSGatewayAgentModule

public static class WSGatewayAgentModule.WSGatewayAgent
extends Agent
implements WSGateway

See Also:
Serialized Form

Field Summary
static java.lang.String REGISTRATION_KEY
           
 
Fields inherited from class org.iids.aos.agent.Agent
log
 
Fields inherited from interface org.iids.aos.systemservices.WSGateway
ERROR_COULD_NOT_PARSE_WSDL, ERROR_IO, ERROR_LEASE_EXPIRED, ERROR_MALFORMED_SOAP_REQUEST, ERROR_MALFORMED_URL, ERROR_NO_EXCLUSIVE_TRANSPORT, ERROR_UNKNOWN_PORT, WSGATEWAY_ADDRESS
 
Constructor Summary
WSGatewayAgentModule.WSGatewayAgent()
           
 
Method Summary
protected  void cleanUp()
          User definable cleanup of the agent before stopping.
 void pingService()
           
 void publishService(java.lang.String serviceName, AgentHandle publisher, java.lang.String className, byte[] jar)
           
 int requestWSDLAccess(java.lang.String wsdl, java.lang.String serviceName, java.lang.String serviceNameSpace, java.lang.Boolean exclTransport, AgentHandle handle)
          Called by an agent server (on behalf of an agent) to request access to a web service specified by a WSDL document.
 void run()
          To be implemented by the agent.
 java.lang.String sendSOAPRequest(java.lang.String request, java.lang.String portName, java.lang.Integer leaseID, AgentHandle handle)
          Called by an agent server (on behalf of an agent) to carry out a SOAP operation.
 void shutdown()
           
 void unbind()
           
 void unPublishService(java.lang.String serviceName)
           
 
Methods inherited from class org.iids.aos.agent.Agent
agentRunning, createAgentHandle, deregister, getAgentCPUtime, getAgentHandles, getApi, getArgs, getContext, getCurrentLocation, getLocations, getLocations, getLog, getOwnerHandle, getPrimaryHandle, getServlet, getServletNames, getToken, initAgent, kill, lookup, lookup, lookupPublished, lookupPublished, move, move, publish, publishServlet, receiveMessage, receiveMessage, receiveMessages, receiveMessages, register, removeAgentHandle, sendMessage, sendMessages, start, stopRunning, waitForCompletion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGISTRATION_KEY

public static final java.lang.String REGISTRATION_KEY
See Also:
Constant Field Values
Constructor Detail

WSGatewayAgentModule.WSGatewayAgent

public WSGatewayAgentModule.WSGatewayAgent()
Method Detail

run

public void run()
Description copied from class: Agent
To be implemented by the agent. This is the main method of the Agent. This method is called by AgentScape as soon as the agent starts.

Once this function finishes, the agent is done. This can be preceded by a successful call to move(AgentScapeID) if the agent should continue to run on another location. If no successful move was done beforehand, then the agent is removed from the location.

Note that it is assumed that, once an agent moved to another location, this method will finish soon afterwards. There is no protection against this (yet) however.

Any cleanup operations can be done by implementing Agent.cleanUp().

Specified by:
run in class Agent
See Also:
cleanup, move

requestWSDLAccess

public int requestWSDLAccess(java.lang.String wsdl,
                             java.lang.String serviceName,
                             java.lang.String serviceNameSpace,
                             java.lang.Boolean exclTransport,
                             AgentHandle handle)
                      throws org.apache.xmlrpc.XmlRpcException
Description copied from interface: WSGateway
Called by an agent server (on behalf of an agent) to request access to a web service specified by a WSDL document. As part of this call, the WS gateway creates a lease, which acts a context in which the agent interacts with the web service. Multiple leases may be requested for the same parameter set.

SOAP communicates over transport sessions whose protocols and contact points are specified in the WSDL document. (Typically these are HTTP sessions.) Some web services associate client state with the transport sessions. An agent may optionally specify that it requires the same transport sessions to be used consistently by this lease and that other leases (of other agents or of the same agent) cannot share the transport sessions.

Specified by:
requestWSDLAccess in interface WSGateway
Parameters:
wsdl - a URL pointing to a WSDL document
serviceName - the requested web service in the WSDL document
serviceNameSpace - the XML name space of serviceName
exclTransport - if true, the agent requires transport sessions to be maintained for the duration of the lease, not to be shared by other leases, and to use at most one transport session per web service port
handle - the agent identifier
Returns:
a lease ID
Throws:
org.apache.xmlrpc.XmlRpcException - containing one of: ERROR_MALFORMED_URL, ERROR_COULD_NOT_PARSE_WSDL, ERROR_NO_EXCLUSIVE_TRANSPORT

sendSOAPRequest

public java.lang.String sendSOAPRequest(java.lang.String request,
                                        java.lang.String portName,
                                        java.lang.Integer leaseID,
                                        AgentHandle handle)
                                 throws org.apache.xmlrpc.XmlRpcException
Description copied from interface: WSGateway
Called by an agent server (on behalf of an agent) to carry out a SOAP operation. The operation is carried out by sending a SOAP request to a web service and receiving the SOAP response.

Specified by:
sendSOAPRequest in interface WSGateway
Parameters:
request - a SOAP envelope containing the request, including the name of the operation
portName - port inside the web service that contains the SOAP operation
leaseID - a lease identifier returned by requestWSDLAccess
handle - the agent identifier, which must correspond to the agent identifier passed to requestWSDLAccess
Returns:
a SOAP envelope containing the response
Throws:
org.apache.xmlrpc.XmlRpcException - containing one of: ERROR_LEASE_EXPIRED, ERROR_UNKNOWN_PORT, ERROR_MALFORMED_SOAP_REQUEST, ERROR_IO

publishService

public void publishService(java.lang.String serviceName,
                           AgentHandle publisher,
                           java.lang.String className,
                           byte[] jar)
                    throws WSGatewayException
Specified by:
publishService in interface WSGateway
Throws:
WSGatewayException

unPublishService

public void unPublishService(java.lang.String serviceName)
                      throws WSGatewayException
Specified by:
unPublishService in interface WSGateway
Throws:
WSGatewayException

unbind

public void unbind()
Specified by:
unbind in interface SystemService

shutdown

public void shutdown()
              throws java.lang.UnsupportedOperationException
Specified by:
shutdown in interface SystemService
Throws:
java.lang.UnsupportedOperationException

pingService

public void pingService()
Specified by:
pingService in interface SystemService

cleanUp

protected void cleanUp()
Description copied from class: Agent
User definable cleanup of the agent before stopping. This method is called by the method Agent.stopRunning(), which is called by AgentScape whenever the agent moves or is (being) killed. An Agent-developer can override this method to perform any cleanup necessary before the agent is stopped permanently, such as stopping any threads this agent has created or removing any windows that have been put on the screen.

This method may not throw any Exceptions.

Overrides:
cleanUp in class Agent


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.