ADK CVS

tryllian.webservices.gateway
Class HabitatGateway

java.lang.Object
  extended bytryllian.webservices.gateway.HabitatGateway
All Implemented Interfaces:
tryllian.are.messenger.DeliveryFailureHandler, tryllian.are.messenger.MessageReceiver
Direct Known Subclasses:
SimpleTupleGateway

public class HabitatGateway
extends java.lang.Object
implements tryllian.are.messenger.MessageReceiver, tryllian.are.messenger.DeliveryFailureHandler

This class is a gateway: subclass it to create a class that behaves like a web service but it can forward calls to the webservice as an agent message via a StandaloneMessenger. It is designed to run using Axis in Tomcat, but may very well work in other servlet containers.

Take the following steps to use this class as a webservice:

  1. install Tomcat (see http://jakarta.apache.org/tomcat) (4.0.6 works)
  2. install Axis (see http://xml.apache.org/axis) (1.0 beta3 works)
  3. copy ARE files to the tomcat lib dir
  4. compile this file and subclasses, jar it and place it in the Axis lib dir
  5. deploy this file in Axis by running:
    java org.apache.axis.client.AdminClient deploy.wsdd
    It is important to deploy the service with scope=Application to generate only one instance for all requests. (The StandaloneMessenger won't allow more than one instance per VM XXX CHECK).

The deployment descriptor should look somewhat like this:

 
     
       
       
       
     
 
 

This class currently uses a property file for it's settings, this can probably be moved to a web.xml file...

See Also:
SimpleTupleGateway, tryllian.webservices.gateway.examples.Temperatureconverter

Constructor Summary
HabitatGateway()
          Create a new gateway - default constructor - needed to run this class as a webservice.
HabitatGateway(tryllian.are.messenger.standalone.StandaloneMessengerProperties props)
          Create a new gateway.
 
Method Summary
 tryllian.are.messenger.MessageFactory getMessageFactory()
          Get the message factory.
 void handleMessage(Message msg)
          Handle an incoming message
 void localDeliveryFailed(tryllian.are.messenger.DeliveryFailure details)
          Called whenever an envelope could not be delivered for local reasons
 void remoteDeliveryFailed(tryllian.are.messenger.DeliveryFailure details)
          Called whenever an envelope could not be delivered for remote reasons
 Message sendAndReceiveMessage(OutgoingMessage msg, long timeOut)
          Sends a message and waits for the answer (blocking call).
 void sendMessage(OutgoingMessage msg)
          Sends a message - this version does not wait for an answer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HabitatGateway

public HabitatGateway()
               throws java.io.IOException,
                      java.security.GeneralSecurityException
Create a new gateway - default constructor - needed to run this class as a webservice. It will create a messenger.properties file in the Tomcate basedir if none exists.


HabitatGateway

public HabitatGateway(tryllian.are.messenger.standalone.StandaloneMessengerProperties props)
               throws java.io.IOException,
                      java.security.GeneralSecurityException
Create a new gateway.

Method Detail

getMessageFactory

public tryllian.are.messenger.MessageFactory getMessageFactory()
Get the message factory.


sendMessage

public void sendMessage(OutgoingMessage msg)
Sends a message - this version does not wait for an answer.


sendAndReceiveMessage

public Message sendAndReceiveMessage(OutgoingMessage msg,
                                     long timeOut)
Sends a message and waits for the answer (blocking call). If the call times out or an exception occured during the call it will return null.

Parameters:
timeOut - timeout in milliseconds, -1 means no timeout.

handleMessage

public void handleMessage(Message msg)
Handle an incoming message

Specified by:
handleMessage in interface tryllian.are.messenger.MessageReceiver

localDeliveryFailed

public void localDeliveryFailed(tryllian.are.messenger.DeliveryFailure details)
Called whenever an envelope could not be delivered for local reasons

Specified by:
localDeliveryFailed in interface tryllian.are.messenger.DeliveryFailureHandler

remoteDeliveryFailed

public void remoteDeliveryFailed(tryllian.are.messenger.DeliveryFailure details)
Called whenever an envelope could not be delivered for remote reasons

Specified by:
remoteDeliveryFailed in interface tryllian.are.messenger.DeliveryFailureHandler

Copyright 2005, Tryllian Solutions B.V.