Gary,

I have implemented a bidirectional serialization of Vectors in GraniteDS
trunk (so it's going to be available in the upcoming 3.0.0.RC1 release).

I have put together a sample project here:
https://github.com/fwolff/flex-vectors-example (read instructions on the
landing page).

Basically, you can now serialize any Java array or Collection as an AS3
Vector with the help of the following annotations (pseudo Java code with
default values):

@AMFVectorInt(boolean fixed = false) // fixed means fixed size. Apply to
any array or Collection of java.lang.Number (or primitives).
@AMFVectorUint(boolean fixed = false) // idem.
@AMFVectorNumber(boolean fixed = false) // idem.
@AMFVectorObject(String type = "", boolean fixed = false) // type = "" -->
GraniteDS will try to guess the type of the Vector components (eg. "String"
for "java.lang.String").

Have a look at the source code of the sample to understand how to use it
(I'm to lazy to explain everything in this post).

Speaking of laziness, here are the current limitations of this
implementation:

1. You can't serialize Vector of Vectors (or a Vector in a collection, etc.)
2. This feature won't work with the "externalizer" feature of GraniteDS: it
would require to modify the code generator (the easy part) and to have
another implementation of persistent collections so transparent
lazy-loading with Tide would work with vectors (the hard part).

Anyway, I'd like to have your feedback about it and comments about how to
improve it.

Regards,
Franck.


2013/8/21 Gary Young <[email protected]>

> They don't, I have to convert Array to Vector.
>
> Actionscript's Vector is not perfect, element type has no inheritance,
> Vector.<Sprite> is Vector.<DisplayObject> will return false. and if a
> function accept parameter type Vector.<Sprite> won't accept
> Vector.<DisplayObject>.
>
> So I think your @Vector should assign a type for each element, so that
> client can use directly.
>
> thanks.
>
> -Gary
>
>
>
> On Wed, Aug 21, 2013 at 10:08 AM, Franck Wolff
> <[email protected]>wrote:
>
> > Gary,
> >
> > GraniteDS has standard support for AS Vector ---> Java array (or any
> other
> > collection type) serialization. Java array (collections) ---> Vector
> needs
> > additional care: there is no mean to know what's the client application
> is
> > expecting, hence Java collections and arrays are serialized respectively
> > as ArrayCollection and Array...
> >
> > As a (bad, I admit) workaround, you can plug into GraniteDS a specific
> AMF3
> > serializer that will override standard array/collection serialization to
> > get a vector on the Flex side.
> >
> > What we could certainly do is to add support for a specific Java
> annotation
> > (say @Vector) that will tell the serializer to send Vectors instead of
> > ArrayCollections / Arrays when it finds it on a bean property. I'm
> thinking
> > about something like:
> >
> > @Vector
> > private String[] stringArray;
> >
> > @Vector
> > private List<String> stringList;
> >
> > or even
> >
> > @Vector
> > public List<String> getStringList() { ... }
> >
> > I think it would be pretty easy to implement such feature and I can
> > certainly plan it for the next release (3.0.0.RC1).
> >
> > Since you seem to be using another server-side solution (BlazeDS / LCDS /
> > ?), how do they achieve AS Vector <---> Java array / collection
> > serialization?
> >
> > Franck.
> >
> >
> > 2013/8/21 Gary Young <[email protected]>
> >
> > > Quick question: Does GraniteDS 3 support  Actionscript Vector <----->
> > Java
> > > Array?
> > >
> > >
> > > On Wed, Aug 21, 2013 at 8:00 AM, Franck Wolff <
> > [email protected]
> > > >wrote:
> > >
> > > > Thanks Paul.
> > > >
> > > > The correct link is of course:
> > > >
> > > >
> > >
> >
> http://granitedataservices.com/blog/2013/08/20/graniteds-3-0-0-m3-is-out/(without
> > > > "*.*").
> > > >
> > > > BTW: sorry for the double posts, I'm a bit confused with "
> > > > [email protected]" and the old "[email protected]
> > "...
> > > >
> > > > Franck.
> > > >
> > > > 2013/8/21 Paul Hastings <[email protected]>
> > > >
> > > > > On 8/21/2013 5:36 PM, Franck Wolff wrote:
> > > > >
> > > > >> http://granitedataservices.**com/blog/2013/08/20/graniteds-**
> > > > >> 3-0-0-m3-is-out/*.*<
> > > >
> > >
> >
> http://granitedataservices.com/blog/2013/08/20/graniteds-3-0-0-m3-is-out/*.*
> > > > >
> > > > >>
> > > > >
> > > > > your link is messed up a bit ("*.*").
> > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to