Package org.jboss.fresh.io

Examples of org.jboss.fresh.io.BufferObjectWriter


            vals = new Object[sig.length];
        } else {
            methodName = method;
        }

        BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
        BufferObjectReader oin = new BufferObjectReader(getStdIn());

        if (vals != null) {
            for (int i = 0; i < vals.length; i++) {

                if (!oin.isFinished())
                    vals[i] = oin.readObject();
                else if (canThrowEx()) {
                    throw new Exception("Not enough input objects on stdin.");
                } else {
                    out.println("Not enough input objects on stdin.");
                    return;
                }
            }
        }

        /*
        if (notx) {
            // if in tx, do this in another thread - through remote
            // or
            if (TxSupport.isActive()) {
                wasActive = true;
                TxSupport.commit();
            }
        } */

        try {
            invoke(out, mbeanName, methodName, sig, vals, oout);
        }
        finally {
           /* if (wasActive && !TxSupport.isActive()) {
                TxSupport.begin();
            } */
        }

        oout.close();
        oin.close();

        getLog().debug("done");
    }
View Full Code Here


      out.close();
      log.debug("done");
      return;
    }

    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());

    Shell sh = getShell();
    FileName fname = new FileName(params[0]);
    if (!fname.isAbsolute()) {
      fname = new FileName(sh.getEnvProperty("PWD")).absolutize(fname);
View Full Code Here

*/
public class Bunzip2Exe extends AbstractExecutable {
  public static final String VERSION = "$Header$";

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectWriter out = new BufferObjectWriter(getStdOut());
    BufferInputStream in = getStdInStream();
    CBZip2InputStream bin = new CBZip2InputStream(in);
    ObjectInputStream oin = new ObjectInputStream(bin);
    Object obj;
    try {
      boolean eof = false;
      while( !eof ) {
        try {
          obj = oin.readObject();
          out.writeObject(obj);
        } catch (java.io.OptionalDataException ode) {
          if(ode.eof) {
            eof = true;
            oin.close();
            bin.close();
            in.close();
          } else {
            throw ode;
          }
        }
      }
    } catch (Exception e) {
      if(canThrowEx()) {
        throw e;
      } else {
        org.jboss.fresh.io.BufferWriter bw = new BufferWriter(getStdOut());
        PrintWriter tOut = new PrintWriter(bw);
        tOut.write(e.toString());
      }
    }
    out.close();
  }
View Full Code Here

        else
            ctx = new InitialContext(env);


        if (g) {
            BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
            Object o = null;

            try {
                o = ctx.lookup(name);
            } catch (NamingException ex) {
                if (tex)
                    throw new RuntimeException(ex);
                else
                    out.print("Name not bound: " + name);
                return;
            }

            oout.writeObject(o);
            oout.flush();
            return;
        }

        if (l) {
            BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
            Object o = ctx.lookup(name);
            if (!(o instanceof Context)) {
                if (tex)
                    throw new RuntimeException("Object is not instance of Context. Can't list it. : " + name);
                else
View Full Code Here

log.info("Stopping current router ...");
      router.stop(true);
log.info("ok.  getting connector and replacing buffers ...");
      EventNetShellAgentConnector con = (EventNetShellAgentConnector) router.getConnector();
      con.setOutput(new BufferObjectWriter(getStdOut()));
      con.setInput(new BufferObjectReader(getStdIn()));
log.info("ok. Creating new ProcessorThread");
      router.start();
log.info("### YAK! This shouldn'0t happen :(.");
      return;

       // (this will take over our thread and our job is done)

    } else {
      // if it doesn't exist then we need to instanciate a new EventNetRouter and register it with EventCentral
      // Then do same things as with taking over which eventually takes executable's thread inside the last method we call.
      if(hostLabel == null) {
        error("Host not specified");
        return;
      }

      if(app==null) app = shell.getEnvProperty("PROJECT");

      router = new EventNetRouterImpl(ec, initorID, hostLabel, app, keepEvents);
      router.setConID(conID);
     
      //ec.registerEventNetRouter(initorID, router);
      EventNetShellAgentConnector con = new EventNetShellAgentConnector();
      con.setOutput(new BufferObjectWriter(getStdOut()));
      con.setInput(new BufferObjectReader(getStdIn()));

      router.setConnector(con);
      router.start();
//      t = new ProcessorThread(router);
View Full Code Here

      throwException("No object recieved from the standard input.");
      return;
    }

    // write object
    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
    oout.writeObject(image);
    oout.close();

    log.debug("done");
  }
View Full Code Here

          JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(os);
          jpegEncoder.encode(newImage);
          os.close();
*/
        } else { // OBJ_TYPE
          BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
          oout.writeObject(newImage);
          oout.close();
        }

        return;
      }

