@@ -0,0 +1,2978 @@
+package innovimax.mixthem.rest.services;%0A%0Aimport innovimax.mixthem.MixException;%0Aimport innovimax.mixthem.Rule;%0Aimport innovimax.mixthem.rest.ErrorResponse;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.io.Reader;%0A%0Aimport javax.ws.rs.InternalServerErrorException;%0Aimport javax.ws.rs.WebApplicationException;%0Aimport javax.ws.rs.core.Response;%0Aimport javax.ws.rs.core.StreamingOutput;%0A%0Apublic class ServiceOutput implements StreamingOutput %7B%0A%0A    final Rule rule;%0A    final Reader reader1;%0A    final Reader reader2;%0A%0A    public ServiceOutput(Rule rule, Reader reader1, Reader reader2) %7B%0A        this.rule = rule;%0A        this.reader1 = reader1;%0A        this.reader2 = reader2;%0A    %7D%0A%0A    @Override%0A    public void write(OutputStream output) throws IOException, WebApplicationException %7B%0A        try %7B%0A            getAPI().process(rule, reader1, reader2, output);    %0A        %7D catch (MixException e) %7B%0A            ErrorResponse error = ServiceErrorResponse.createMixingError(e.getMessage());%0A            Response response = Response.status(error.getCode()).entity(error).build();%0A            throw new InternalServerErrorException(response);%0A        %7D%0A    %7D%0A%0A    private MixThemAPI getAPI() throws MixException %7B%0A        //TODO get API interface from MixThem release%0A        return new MixThemTest();        %0A    %7D%0A%0A    //TODO define API interface in MixThem release%0A    private interface MixThemAPI %7B%0A        void process(Rule rule, java.io.Reader reader1, java.io.Reader reader2, OutputStream output) throws MixException;%0A    %7D%0A    private class MixThemTest implements MixThemAPI %7B%0A        @Override%0A        public void process(Rule rule, java.io.Reader reader1, java.io.Reader reader2, OutputStream output) throws MixException %7B%0A            if (rule == null) %7B%0A                throw new MixException(%22Rule not defined!%22, null);%0A            %7D%0A            if (reader1 == null) %7B%0A                throw new MixException(%22First reader not defined!%22, null);%0A            %7D%0A            if (reader2 == null) %7B%0A                throw new MixException(%22Last reader not defined!%22, null);%0A            %7D%0A            try %7B%0A                java.io.BufferedReader br1 = new java.io.BufferedReader(reader1);%0A                java.io.BufferedReader br2 = new java.io.BufferedReader(reader2);%0A                java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.OutputStreamWriter(output));%0A                String line = null;%0A                while ((line = br1.readLine()) != null) %7B%0A                    bw.write(line);%0A                    bw.newLine();%0A                %7D %0A                while ((line = br2.readLine()) != null) %7B%0A                    bw.write(line);%0A                    bw.newLine();%0A                %7D %0A                bw.flush();              %0A                br1.close();%0A                br2.close();%0A            %7D catch (Exception e) %7B%0A                throw new MixException(e);                %0A            %7D            %0A        %7D%0A    %7D%0A%0A%7D%0A

Create ServiceOutput.java