Package flex.messaging.io.amf

Examples of flex.messaging.io.amf.Amf3Output


  {
    // Create and instance of the byte array output stream to write the AMF3
    // object to.
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    // Create the AMF3Output object and set its output stream.
    final Amf3Output amf3Output = new Amf3Output(context);
    amf3Output.setOutputStream(bout);
    // Write the AMF3 object to the byte array output stream after
    // converting the source java object.
    amf3Output.writeObject(source);
    // Flush and close the stream.
    amf3Output.flush();
    amf3Output.close();
    return bout;
  }
View Full Code Here


     * current SerializationContext, OutputStream and debug trace settings
     * to switch the version of the AMF protocol mid-stream.
     */
    protected Amf3Output createAMF3Output()
    {
        return new Amf3Output(context);
    }
View Full Code Here

        writeObjectTraits(ti);

        if (externalizable)
        {
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            Amf3Output objOut = createAMF3Output();
            objOut.setOutputStream(bout);
            //objOut.setDebugTrace(trace);
            ((Externalizable)instance).writeExternal(objOut);
            writeByteArray(bout.toByteArray());
        }
        else if (propertyNames != null)
View Full Code Here

     *
     * @return The size of the message after message is serialized.
     */
    protected long getMessageSizeForPerformanceInfo(Message message)
    {
        Amf3Output amfOut = new Amf3Output(serializationContext);
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        DataOutputStream dataOutStream = new DataOutputStream(outStream);
        amfOut.setOutputStream(dataOutStream);     
        try
        {
            amfOut.writeObject(message);
        }
        catch (IOException e)
        {
            if (Log.isDebug())
                log.debug("MPI exception while retrieving the size of the serialized message: " + e.toString());             
View Full Code Here

               
        // Serialize each message as a separate chunk of bytes.
        TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
        for (Iterator iter = messages.iterator(); iter.hasNext();)
        {
            Amf3Output amfOut = getAmfOutput();
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            DataOutputStream dataOutStream = new DataOutputStream(outStream);
            amfOut.setOutputStream(dataOutStream);
           
            Message message = (Message)iter.next();
           
            // Add performance information if MPI is enabled.
            if (isRecordMessageSizes() || isRecordMessageTimes())
                addPerformanceInfo(message);
           
            if (Log.isDebug())
                log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
                       
            amfOut.writeObject(message);
            dataOutStream.flush();
            byte[] messageBytes = outStream.toByteArray();
            streamChunk(messageBytes, os, response);
           
            // Update the push count for the StreamingEndpoint mbean.
View Full Code Here

            {
                if (Log.isDebug())
                    log.debug("Endpoint with id '" + getId() + "' cannot use Java5 specific AMF output class: " + e.getMessage());
            }
        }
        return new Amf3Output(serializationContext);
    }
View Full Code Here

  {
    try
    {
      DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(servletOutputStream);
     
      Amf3Output amf3Output = new Amf3Output(serializationContext);
      amf3Output.setOutputStream(deflaterOutputStream); // compress
      amf3Output.writeObject(objToSerialize);
      amf3Output.flush();
     
      deflaterOutputStream.close(); // this is necessary to finish the compression
     
      /*
       * Do not call amf3Output.close() because that will
View Full Code Here

      testBean.setDocument(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
      testBean.setShort(new Short("99"));
      testBean.setString("test");
*/     
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      Amf3Output amf3Output = new Amf3Output(context);
      amf3Output.setOutputStream(bout);
      amf3Output.writeObject("hello world");
      amf3Output.flush();
      amf3Output.close();
      
      InputStream bIn = new ByteArrayInputStream(bout.toByteArray());
      Amf3Input amf3Input = new Amf3Input(context);
      amf3Input.setInputStream(bIn);
      /*      TestBean o = (TestBean) amf3Input.readObject();
View Full Code Here

  }

  public void writeTo(Object obj, Class realType, Type genericType, OutputStream stream) throws IOException {
    AMFMapper mapper = AMFMapperIntrospector.getAMFMapper(realType, genericType);
    SerializationContext context = new SerializationContext();
    Amf3Output output = new Amf3Output(context);
    output.setOutputStream(stream);
    output.writeObject(mapper.toAMF(obj, new AMFMappingContext()));
  }
View Full Code Here

     * current SerializationContext, OutputStream and debug trace settings
     * to switch the version of the AMF protocol mid-stream.
     */
    protected Amf3Output createAMF3Output()
    {
        return new Amf3Output(context);
    }
View Full Code Here

TOP

Related Classes of flex.messaging.io.amf.Amf3Output

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.