001 package org.shiftone.jrat.inject.process;
002
003
004 import org.shiftone.jrat.core.JRatException;
005 import org.shiftone.jrat.inject.InjectorOptions;
006 import org.shiftone.jrat.inject.bytecode.Transformer;
007 import org.shiftone.jrat.util.log.Logger;
008
009 import java.io.InputStream;
010 import java.io.OutputStream;
011
012
013 /**
014 * @author jeff@shiftone.org (Jeff Drost)
015 */
016 public class ClassFileProcessor extends AbstractFileProcessor {
017
018 private static final Logger LOG = Logger.getLogger(ClassFileProcessor.class);
019
020 protected void processStream(Transformer transformer, InjectorOptions options, InputStream inputStream,
021 OutputStream outputStream, String fileName) {
022
023 LOG.debug("processStream");
024
025 byte[] newClassData = transformer.inject(inputStream, fileName, options);
026
027 try {
028 outputStream.write(newClassData);
029 }
030 catch (Exception e) {
031 throw new JRatException("unable to write data to output stream", e);
032 }
033 }
034 }