2 Replies Latest reply on Jan 30, 2011 7:33 PM by kcbabo

    Some rework of the API

    kcbabo

      Tom and I have been discussing some changes to the core API based on his experience with it so far.  I have taken a whack at a couple of the changes we discussed and posted them in a branch in my repo:

      https://github.com/kcbabo/core/commits/contextphase

       

      From the commit notes:

      Clean-up and minor improvements to API:
        o Dumped the idea of Context with scopes.  Message now has a context accessor directly on the interface.
        o Added ExchangePhase to explicitly identify which phase the exchange is in
        o Updated Exchange to set ExchangePhase and added validation logic to send and sendFault
        o Dumped MessageBuilder stuff - Message instances are created off of Exchange now
        o Updated code in handlers to use exchange phase, but they're still ugly
        o Updated tests and other code that was impacted by API changes
        o Added tests to ExchangeImpl

       

      Overall, I think this is an improvement.  There are still rough edges.  I'm not super jazzed about returning null from Exchange.getPhase() on a new exchange.  The state should not be IN, because we set the phase to IN on the first send.  I flirted with the idea of adding a NEW phase, but it didn't sit right for some reason.

       

      Oh ... I forgot to add logic to detect repeated sends of the same message, which we agreed to not allow since message context is now attached to message.  The idea was that you would create a new message from the existing one to move the content over.   Need to think on a clean way to represent that.  Our goal is to discourage re-use of message context, since this tends to create a situation where a message picks up a lot of context baggage when it's reused across multiple invocations.

        • 1. Some rework of the API
          tfennelly

          Most definetely an improvement.  Message creation and context access is less noisy... the shenanigans with setting the source as target in the DeliveryHandler is sorted + casting the Endpoint is gone.  I think this is a good cleanup!!

           

          BTW... do we still need the Scope enum?

          • 2. Some rework of the API
            kcbabo
            Most definetely an improvement.  Message creation and context access is less noisy... the shenanigans with setting the source as target in the DeliveryHandler is sorted + casting the Endpoint is gone.  I think this is a good cleanup!!

            OK, I will make sure the changes are findbugs and checkstyle clean, create a JIRA, and submit a pull request.

            BTW... do we still need the Scope enum?

            Good point. I will clean that up.