Package flex.messaging.io.amf

Examples of flex.messaging.io.amf.Amf3Input


   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public <T> T fromAmf(final ByteArrayInputStream amf)
      throws ClassNotFoundException, IOException {
    Amf3Input amf3Input = new Amf3Input(context);
    amf3Input.setInputStream(amf);
    // Read object does the actual work of conversion.
    return (T) amf3Input.readObject();
  }
View Full Code Here


    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {
        Object saveObjectTable = null;
        Object saveTraitsTable = null;
        Object saveStringTable = null;
        Amf3Input in3 = null;

        if (in instanceof Amf3Input)
            in3 = (Amf3Input) in;

        try
        {
            if (in3 != null)
            {
                saveObjectTable = in3.saveObjectTable();
                saveTraitsTable = in3.saveTraitsTable();
                saveStringTable = in3.saveStringTable();
            }

            this.defaultInstance = in.readObject();
        }
        finally
        {
            if (in3 != null)
            {
                in3.restoreObjectTable(saveObjectTable);
                in3.restoreTraitsTable(saveTraitsTable);
                in3.restoreStringTable(saveStringTable);
            }
        }
    }
View Full Code Here

        if (obj instanceof Externalizable)
        {
            if (value != null && value.getClass().isArray() && Byte.TYPE.equals(value.getClass().getComponentType()))
            {
                Externalizable extern = (Externalizable)obj;
                Amf3Input objIn = new Amf3Input(context);
                byte[] ba = (byte[])value;
                ByteArrayInputStream baIn = new ByteArrayInputStream(ba);
                try
                {
                    //objIn.setDebugTrace(trace);
                    objIn.setInputStream(baIn);
                    extern.readExternal(objIn);
                }
                catch (ClassNotFoundException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                catch (IOException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                finally
                {
                    try
                    {
                        objIn.close();
                    }
                    catch (IOException ex)
                    {
                    }
                }
View Full Code Here

  //  De-serialize a ByteArray/AMF3/Flex object to a Java object 
  protected ASObject deserializeAmf3(InputStream inputStream) throws ClassNotFoundException, IOException
  {
    ASObject deSerializedObj = null;
 
    Amf3Input amf3Input = new Amf3Input(serializationContext);
    amf3Input.setInputStream(inputStream); // uncompress
    deSerializedObj = (ASObject) amf3Input.readObject();
    //amf3Input.close();

    return deSerializedObj;
  }
View Full Code Here

      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();
      
      System.out.println(o.getByte().equals(testBean.getByte()));
      System.out.println(o.getBigDecimal().equals(testBean.getBigDecimal()));
      System.out.println(o.getBoolean().equals(testBean.getBoolean()));
View Full Code Here

  }

  public Object readFrom(Class realType, Type genericType, InputStream stream) throws IOException {
    AMFMapper mapper = AMFMapperIntrospector.getAMFMapper(realType, genericType);
    SerializationContext context = new SerializationContext();
    Amf3Input input = new Amf3Input(context);
    input.setInputStream(stream);
    try {
      return mapper.toJAXB(input.readObject(), new AMFMappingContext());
    }
    catch (ClassNotFoundException e) {
      throw new IOException("Invalid request: " + e.getMessage());
    }
  }
View Full Code Here

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {
        Object saveObjectTable = null;
        Object saveTraitsTable = null;
        Object saveStringTable = null;
        Amf3Input in3 = null;

        if (in instanceof Amf3Input)
            in3 = (Amf3Input) in;

        try
        {
            if (in3 != null)
            {
                saveObjectTable = in3.saveObjectTable();
                saveTraitsTable = in3.saveTraitsTable();
                saveStringTable = in3.saveStringTable();
            }

            this.defaultInstance = in.readObject();
        }
        finally
        {
            if (in3 != null)
            {
                in3.restoreObjectTable(saveObjectTable);
                in3.restoreTraitsTable(saveTraitsTable);
                in3.restoreStringTable(saveStringTable);
            }
        }
    }
View Full Code Here

        if (obj instanceof Externalizable)
        {
            if (value != null && value.getClass().isArray() && Byte.TYPE.equals(value.getClass().getComponentType()))
            {
                Externalizable extern = (Externalizable)obj;
                Amf3Input objIn = new Amf3Input(context);
                byte[] ba = (byte[])value;
                ByteArrayInputStream baIn = new ByteArrayInputStream(ba);
                try
                {
                    //objIn.setDebugTrace(trace);
                    objIn.setInputStream(baIn);
                    extern.readExternal(objIn);
                }
                catch (ClassNotFoundException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                catch (IOException ex)
                {
                    throw new MessageException("Error while reading Externalizable class " + extern.getClass().getName(), ex);
                }
                finally
                {
                    try
                    {
                        objIn.close();
                    }
                    catch (IOException ex)
                    {
                    }
                }
View Full Code Here

TOP

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

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.