Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.miamm.soapmmil
Class MIAMMServiceEngine  view MIAMMServiceEngine download MIAMMServiceEngine.java

java.lang.Object
  extended byorg.miamm.soapmmil.MIAMMServiceEngine
All Implemented Interfaces:
SoapMMILConstants, org.miamm.soapmmil.engine.WayAdapter

public class MIAMMServiceEngine
extends java.lang.Object
implements org.miamm.soapmmil.engine.WayAdapter, SoapMMILConstants

The back-end to MIAMMService. This class does all the work that allows your service to interact with other MIAMM services. FIXME: What i want to do is to create a super effecient custom SOAP implementation that doesn't have all the overhead of marshalling and unmarshalling SOAPElement, but to do so means tearing some more code, cleaning things up more

Version:
$Revision: 1.29 $
$Date: 2003/05/06 13:43:08 $

Field Summary
(package private)  java.util.Set _awaiting
           
(package private)  ResponsesTable _awaitTable
           
private  org.miamm.soapmmil.engine.AxisWay _axisWay
           
private  MIAMMServiceEngine _engine
           
(package private) static org.apache.log4j.Logger _logger
           
private  long _msgIdCounter
           
private  MIAMMService _service
           
(package private) static int BIG_SLEEP
           
(package private) static boolean DEBUG_THREADS
           
(package private) static long DEFAULT_TIMEOUT
           
(package private) static int MINI_SLEEP
           
(package private) static int NORMAL_SLEEP
           
(package private) static java.lang.String UCLASSNAME
           
 
Fields inherited from interface org.miamm.soapmmil.SoapMMILConstants
ELEMENT_MISOH_BLOCK, LOG4J_PROPERTY, misohDescriptor, NAMESPACE_PREFIX_MIAMM, NAMESPACE_URI_MIAMM, PROPERTY_MIAMM_SMART_RECEIVER, PROPERTY_MIAMM_URLFILE
 
Constructor Summary
MIAMMServiceEngine(MIAMMService service)
           
 
Method Summary
 void acceptEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Deprecated. Use allowEventType instead (the name "acceptEventType" causes confusion)
 void allowEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Include an event type in the list of event types that we are interested in receiving.
 SoapmmilMessage awaitResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh)
           
 SoapmmilMessage awaitResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh, long timeout)
           
 SoapmmilMessage awaitResponse(SoapmmilMessage message)
          Block until we receive the response to the message in SoapmmilMessage parameter.
 SoapmmilMessage awaitResponse(SoapmmilMessage message, long timeout)
           
