class FastInfosetCompressionService implements CompressionService {

    @Override
    public ByteArrayOutputStream compress(final InputStream inputStream) {
        InputStream source = inputStream;
        try {
            ByteArrayOutputStream fis = outputStreamFactory.createByteArrayOutputStream();
            SAXDocumentSerializer saxDocumentSerializer = documentSerializerFactory.createSAXDocumentSerializer();
            saxDocumentSerializer.setOutputStream(fis);
            SAXParserFactory saxParserFactory = saxParserCreator.createSAXParserFactory();
            saxParserFactory.setNamespaceAware(true);
            SAXParser saxParser = saxParserFactory.newSAXParser();
            saxParser.parse(source, saxDocumentSerializer);
            return fis;
        } catch (Exception e) {
            throw new SystemException("Could not perform fastinfoset compression!", e);
        }
    }

}