Package org.jboss.fresh.io

Examples of org.jboss.fresh.io.BufferObjectReader


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

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

    // if no params, just let through everything
    // if type param, do some filtering.
    if (params.length == 0) {
      log.info("No parameters specified. Just piping through.");
      while (!oin.isFinished()) {
        oout.writeObject(oin.readObject());
      }
      oout.close();
      log.debug("done");
      return;
    }


    HashMap typemap = new HashMap();
    typemap.put("type", "string");

    // filterparser mora pripraviti pogoje - Filter objekte. Filter objekt zna za vrednost dolo�enega tipa pogledati ali izpolnjuje set pogojev.
    // Seveda je normalno pogoj vezan na neko polje v neki podatkovni strukturi. Treba je samo ta field vedno posredovati temu filtru.
    // Treba je torej vedeti kateri field je vezan na kateri filter.
    // smiselno je enumerirati list filtrov. Vsak filter vpra�ati na kateri field se nana�a in ta field posredovati v preverjanje.

    FilterParser p = null;
    Filter[] filters = null;

    try {
      p = new MyFilterParser(typemap, params);
      filters = p.getFilters();
    } catch (Exception e) {
      if (canThrowEx()) {
        throw e;
      } else {
        PrintWriter err = new PrintWriter(new BufferWriter(getStdOut()));
        err.println("" + e);
      }
    }

    // now we do ...
    while (!oin.isFinished()) {
      FileInfo finf = (FileInfo) oin.readObject();

      boolean ok = false;

      for (int i = 0; i < filters.length; i++) {
        String fld = filters[i].getFieldName();
View Full Code Here


        return;
      }

    }

    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferObjectWriter out = new BufferObjectWriter(getStdOut());

    Object obj;
    while (!in.isFinished()) {
      obj = in.readObject();
      // process input stream
      if (obj == null) {
        if (forceString) {
          log.debug("Object is null. Outputing empty String.");
          out.writeObject("");
View Full Code Here

      return;
    }

    Object ret = new Object();

    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferObjectWriter out = new BufferObjectWriter(getStdOut());

    Object[] input = (Object[]) in.readObject();

    System.out.println("Input Object[] is: " + String.valueOf(input));

    Object[] cons_params = (Object[]) input[0];
    System.out.println("Constructor params is: " + String.valueOf(cons_params));
View Full Code Here

//    System.out.println("##[CatExe] : getStdOut():" + getStdOut());
//    System.out.println("##[CatExe] : getStdIn():" + getStdIn());

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

    VFS vfs = shell.getVFS();

    FileName pwd = new FileName(shell.getEnvProperty("PWD"));

    List paths = new LinkedList();

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

      FileName path = new FileName(param);
      if (path.isRelative())
        path = pwd.absolutize(path);

      path = vfs.resolve(shell.getUserCtx(), path, false);
      paths.add(path);
    }


//    List result = new LinkedList();

//    if no paths given, read from stdin
    if (!paths.isEmpty()) {
      Iterator it = paths.iterator();
      while (it.hasNext()) {
        FileName path = (FileName) it.next();

        FileOpInfo op = new FileOpInfo();
        op.filename = path;
//        op.offset = 0;
        FileReadInfo read = null;

        do {
          read = vfs.read(shell.getUserCtx(), op);

          // if file has no content(is asset, etc.) null is returned by vfs.read()
          if (read == null)
            break;

          op.tag = read.tag;
          op.offset += read.buf.length;
          oout.writeObject(read.buf);
        } while (read.more);
      }

    } else {
      while (!oin.isFinished()) {
        Object obj = oin.readObject();
        oout.writeObject(obj);
//        System.out.println("##[CatExe] writing to out: " + obj);
      }

    }
View Full Code Here

    if (!useRegExp && ignoreCase) {
      word = word.toUpperCase();
    }

    BufferObjectReader oin = new BufferObjectReader(getStdIn());
    AutoConvertInputStream acis = new AutoConvertInputStream(oin);
    InputStreamReader isr = new InputStreamReader(acis);
    java.io.BufferedReader br = new java.io.BufferedReader(isr);

    String line = br.readLine();
View Full Code Here

        buf = getBuffer(pinfo.procid, 1);
      } catch(org.jboss.fresh.shell.NoSuchProcessException ex) {
        return null;
      }

      BufferObjectReader in = new BufferObjectReader(buf); // get out buffer

      in.setTimeout((int) BUFFER_TIMEOUT);

      Object retObj = null;
      while (!in.isFinished()) { // �e ho�emo, da sa izvede do konca moramo prebrati vse  -  dokler se ne zapre.
        try {

          if (retObj == null) {
//log.debug("########\n\n\n\\n Timeout: " + in.getTimeout());
            retObj = in.readObject()// read it
          } else {
//log.debug("########\n\n\n\\n Timeout_1: " + in.getTimeout());
            in.readObject()// dump it
          }
        } catch (IOException ex) {
//log.debug("[ShellImpl] executeAsObject:");
          log.error(ex.getMessage(), ex);
        }
View Full Code Here

*/
public class GzipExe extends AbstractExecutable {
  public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/cp2/cp2-systemshell/src/com/parsek/shell/commands/GzipExe.java,v 1.3 2004/07/22 13:38:56 boky Exp $";

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferOutputStream out = getStdOutStream();
    GZIPOutputStream gout = new GZIPOutputStream(out);
    ObjectOutputStream oout = new ObjectOutputStream(gout);
    Object obj;
    try {
      while( !in.isFinished() ) {
        obj = in.readObject();
        oout.writeObject(obj);
        oout.flush();
        gout.flush();
        out.flush();
      }
      in.close();
    } catch (Exception e) {
      if(canThrowEx()) {
        throw e;
      } else {
        org.jboss.fresh.io.BufferWriter bw = new BufferWriter(getStdOut());
View Full Code Here

        } 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

            Object o = null;
            String factoryCName = null;

            if(spiObjectFactory == null || "StaticStore".equals(spiObjectFactory)) {
                BufferObjectReader oin = new BufferObjectReader(getStdIn());
                if(!oin.isFinished()) {
                    o = oin.readObject();
                }
            } else if("JNDI2Registry".equals(spiObjectFactory)) {
                o = new RegistryContext().lookup((String) spiParams.get(1));
                factoryCName = org.jboss.fresh.registry.JNDI2RegistryResolverFactory.class.getName();
            } else if("StaticStore".equals(spiObjectFactory)) {
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);
//      t.start();
View Full Code Here

TOP

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

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.