private  SoapmmilMessage awaitResponse(java.lang.String msgId, long timeout)
           
 org.miamm.castor.headerblock.MiammSoapHeaderBlock createMessage(org.miamm.castor.headerblock.types.MsgRoleType msgType, org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Deprecated. use fireMessage(SoapmmilMessage) instead
protected  java.lang.String createMsgId()
          Creates and returns a unique message ID.
 org.miamm.castor.headerblock.MiammSoapHeaderBlock createResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock msgRef, org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Deprecated. use fireMessage(SoapmmilMessage) instead
 void disallowEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Exclude an event type from the list of event types that we are interested in receiving.
private  void doRecogniseEvent(SoapmmilMessage message)
          Call the recogniseEvent function of our service.
 void fireMessage(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh, org.xml.sax.InputSource contents)
          Deprecated. use fireMessage(SoapmmilMessage) instead
 void fireMessage(SoapmmilMessage message)
          Fires a message into the ether.
(package private)  MIAMMService getService()
           
 java.lang.String getServiceName()
          Returns the name of the associated service.
 boolean isAwaiting(java.lang.String msgId)
          Returns true if this service is waiting for a response on a message with id msgId
private  void logDebug(java.lang.String message)
           
 void receiveBySAAJ(javax.xml.soap.SOAPEnvelope requestEnvelope, javax.xml.soap.SOAPEnvelope responseEnvelope)
          Interface between Axis and the SoapMMIL.
 void receiveMessage(SoapmmilMessage message)
          Determines if the incoming message should be handled via the await mechanism or normally.
 void rejectEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
          Deprecated. Use disallowEventType instead (the name "rejectEventType" causes confusion)
 void setActive(boolean active)
          If you set this to false, your service will not process any messages in the queue.
private  void setAwaitable(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh, boolean awaitable)
          Deprecated. use setAwaitable(String, boolean) instead... we're trying to move away from MiammSoapHeaderBlock in the hopes of generalising and improving the soapmmil
 void setAwaitable(java.lang.String msgId, boolean awaitable)
          Toggles the awaitability of a message.
 void setRefuseCalls(boolean refuse)
          If you set this to true, your service will reject any incoming messages and throw a SOAP fault whenever it receives one.
protected  void stampMessage(SoapmmilMessage message)
          Sets the message's ID and sender if they have not already been set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UCLASSNAME

static final java.lang.String UCLASSNAME
See Also:
Constant Field Values

_logger

static org.apache.log4j.Logger _logger

_service

private MIAMMService _service

_msgIdCounter

private long _msgIdCounter

_engine

private MIAMMServiceEngine _engine

_axisWay

private org.miamm.soapmmil.engine.AxisWay _axisWay

_awaiting

java.util.Set _awaiting

_awaitTable

ResponsesTable _awaitTable

DEFAULT_TIMEOUT

static final long DEFAULT_TIMEOUT
See Also:
Constant Field Values

MINI_SLEEP

static final int MINI_SLEEP
See Also:
Constant Field Values

NORMAL_SLEEP

static final int NORMAL_SLEEP
See Also:
Constant Field Values

BIG_SLEEP

static final int BIG_SLEEP
See Also:
Constant Field Values

DEBUG_THREADS

static final boolean DEBUG_THREADS
See Also:
Constant Field Values
Constructor Detail

MIAMMServiceEngine

public MIAMMServiceEngine(MIAMMService service)
Method Detail

allowEventType

public void allowEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
Include an event type in the list of event types that we are interested in receiving. This function should be called at the end of your constructor. FIXME: this is too specific... what we need is some kind of general filtering mechanism, some kind of incomplete XML message template we can check agaist. acceptEventType would then be a wrapper function specific to MIAMM


disallowEventType

public void disallowEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
Exclude an event type from the list of event types that we are interested in receiving. You do not need to call this function unless you have previously allowed this event type, and you want to stop doing so.


acceptEventType

public void acceptEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
Deprecated. Use allowEventType instead (the name "acceptEventType" causes confusion)

Include an event type in the list of event types that we are interested in receiving. This function should only be called from init FIXME: this is too specific... what we need is some kind of general filtering mechanism, some kind of incomplete XML message template we can check agaist. acceptEventType would then be a wrapper function specific to MIAMM


rejectEventType

public void rejectEventType(org.miamm.castor.headerblock.types.MsgContentType msgContent)
Deprecated. Use disallowEventType instead (the name "rejectEventType" causes confusion)

Exclude an event type from the list of event types that we are interested in receiving. You do not need to call this function unless you have previously accepted this event type, and you want to stop doing so.


setRefuseCalls

public void setRefuseCalls(boolean refuse)
If you set this to true, your service will reject any incoming messages and throw a SOAP fault whenever it receives one. You can resume accepting calls as normal by setting this to false.

FIXME: we don't actually throw the SOAP fault yet... right now we just log the error and do nothing. Throwing the SOAP fault would require thinking about how we play with all this request-response stuff, which would also require looking into JAXM and thinking (hard) about how this would fit in with the fire and forget ethos of SoapMMIL (for example, what happens it broadcasted messages?).


setActive

public void setActive(boolean active)
If you set this to false, your service will not process any messages in the queue. You can set this back to true to resume processing. Messages will continue building in the queue unless you also setRefuseCalls


fireMessage

public void fireMessage(SoapmmilMessage message)
                 throws MIAMMException
Fires a message into the ether. Theoretically, you don't care where the message goes to and what happens to it, just that it actually gets somewhere.


createMessage

public org.miamm.castor.headerblock.MiammSoapHeaderBlock createMessage(org.miamm.castor.headerblock.types.MsgRoleType msgType,
                                                                       org.miamm.castor.headerblock.types.MsgContentType msgContent)
Deprecated. use fireMessage(SoapmmilMessage) instead

Produces the header block for an outgoing message.


createResponse

public org.miamm.castor.headerblock.MiammSoapHeaderBlock createResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock msgRef,
                                                                        org.miamm.castor.headerblock.types.MsgContentType msgContent)
