Package flex.messaging.io

Examples of flex.messaging.io.PropertyProxy


                Object item = it.next();
                if (item != null && descriptor != null && !(item instanceof String)
                        && !(item instanceof Number) && !(item instanceof Boolean)
                        && !(item instanceof Character))
                {
                    PropertyProxy proxy = PropertyProxyRegistry.getProxy(item);
                    proxy = (PropertyProxy)proxy.clone();
                    proxy.setDescriptor(descriptor);
                    item = proxy;
                }
                writeObject(item);
            }
View Full Code Here


                if (desc != null)
                    ac.setDescriptor(desc);
            }

            // Then wrap ArrayCollection in PropertyProxy for bean-like serialization
            PropertyProxy proxy = PropertyProxyRegistry.getProxy(ac);
            writePropertyProxy(proxy, ac);
        }
    }
View Full Code Here

    /**
     * @exclude
     */
    protected void writeCustomObject(Object o) throws IOException
    {
        PropertyProxy proxy = null;

        if (o instanceof PropertyProxy)
        {
            proxy = (PropertyProxy)o;
            o = proxy.getDefaultInstance();

            // The proxy may wrap a null default instance, if so, short circuit here.
            if (o == null)
            {
                writeAMFNull();
                return;
            }
            // HACK: Short circuit and unwrap if PropertyProxy is wrapping an Array
            // or Collection type since we don't yet have the ability to proxy multiple
            // AMF types. We write an AMF Array directly instead of an AMF Object
            else if (o instanceof Collection)
            {
                if (context.legacyCollection)
                    writeCollection((Collection)o, proxy.getDescriptor());
                else
                    writeArrayCollection((Collection)o, proxy.getDescriptor());
                return;
            }
            else if (o.getClass().isArray())
            {
                writeObjectArray((Object[])o, proxy.getDescriptor());
                return;
            }
            else if (context.legacyMap && o instanceof Map && !(o instanceof ASObject))
            {
                writeMapAsECMAArray((Map)o);
View Full Code Here

                    trace.write("(Document not printable)");
                }
            }
            else
            {
                PropertyProxy proxy = PropertyProxyRegistry.getProxy(o);
               
                if (o instanceof PrettyPrintable)
                {
                    PrettyPrintable pp = (PrettyPrintable)o;
                    header.append(pp.toStringHeader());
                }
                else
                {
                    header.append(c.getName());
                    if (o instanceof Map)
                    {
                        header.append(" (Map size:").append(((Map)o).size()).append(")");
                    }
                }

                trace.startObject(header.toString());

                List propertyNames = proxy.getPropertyNames();
                if (propertyNames != null)
                {
                    Iterator it = propertyNames.iterator();
                    while (it.hasNext())
                    {
                        String propName = (String)it.next();
                        trace.namedElement(propName);
                       
                        Object value = null;
                        if (trace.nextElementExclude)
                        {
                            trace.nextElementExclude = false;
                            value = Log.VALUE_SUPRESSED;
                        }
                        else
                        {
                            if (o instanceof PrettyPrintable)
                            {
                                String customToString = ((PrettyPrintable)o).toStringCustomProperty(propName);
                                if (customToString != null)
                                {
                                    value = customToString;
                                }
                            }


                            if (value == null)
                            {
                                value = proxy.getValue(propName);
                            }
                        }

                        internalPrettify(value);
                        trace.newLine();
View Full Code Here

    /**
     * Deserialize the bits of a map w/o a prefixing type byte.
     */
    protected Object readObjectValue(String className) throws ClassNotFoundException, IOException
    {
        PropertyProxy proxy = null;
        Object object;

        // Check for any registered class aliases
        String aliasedClass = ClassAliasRegistry.getRegistry().getClassName(className);
        if (aliasedClass != null)
            className = aliasedClass;

        if (className == null || className.length() == 0)
        {
            object = new ASObject();
        }
        else if (className.startsWith(">")) // Handle [RemoteClass] (no server alias)
        {
            object = new ASObject();
            ((ASObject)object).setType(className);
        }
        else if (context.instantiateTypes || className.startsWith("flex."))
        {
            Class desiredClass = AbstractProxy.getClassFromClassName(className, context.createASObjectForMissingType);

            proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass);

            if (proxy == null)
                object = ClassUtil.createDefaultInstance(desiredClass, null);
            else
                object = proxy.createInstance(className);
        }
        else
        {
            // Just return type info with an ASObject...
            object = new ASObject();
            ((ASObject)object).setType(className);
        }

        if (proxy == null)
            proxy = PropertyProxyRegistry.getProxyAndRegister(object);

        int objectId = rememberObject(object);

        if (isDebug)
            trace.startAMFObject(className, objectsTable.size() - 1);

        String propertyName = in.readUTF();
        int type = in.readByte();
        while (type != kObjectEndType)
        {
            if (isDebug)
                trace.namedElement(propertyName);

            Object value = readObjectValue(type);
            proxy.setValue(object, propertyName, value);
            propertyName = in.readUTF();
            type = in.readByte();
        }

        if (isDebug)
            trace.endAMFObject();

        // This lets the BeanProxy substitute a new instance into the BeanProxy
        // at the end of the serialization.  You might for example create a Map, store up
        // the properties, then construct the instance based on that.  Note that this does
        // not support recursive references to the parent object however.
        Object newObj = proxy.instanceComplete(object);

        // TODO: It is possible we gave out references to the
        // temporary object.  it would be possible to warn users about
        // that problem by tracking if we read any references to this object
        // in the readObject call above.
View Full Code Here

    // <object type="com.my.Class">

    public void start_object(Attributes attributes)
    {
        PropertyProxy proxy = null;

        String type = attributes.getValue("type");
        if (type != null)
        {
            type = type.trim();
        }

        Object object;
       
        if (type != null && type.length() > 0)
        {
            // Check for any registered class aliases
            String aliasedClass = ClassAliasRegistry.getRegistry().getClassName(type);
            if (aliasedClass != null)
                type = aliasedClass;

            if (type == null || type.length() == 0)
            {
                object = new ASObject();
            }
            else if (type.startsWith(">")) // Handle [RemoteClass] (no server alias)
            {
                object = new ASObject();
                ((ASObject)object).setType(type);
            }
            else if (context.instantiateTypes || type.startsWith("flex."))
            {
                Class desiredClass = AbstractProxy.getClassFromClassName(type, context.createASObjectForMissingType);

                proxy = PropertyProxyRegistry.getRegistry().getProxyAndRegister(desiredClass);

                if (proxy == null)
                    object = ClassUtil.createDefaultInstance(desiredClass, null);
                else
                    object = proxy.createInstance(type);
            }
            else
            {
                // Just return type info with an ASObject...
                object = new ASObject();
View Full Code Here

            traitsStack.pop();
       
        if (!objectStack.empty())
        {
            Object obj = objectStack.pop();
            PropertyProxy proxy = (PropertyProxy) proxyStack.pop();

            Object newObj = proxy == null ? obj : proxy.instanceComplete(obj);
            if (newObj != obj)
            {
                int i;
                // Find the index in the list of the old objct and replace it with
                // the new one.
View Full Code Here

            }

            try
            {
                // Then check if there's a more suitable proxy now that we have an instance
                PropertyProxy proxy = (PropertyProxy) proxyStack.peek();
                if (proxy == null)
                    proxy = beanproxy;
                proxy.setValue(obj, prop, value);
            }
            catch (Exception ex)
            {
                throw new MessageException("Failed to set property '" + prop + "' with value: " + value, ex);
            }
View Full Code Here

                if (desc != null)
                    ac.setDescriptor(desc);
            }

            // Then wrap ArrayCollection in PropertyProxy for bean-like serialization
            PropertyProxy proxy = PropertyProxyRegistry.getProxy(ac);
            writePropertyProxy(proxy, ac);
        }
    }
View Full Code Here

    /**
     * @exclude
     */
    protected void writeCustomObject(Object o) throws IOException
    {
        PropertyProxy proxy = null;

        if (o instanceof PropertyProxy)
        {
            proxy = (PropertyProxy)o;
            o = proxy.getDefaultInstance();

            // The proxy may wrap a null default instance, if so, short circuit here.
            if (o == null)
            {
                writeAMFNull();
                return;
            }
            // HACK: Short circuit and unwrap if PropertyProxy is wrapping an Array
            // or Collection type since we don't yet have the ability to proxy multiple
            // AMF types. We write an AMF Array directly instead of an AMF Object
            else if (o instanceof Collection)
            {
                if (context.legacyCollection)
                    writeCollection((Collection)o, proxy.getDescriptor());
                else
                    writeArrayCollection((Collection)o, proxy.getDescriptor());
                return;
            }
            else if (o.getClass().isArray())
            {
                writeObjectArray((Object[])o, proxy.getDescriptor());
                return;
            }
            else if (context.legacyMap && o instanceof Map && !(o instanceof ASObject))
            {
                writeMapAsECMAArray((Map)o);
View Full Code Here

TOP

Related Classes of flex.messaging.io.PropertyProxy

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.