Since {@link Codec} instance is not re-entrant, the callerwho needs to encode two {@link Message}s simultaneously will want to have two {@link Codec} instances. That's what thismethod produces.
Note that this method might be invoked by one thread while another thread is executing one of the {@link #encode} methods. This should be OK because you'll be only copying things that are thread-safe, and creating new ones for thread-unsafe resources, but please let us know if this contract is difficult. @return always non-null valid {@link Codec} that performsthe encoding work in the same way --- that is, if you copy an FI codec, you'll get another FI codec.
Once copied, two {@link Codec}s may be invoked from two threads concurrently; therefore, they must not share any state that requires isolation (such as temporary buffer.)
If the {@link Codec} implementation is alreadyre-entrant and multi-thread safe to begin with, then this method may simply return this.
|
|