Deprecated. use fireMessage(SoapmmilMessage) instead

Produces the header block for an outgoing message which is responding to an earlier message. This is really just a convenience function.


fireMessage

public void fireMessage(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh,
                        org.xml.sax.InputSource contents)
                 throws MIAMMException
Deprecated. use fireMessage(SoapmmilMessage) instead


receiveBySAAJ

public void receiveBySAAJ(javax.xml.soap.SOAPEnvelope requestEnvelope,
                          javax.xml.soap.SOAPEnvelope responseEnvelope)
                   throws javax.xml.soap.SOAPException
Interface between Axis and the SoapMMIL. Whenever AXIS receives a message that is destined towards our MIAMMService, it will call this function


receiveMessage

public void receiveMessage(SoapmmilMessage message)
                    throws MIAMMException
Determines if the incoming message should be handled via the await mechanism or normally.

Specified by:
receiveMessage in interface org.miamm.soapmmil.engine.WayAdapter

doRecogniseEvent

private void doRecogniseEvent(SoapmmilMessage message)
                       throws MIAMMException
Call the recogniseEvent function of our service. Any errors here are reported but not thrown; they are likely the user's fault and not mine


awaitResponse

public SoapmmilMessage awaitResponse(SoapmmilMessage message)
Block until we receive the response to the message in SoapmmilMessage parameter. Your service will continue receiving other input and responses, but the first response to the indicated message will be returned as a SoapmmilMessage here.

Important: this will time out after a default of several minutes. You can use the two-parameter version of this function if you want to set no timeout, or a different timeout

Note: This function calls setAwaitable(true) for you, so you don't need to do anything

Note: to extract any further responses to the indicated message, you'll have to call the awaitResponse function again. Otherwise, if you want to receive all further responses normally via the recogoniseEvent mechanism, you should call setAwaitable(false)

TODO: if it is deemed useful, provide a means to wait exclusively for a response


awaitResponse

public SoapmmilMessage awaitResponse(SoapmmilMessage message,
                                     long timeout)

awaitResponse

public SoapmmilMessage awaitResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh)

awaitResponse

public SoapmmilMessage awaitResponse(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh,
                                     long timeout)

awaitResponse

private SoapmmilMessage awaitResponse(java.lang.String msgId,
                                      long timeout)

setAwaitable

private void setAwaitable(org.miamm.castor.headerblock.MiammSoapHeaderBlock misoh,
                          boolean awaitable)
Deprecated. use setAwaitable(String, boolean) instead... we're trying to move away from MiammSoapHeaderBlock in the hopes of generalising and improving the soapmmil


setAwaitable

public void setAwaitable(java.lang.String msgId,
                         boolean awaitable)
Toggles the awaitability of a message. When a message is awaitable all responses to that message will be put into a seperate queue, from which you will have to pull the responses by calling awaitResponse. Otherwise, responses to that message will be handled through the recogniseEvent mechanism.


isAwaiting

public boolean isAwaiting(java.lang.String msgId)
Returns true if this service is waiting for a response on a message with id msgId


logDebug

private void logDebug(java.lang.String message)

getServiceName

public java.lang.String getServiceName()
Returns the name of the associated service. For WayAdapter

Specified by:
getServiceName in interface org.miamm.soapmmil.engine.WayAdapter

stampMessage

protected void stampMessage(SoapmmilMessage message)
Sets the message's ID and sender if they have not already been set


createMsgId

protected java.lang.String createMsgId()
Creates and returns a unique message ID. This is a helper function for createMessage

Ideally, we would like this guarantee of uniqueness to work globally across all services that are plugged together; but for the sake for early implementation, we can only guarantee uniqueness in so far as the names for each service is unique. Since we can not guarantee that the names of each service is unique, we can't really guarantee that the message IDs will be unique. However, since we are only using this in the context of the MIAMM project, and we can control what all the service names will be, this is okay.


getService

MIAMMService getService()