Package flex.messaging.io

Examples of flex.messaging.io.SerializationContext


    }   
  }

  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());
    }
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

            close();
        }

        this.url = url;
        try {
            serializationContext = new SerializationContext();
            serializationContext.createASObjectForMissingType = true;
            internalConnect();
        } catch (IOException e) {
            ClientStatusException exception = new ClientStatusException(e, ClientStatusException.AMF_CONNECT_FAILED_CODE);
            throw exception;
View Full Code Here

        if (source == null && !desiredClass.isPrimitive())
        {
            return null;
        }

        SerializationContext serializationContext = SerializationContext.getSerializationContext();

        ActionScriptDecoder decoder;
        if (serializationContext.restoreReferences)
            decoder = DecoderFactory.getReferenceAwareDecoder(source, desiredClass);
        else
View Full Code Here

        // Log input/output for debug level
        AmfTrace debugTrace = isDebug ? new AmfTrace() : null;

        // Create an empty ActionMessage object to hold our response
        context.setResponseMessage(new ActionMessage());
        SerializationContext sc = SerializationContext.getSerializationContext();

        try
        {
            // Deserialize the input stream into an "ActionMessage" object.
            MessageDeserializer deserializer = sc.newMessageDeserializer();

            // Set up the deserialization context
            InputStream in = FlexContext.getHttpRequest().getInputStream();
            deserializer.initialize(sc, in, debugTrace);

            // record the length of the input stream for performance metrics
            int reqLen = FlexContext.getHttpRequest().getContentLength();
            context.setDeserializedBytes(reqLen);

            // set up the incoming MPI info if it is enabled           
            if(context.isMPIenabled())
            {
              MessagePerformanceInfo mpi = new MessagePerformanceInfo();
              mpi.recordMessageSizes = context.isRecordMessageSizes();
              mpi.recordMessageTimes = context.isRecordMessageTimes();
              if(context.isRecordMessageTimes())
                mpi.receiveTime = System.currentTimeMillis();
              if(context.isRecordMessageSizes())
                mpi.messageSize =reqLen;
             
              context.setMPII(mpi);
            }

            ActionMessage m = new ActionMessage();
            context.setRequestMessage(m);
            deserializer.readMessage(m, context);
            success = true;
        }
        catch (EOFException eof)
        {
            context.setStatus(MessageIOConstants.STATUS_NOTAMF);
        }
        catch (IOException exc)
        {
            if (isDebug)
                logger.debug("IOException reading message - client closed socket before sending the message?");

            throw exc;
        }
        catch (Throwable t)
        {
            deserializationError(context, t);
        }
        finally
        {
            // Use the same ActionMessage version for the response
            ActionMessage respMsg = context.getResponseMessage();
            respMsg.setVersion(context.getVersion());

            if (isDebug)
                logger.debug(debugTrace.toString());
        }

        try
        {
            if (success)
            {
                next.invoke(context);
            }
        }
        catch (Throwable t)
        {
            unhandledError(context, t);
        }
        finally
        {
            // serialize output
            if (context.getStatus() != MessageIOConstants.STATUS_NOTAMF)
            {
                ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();                              
                ActionMessage respMesg = context.getResponseMessage();

                if (isDebug)
                {
                    debugTrace = new AmfTrace();
                }

                try
                {
                    // overhead calculation is only necessary when MPI is enabled
                    long serializationOverhead=0;
                    if(context.isRecordMessageTimes())
                    {               
                      // set server send time
                      context.getMPIO().sendTime = System.currentTimeMillis();
                        if(context.isRecordMessageSizes())
                          serializationOverhead = System.currentTimeMillis();                     
                    }                  
                    MessageSerializer serializer = sc.newMessageSerializer();
                    serializer.initialize(sc, outBuffer, debugTrace);
                    serializer.writeMessage(respMesg);
                   
                    // keep track of serializes bytes for performance metrics
                    context.setSerializedBytes(outBuffer.size());
                   
                    // serialized message again after adding info if mpio with sizing is enabled
                    if(context.isRecordMessageSizes())
                    {
                      try
                      {                       
                        context.getMPIO().messageSize = outBuffer.size();
                       
                        // reset server send time     
                        if(context.isRecordMessageTimes())
                        {
                            serializationOverhead = System.currentTimeMillis() - serializationOverhead;
                            context.getMPIO().addToOverhead(serializationOverhead);
                              context.getMPIO().sendTime = System.currentTimeMillis();
                        }
                       
                        // reserialize the message now that info has been added
                        outBuffer = new ByteArrayOutputStream();
                        respMesg = context.getResponseMessage();
                        serializer = sc.newMessageSerializer();
                        serializer.initialize(sc, outBuffer, debugTrace);
                        serializer.writeMessage(respMesg);
                      }
                      catch(Exception e)
                      {
View Full Code Here

        if (Log.isError())
            logger.error("Exception occurred during serialization: " + ExceptionUtil.toString(t));

        // serialize the error messages
        SerializationContext sc = SerializationContext.getSerializationContext();
        MessageSerializer serializer = sc.newMessageSerializer();
        ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
        AmfTrace debugTrace = isDebug ? new AmfTrace() : null;
        serializer.initialize(sc, outBuffer, debugTrace);

        try
View Full Code Here

     */
    public AbstractEndpoint(boolean enableManagement)
    {
        super(enableManagement);
        this.log = Log.getLogger(getLogCategory());
        serializationContext = new SerializationContext();
    }
View Full Code Here

      AmfTrace trace = null;
      trace = new AmfTrace();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      AmfMessageSerializer amfser = new AmfMessageSerializer();
      SerializationContext context = SerializationContext.getSerializationContext();
      context.instantiateTypes = false;
      amfser.initialize(context, baos, trace);
      amfser.writeMessage(message);
      messageBytes = baos.toByteArray();
View Full Code Here

      if (DEBUG)
        trace = new AmfTrace();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      AmfMessageSerializer amfser = new AmfMessageSerializer();
      SerializationContext context = SerializationContext
          .getSerializationContext();
      context.instantiateTypes = false;
      amfser.initialize(context, baos, trace);
      amfser.writeMessage(message);
      messageBytes = baos.toByteArray();
View Full Code Here

TOP

Related Classes of flex.messaging.io.SerializationContext

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.