Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support For BlazeDS & Fixed ArrayCollection Deserialization #2

Closed
wants to merge 4 commits into from

Conversation

davidef
Copy link

@davidef davidef commented Oct 24, 2013

No description provided.

@emilkm
Copy link
Owner

emilkm commented Oct 25, 2013

You are quite right about the externalizable flag. I haven't dealt with it in readScriptObject.

Do you intend to use externalizable objects?

flex.messaging.io.amf.Amf3Types.java

public interface Amf3Types
{
    // AMF marker constants
    int kUndefinedType  = 0;
    int kNullType       = 1;
    int kFalseType      = 2;
    int kTrueType       = 3;
    int kIntegerType    = 4;
    int kDoubleType     = 5;
    int kStringType     = 6;
    int kXMLType        = 7;
    int kDateType       = 8;
    int kArrayType      = 9;
    int kObjectType     = 10;
    int kAvmPlusXmlType = 11;
    int kByteArrayType  = 12;
    int kTypedVectorInt = 13;
    int kTypedVectorUint= 14;
    int kTypedVectorDouble = 15;
    int kTypedVectorObject = 16;
    int kDictionaryType = 17;

0x11 = 17 the kDictionaryType

flex.messaging.io.amf.Amf3Input.java

    public Object readObject() throws ClassNotFoundException, IOException
    {
        int type = in.readByte();
        Object value = readObjectValue(type);
        return value;
    }

type is read here and passed to readObjectValue

    protected Object readObjectValue(int type) throws ClassNotFoundException, IOException
    {
        Object value = null;

        switch (type)
        {
            ...

            case kObjectType:
                value = readScriptObject();
                break;

             ...

            case kDictionaryType:
                value = readDictionary();
                break;

            ...               
        }

        return value;
    }

When the marker is kObjectType 10 then readScriptObject does the work.

Based on the BlazeDS implementation of readTraits, I would stick with boolean dynamic = ((ref & 8) == 8);

When the marker is kDictionaryType 17 then readDictionary does the work. Except I haven't implemented it.
If you are using Dictionary type in Java and sending to JavaScript can you give me a small snippet.

Also can you give me a small Java snippet of your ArrayCollection usage.

I would like to test any changes to make sure PHP server is still happy.

@davidef
Copy link
Author

davidef commented Oct 25, 2013

Any Java object which implements java.util.Collection (any List or Set) get automatically mapped to flex.messaging.io.ArrayCollection
just declare a service method like

public List<String> test(){
  return Arrays.asList("a","b","c");
}

Edit: in the current code we don't uses dictionaries but always strictly typed object. In a later commit we added the ability to register javascript class to be used (if found) when deserializing the objects

@ghost ghost assigned emilkm Oct 26, 2013
@emilkm
Copy link
Owner

emilkm commented Oct 26, 2013

I have committed some changes based on your messageId sending. Just making it conditional based on a amf.sendMessageId setting.

Since you do not use Dictionary for now I will not worry about.

Working on setting up a simple Java server to test working with collections.

I noticed your class registry change. If it works for you, I would be happy to see a simple example that I can put in the documentation and pull it in.

Would be interested to know what project you are working on.

@davidef
Copy link
Author

davidef commented Oct 28, 2013

I've just merged your changes (I've to do some fixes to handle externalizable objects).
In my branch there is also a class registry to allow js "strict" typing in deserialization (I've done that so I can add methods to the deserialized objects)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants