Package java.io

Examples of java.io.ObjectOutputStream$Caches


    this.producer = producer;
  }

  public void write(Object message) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oout;
    try {
      oout = new ObjectOutputStream(baos);
      oout.writeObject(message);
      ClientMessage clientMessage = session.createMessage(true);
      clientMessage.getBodyBuffer().writeBytes(baos.toByteArray());
      producer.send(clientMessage);
    } catch (IOException e) {
      throw new IOException("Error creating message");
View Full Code Here


    }
  }

  public void write(Object object) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oout;
    try {
      oout = new ObjectOutputStream(baos);
      oout.writeObject(object);
      ClientMessage message = session.createMessage(true);
      message.getBodyBuffer().writeBytes(baos.toByteArray());
      message.putStringProperty("producerId", name);
      producer.send(message);
    } catch (IOException e) {
View Full Code Here

    }

    private void saveProcessInstanceType(MarshallerWriteContext context,
                                         ProcessInstance processInstance,
                                         String processInstanceType) throws IOException {
        ObjectOutputStream stream = context.stream;
        // saves the processInstance type first
        stream.writeUTF( processInstanceType );
    }
View Full Code Here

              }
            }
            synchronized (batchManager.store) {
              offset = batchManager.getOffset();
              OutputStream fsos = new BufferedOutputStream(batchManager.store.createOutputStream(), IO_BUFFER_SIZE);
                    ObjectOutputStream oos = new ObjectOutputStream(fsos);
                    batch.writeExternal(oos);
                    oos.close();
                    long size = batchManager.store.getLength() - offset;
                    long[] info = new long[] {offset, size};
                    batchManager.physicalMapping.put(this.id, info);
            }
            LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, batchManager.id, id, "batch written starting at:", offset); //$NON-NLS-1$
View Full Code Here

        }
    }
   
    private static void helpTestSerialization(String[] types, List[] batch) throws IOException, ClassNotFoundException {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(byteStream);
        BatchSerializer.writeBatch(out, types, batch);
        out.flush();
       
        byte[] bytes = byteStream.toByteArray();
       
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytes);
        ObjectInputStream in = new ObjectInputStream(bytesIn);
        List[] newBatch = BatchSerializer.readBatch(in, types);
        out.close();
        in.close();

        assertEqual(batch, newBatch);
    }
View Full Code Here

        }
        stream.writeShort( PersisterEnums.END );
    }

    public void writeProcessTimers(MarshallerWriteContext context) throws IOException {
        ObjectOutputStream stream = context.stream;

        TimerManager timerManager = ((InternalProcessRuntime) ((InternalWorkingMemory) context.wm).getProcessRuntime()).getTimerManager();
        long timerId = timerManager.internalGetTimerId();
        stream.writeLong( timerId );
       
        // need to think on how to fix this
        // stream.writeObject( timerManager.getTimerService() );
       
        List<TimerInstance> timers = new ArrayList<TimerInstance>( timerManager.getTimers() );
        Collections.sort( timers,
                          new Comparator<TimerInstance>() {
                              public int compare(TimerInstance o1,
                                                 TimerInstance o2) {
                                  return (int) (o2.getId() - o1.getId());
                              }
                          } );
        for ( TimerInstance timer : timers ) {
            stream.writeShort( PersisterEnums.TIMER );
            writeTimer( context,
                        timer );
        }
        stream.writeShort( PersisterEnums.END );
    }
View Full Code Here

        stream.writeShort( PersisterEnums.END );
    }

    public void writeTimer(MarshallerWriteContext context,
                           TimerInstance timer) throws IOException {
        ObjectOutputStream stream = context.stream;
        stream.writeLong( timer.getId() );
        stream.writeLong( timer.getTimerId() );
        stream.writeLong( timer.getDelay() );
        stream.writeLong( timer.getPeriod() );
        stream.writeLong( timer.getProcessInstanceId() );
        stream.writeLong( timer.getActivated().getTime() );
        Date lastTriggered = timer.getLastTriggered();
        if ( lastTriggered != null ) {
            stream.writeBoolean( true );
            stream.writeLong( timer.getLastTriggered().getTime() );
        } else {
            stream.writeBoolean( false );
        }
    }
View Full Code Here

            stream.writeBoolean( false );
        }
    }

    public void writeWorkItems(MarshallerWriteContext context) throws IOException {
        ObjectOutputStream stream = context.stream;

        List<WorkItem> workItems = new ArrayList<WorkItem>(
        ((WorkItemManager) context.wm.getWorkItemManager()).getWorkItems() );
        Collections.sort( workItems,
                          new Comparator<WorkItem>() {
                              public int compare(WorkItem o1,
                                                 WorkItem o2) {
                                  return (int) (o2.getId() - o1.getId());
                              }
                          } );
        for ( WorkItem workItem : workItems ) {
            stream.writeShort( PersisterEnums.WORK_ITEM );
            writeWorkItem( context,
                           workItem );
        }
        stream.writeShort( PersisterEnums.END );
    }
