Package java.io

Examples of java.io.ObjectInputStream$BlockDataInputStream


    public static WorkItem readWorkItem(MarshallerReaderContext context) throws IOException {
       return readWorkItem(context, true);
    }

    public static WorkItem readWorkItem(MarshallerReaderContext context, boolean includeVariables) throws IOException {
        ObjectInputStream stream = context.stream;

        WorkItemImpl workItem = new WorkItemImpl();
        workItem.setId( stream.readLong() );
        workItem.setProcessInstanceId( stream.readLong() );
        workItem.setName( stream.readUTF() );
        workItem.setState( stream.readInt() );

        if(includeVariables){
        int nbParameters = stream.readInt();

        for ( int i = 0; i < nbParameters; i++ ) {
            String name = stream.readUTF();
            try {
                Object value = stream.readObject();
                workItem.setParameter( name,
                                       value );
            } catch ( ClassNotFoundException e ) {
                throw new IllegalArgumentException( "Could not reload parameter " + name );
            }
View Full Code Here


        return workItem;
    }

    public void readProcessTimers(MarshallerReaderContext context) throws IOException {
        ObjectInputStream stream = context.stream;

        TimerManager timerManager = ((InternalProcessRuntime) ((InternalWorkingMemory) context.wm).getProcessRuntime()).getTimerManager();
        timerManager.internalSetTimerId( stream.readLong() );
       
        // still need to think on how to fix this.
//        TimerService service = (TimerService) stream.readObject();
//        timerManager.setTimerService( service );

        while ( stream.readShort() == PersisterEnums.TIMER ) {
            TimerInstance timer = readTimer( context );
            timerManager.internalAddTimer( timer );
        }
    }
View Full Code Here

            timerManager.internalAddTimer( timer );
        }
    }

    public TimerInstance readTimer(MarshallerReaderContext context) throws IOException {
        ObjectInputStream stream = context.stream;

        TimerInstance timer = new TimerInstance();
        timer.setId( stream.readLong() );
        timer.setTimerId( stream.readLong() );
        timer.setDelay( stream.readLong() );
        timer.setPeriod( stream.readLong() );
        timer.setProcessInstanceId( stream.readLong() );
        timer.setActivated( new Date( stream.readLong() ) );
        if ( stream.readBoolean() ) {
            timer.setLastTriggered( new Date( stream.readLong() ) );
        }
        return timer;
    }
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(new ExceptionHolder(new BadException(obj)));
        oos.flush();
       
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ExceptionHolder holder = (ExceptionHolder)ois.readObject();
        assertTrue(holder.getException() instanceof BadException);
        assertEquals("Remote org.teiid.client.util.TestExceptionHolder$BadException: null", holder.getException().getMessage()); //$NON-NLS-1$
  }
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(new ExceptionHolder(new BadException2(obj, "I have foreign exception embedded in me"))); //$NON-NLS-1$
        oos.flush();
       
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ExceptionHolder holder = (ExceptionHolder)ois.readObject();
        Throwable e = holder.getException();
        assertTrue(e instanceof BadException2);
        assertEquals("Remote org.teiid.client.util.TestExceptionHolder$BadException2: I have foreign exception embedded in me", e.getMessage()); //$NON-NLS-1$
       
        // now unknown exception is not found, so promote known SQL exception up
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(new ExceptionHolder(obj));
        oos.flush();
       
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ExceptionHolder holder = (ExceptionHolder)ois.readObject();
        Throwable e = holder.getException();
        assertTrue(e instanceof TeiidRuntimeException);
        assertEquals("Unknown Exception", e.getMessage()); //$NON-NLS-1$
 
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(new ExceptionHolder(ex));
        oos.flush();
       
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ExceptionHolder holder = (ExceptionHolder)ois.readObject();
        Throwable e = holder.getException();
        assertTrue(e instanceof TeiidException);
  }
View Full Code Here

        try {
          Thread t = new Thread() {
            public void run() {
              try {
              InputStream is = getResources().openRawResource(R.raw.hcsb_ser);
              ObjectInputStream ios = new ObjectInputStream(is);
              Object o = ios.readObject();
              DetectHaarParam.setCascade((HaarClassifierCascade) o);
              ios.close();
              is.close();
              } catch (Exception ex) {
                    ex.printStackTrace();
                      System.err.print("Exception: " + ex.toString()); //$NON-NLS-1$ //$NON-NLS-2$        
              }
View Full Code Here

   
    now = reply.now;
    setStamp(reply.stamp);
    // creates all agents
    ByteArrayInputStream bis = new ByteArrayInputStream(reply.agents);
    ObjectInputStream ois = new ObjectInputStream(bis);
    try {
      AgentId id = null;
      Agent agent = null;
      AgentIdStamp.stamp = (AgentIdStamp) ois.readObject();
      while (true) {
        id = (AgentId) ois.readObject();
        agent = (Agent) ois.readObject();
        agent.id = id;
        agent.deployed = true;
        // If there is a bag associated with this agent don't initialize it!
        if (agent instanceof BagSerializer) {
          ((BagSerializer) agent).readBag(ois);
        } else {
          agent.agentInitialize(false);
        }
        createAgent(agent);
      }
    } catch (EOFException exc) {
      logmon.log(BasicLevel.WARN,
                 AgentServer.getName() + " setState()", exc);
    } catch (Exception exc) {
      logmon.log(BasicLevel.ERROR,
                 AgentServer.getName() + " setState()", exc);
    } finally {
      try {
        ois.close();
      } catch (Exception exc) {}
    }
    // inserts all pending messages
    bis = new ByteArrayInputStream(reply.messages);
    ois = new ObjectInputStream(bis);
    try {
      qinFromExt = (Vector) ois.readObject();
      if (logmon.isLoggable(BasicLevel.DEBUG)) {
        for (int i=0; i<qinFromExt.size(); i++) {
          Message msg = (Message) qinFromExt.elementAt(i);
          logmon.log(BasicLevel.DEBUG,
                     AgentServer.getName() + " setState() -> " + msg);
        }
      }
      postFromExt();
    } finally {
      try {
        ois.close();
      } catch (Exception exc) {}
    }
  }
View Full Code Here

  }

  Object load(byte[] buf) throws Exception {
    Object obj = null;
    ByteArrayInputStream bis = new ByteArrayInputStream(buf);
    ObjectInputStream ois = new ObjectInputStream(bis);   
    obj = ois.readObject();
    try {
      ois.close();
    } catch (IOException exc) {}
    return obj;
  }
View Full Code Here

TOP

Related Classes of java.io.ObjectInputStream$BlockDataInputStream

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.