Currently the Exchange has the following 4 apis that I think can be
consolidated into 1 or 2 methods:
Exchange newInstance();
Exchange copy();
Exchange newCopy(boolean handoverOnCompletion);
void copyFrom(Exchange source);
I think both copyFrom(Exchange) and newInstance() could easily be
replaced by copy(). The usage pattern is:
Exchange e = source.newInstance();
e.copyFrom(source);
which is as good as
Exchange e = source.copy();
I believe newCopy(which is kinda ugly and only used in 4 places) can
be consolidated with copy(), but I'd have to take a closer look. Its
usage is not really consistent with the javadoc description (only used
by wiretap, seda and ThreadsProcessor, not all of the components that
do async messaging). Looking at the implementation in
DefaultExchange, setting the CORRELATION_ID is already done by copy()
and in 2 out of 4 calls it's invoked with handoverOnCompletion set to
false.
I can't really see what the different semantic abstractions these
methods represent (in spite of the javadoc comments) and I'd like this
api cleanup to be done in 2.0 if you guys agree.
Thoughts?
Hadrian