View Full Code Here

         writeWorkItem(context, workItem, true);
    }

    public static void writeWorkItem(MarshallerWriteContext context,
                                     WorkItem workItem, boolean includeVariables) throws IOException {
        ObjectOutputStream stream = context.stream;
        stream.writeLong( workItem.getId() );
        stream.writeLong( workItem.getProcessInstanceId() );
        stream.writeUTF( workItem.getName() );
        stream.writeInt( workItem.getState() );

        if(includeVariables){
          Map<String, Object> parameters = workItem.getParameters();
          stream.writeInt( parameters.size() );
          for ( Map.Entry<String, Object> entry : parameters.entrySet() ) {
              stream.writeUTF( entry.getKey() );
              stream.writeObject( entry.getValue() );
          }
      }
    }
View Full Code Here

    // Output methods
    public void writeProcessInstance(MarshallerWriteContext context,
            ProcessInstance processInstance) throws IOException {
        WorkflowProcessInstanceImpl workFlow = (WorkflowProcessInstanceImpl) processInstance;
        ObjectOutputStream stream = context.stream;
        stream.writeLong(workFlow.getId());
        stream.writeUTF(workFlow.getProcessId());
        stream.writeInt(workFlow.getState());
        stream.writeLong(workFlow.getNodeInstanceCounter());

        SwimlaneContextInstance swimlaneContextInstance = (SwimlaneContextInstance) workFlow.getContextInstance(SwimlaneContext.SWIMLANE_SCOPE);
        if (swimlaneContextInstance != null) {
            Map<String, String> swimlaneActors = swimlaneContextInstance.getSwimlaneActors();
            stream.writeInt(swimlaneActors.size());
            for (Map.Entry<String, String> entry : swimlaneActors.entrySet()) {
                stream.writeUTF(entry.getKey());
                stream.writeUTF(entry.getValue());
            }
        } else {
            stream.writeInt(0);
        }
       
        List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(workFlow.getNodeInstances());
        Collections.sort(nodeInstances,
                new Comparator<NodeInstance>() {

                    public int compare(NodeInstance o1,
                            NodeInstance o2) {
                        return (int) (o1.getId() - o2.getId());
                    }
                });
        for (NodeInstance nodeInstance : nodeInstances) {
            stream.writeShort(PersisterEnums.NODE_INSTANCE);
            writeNodeInstance(context,
                    nodeInstance);
        }
        stream.writeShort(PersisterEnums.END);
       
        List<ContextInstance> exclusiveGroupInstances =
          workFlow.getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
        if (exclusiveGroupInstances == null) {
          stream.writeInt(0);
        } else {
          stream.writeInt(exclusiveGroupInstances.size());
          for (ContextInstance contextInstance: exclusiveGroupInstances) {
            ExclusiveGroupInstance exclusiveGroupInstance = (ExclusiveGroupInstance) contextInstance;
            Collection<NodeInstance> groupNodeInstances = exclusiveGroupInstance.getNodeInstances();
            stream.writeInt(groupNodeInstances.size());
            for (NodeInstance nodeInstance: groupNodeInstances) {
              stream.writeLong(nodeInstance.getId());
            }
          }
        }
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) workFlow.getContextInstance(VariableScope.VARIABLE_SCOPE);
        Map<String, Object> variables = variableScopeInstance.getVariables();
        List<String> keys = new ArrayList<String>(variables.keySet());
        Collection<Object> values = variables.values();
       
        Collections.sort(keys,
                new Comparator<String>() {

                    public int compare(String o1,
                            String o2) {
                        return o1.compareTo(o2);
                    }
                });
        // Process Variables
                // - Number of non null Variables = nonnullvariables.size()
                // For Each Variable
                    // - Variable Key
                    // - Marshalling Strategy Index
                    // - Marshalled Object
       
        Collection<Object> notNullValues = new ArrayList<Object>();
        for(Object value: values){
            if(value != null){
                notNullValues.add(value);
            }
        }
               
        stream.writeInt(notNullValues.size());
        for (String key : keys) {
            Object object = variables.get(key);
            if(object != null){
                stream.writeUTF(key);
                int index = context.objectMarshallingStrategyStore.getStrategy(object);
                stream.writeInt(index);
                ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategy(index);
                if(strategy.accept(object)){
                    strategy.write(stream, object);
                }
            }
View Full Code Here

TOP

Related Classes of java.io.ObjectOutputStream$Caches

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.