View Full Code Here

        if (tmp.equals("e")) {
          // get command
          String param = params[++i];

          BufferObjectWriter bout = new BufferObjectWriter(getStdOut());
          bout.writeObject(URLEncoder.encode(param, "utf-8"));
          bout.close();

        } else if (tmp.equals("d")) {

          String param = params[++i];

          BufferObjectWriter bout = new BufferObjectWriter(getStdOut());
          bout.writeObject(URLDecoder.decode(param, "utf-8"));
          bout.close();

        } else {
          if (canThrowEx()) {
            throw new Exception("Unknown command: " + tmp);
          } else {
View Full Code Here

      log.debug("done");
      return;
    }

    BufferObjectReader oin = new BufferObjectReader(getStdIn());
    BufferObjectWriter oout = new BufferObjectWriter(getStdOut());

    // handle parameters
    int x = 0, y = 0, w = 0, h = 0, x2 = -1, y2 = -1;
    String inType = IMG_TYPE;
    String outType = null;

    for (int i = 0; i < params.length; i++) {
      String str = params[i];

      if (str.equals("-x1")) {
        x = Integer.parseInt(params[++i]);
      } else if (str.equals("-y1")) {
        y = Integer.parseInt(params[++i]);
      } else if (str.equals("-x2")) {
        x2 = Integer.parseInt(params[++i]);
      } else if (str.equals("-y2")) {
        y2 = Integer.parseInt(params[++i]);
      } else if (str.equals("-in")) {
        inType = params[++i];
        if (!inType.equals(IMG_TYPE) && !inType.equals(OBJ_TYPE)) {
          throwException("Invalid in type");
          return;
        }
      } else if (str.equals("-out")) {
        outType = params[++i];
        if (!outType.equals(IMG_TYPE) && !outType.equals(OBJ_TYPE)) {
          throwException("Invalid out type");
          return;
        }
      } else {
        throwException("There is an unknown parameter.");
        return;
      }
    }

    if (outType == null) {
      outType = inType;
    }

    // read image
    BufferedImage image = null;

    if (inType.equals(IMG_TYPE)) {
      BufferInputStream bis = new BufferInputStream(getStdIn());
      image = ImageIO.read(bis);
      bis.close();
    } else { // OBJ_TYPE
      Object obj = null;

      if (oin.hasNext()) {
        obj = oin.next();
      }
      oin.close();

      try {
        image = (BufferedImage) obj;
      } catch (Exception e) {
        throwException("" + e);
        return;
      }
    }

    if (image == null) {
      throwException("IMAGE == NULL");
      return;
    }

    // test for crop area size

    int imgh = image.getHeight();
    int imgw = image.getWidth();

    if (x2 == -1) x2 = imgw;
    if (y2 == -1) y2 = imgh;

    if (x < 0) x = 0;
    if (y < 0) y = 0;

    w = x2 - x;
    h = y2 - y;

    if (x > imgw) x = imgw;
    if (y > imgh) y = imgh;

    if (x + w > imgw) w = imgw - x;
    if (y + h > imgh) h = imgh - y;

    // make new image
    BufferedImage newImage = new BufferedImage(w, h, image.getType());
    newImage.setData(image.getData(new Rectangle(x, y, w, h)).createTranslatedChild(0, 0));

    // write new image to stream
    if (outType.equals(IMG_TYPE)) {
      BufferOutputStream bos = new BufferOutputStream(getStdOut());
      ImageIO.write(newImage, "jpg", bos);
      bos.close();
    } else { // OBJ_TYPE
      oout.writeObject(newImage);
      oout.close();
    }

    log.debug("done");
  }
View Full Code Here

    if (params.length > 0) {
      getShell().executeAsObject("exec /projects/" + params[0] + "/project-init.rc");
      getShell().setEnvProperty("PROJECT", params[0]);
      // otherwise display the current project
    } else {
      BufferObjectWriter bout = new BufferObjectWriter(getStdOut());
      bout.writeObject(getShell().getEnvProperty("PROJECT"));
      bout.close();
    }

    log.debug("done");
  }
View Full Code Here

TOP

Related Classes of org.jboss.fresh.io.BufferObjectWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.