That's about my implementation - only thing I couldn't read out of the pseudo code is, that whenever you give back the Dispatch object out of your container, it still calls upon addStatusListener. So it's possible that one Dispatch object has multiple StatusListeners, isn't it? If so I'd have to build up a container that holds the corresponding Listeners for a specific Dispatch object, right?

Carsten Driesner schrieb:
Hi Jimmy,

I am not sure if I understand your current problem. First you should assure that you provide one dispatch object for a command. AddStatusListener is called by user every interface elements which is bound to the command. That means you have no influence when or how often addStatusListener is called. Therefore a dispatch object must maintain a container for the listeners which can add themselves via addStatusListener.

The logical structure (pseudo code!) should look like:

DispatchObject::addStatusListener( XStatusListener xStatusListener )
{
  // Add new listener to my listener container
  ListenerContainer.add( xStatusListener );

  // Create current state event
  FeatureStateEvent aFeatureStateEvent;
  aFeatureStateEvent.State = aState;
  ...

  // send current status to the new listener
  xStatusListener.statusChanged( aFeatureStateEvent );
}

void DispatchObject::removeStatusListener( XStatusListener xStatusListener )
{
  // remove status listener from my container
  ListenerContainer.remove( xStatusListener );
}

XDispatch XDispatchProvider::queryDispatch( URL aURL, ... )
{
  if ( aURL.Protocol.equalsAscii( "myprotocol:" ))
  {
    // Look for a previously created dispatch object
    dispatchObject = container[aURL];
    if ( dispatch == null )
    {
      // create on demand new dispatch object
      dispatchObject = new DispatchObject( aURL );
      container[aURL] = dispatchObject;
    }
    return dispatchObject;
  }

  return null;
}

Regards,
Carsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to