code: private final DataSlice encodeHeaderPartToSlice(JsMsgPart jsPart) throws MessageEncodeFailedException {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodeHeaderPartToSlice", jsPart);
  
      // We hope that it is already encoded so we can just get it from JMF.....
      DataSlice slice = ((JMFMessage)jsPart.jmfPart).getAssembledContent();
  
      // ... if not, then we have to encode it now
      if (slice == null) {
        byte[] buff;
  
        // We need to ensure noone updates any vital aspects of the message part
        // between the calls to getEncodedLength() and toByteArray()       d364050
        synchronized (getPartLockArtefact(jsPart)) {
          buff = encodePart(jsPart);
        }
        slice = new DataSlice(buff, 0, buff.length);
      }
  
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodeHeaderPartToSlice", slice);
      return slice;
    }
docs: Encode the header, or only, a message part into a DataSlice for transmitting
  over the wire, or flattening for persistence.
  If the message part is already 'assembled' the contents are simply be
  wrapped in a DataSlice by the JMFMessage & returned.
  If the message part is not already assembled, the part is encoded into a
  new byte array which is wrapped by a DataSlice.
  
  @param jsPart The message part to be encoded.
  
  @return DataSlice The DataSlice containing the encoded message part
  
  @exception MessageEncodeFailedException is thrown if the message part failed to encode.