See https://github.com/fwolff/flex-vectors-example and especially
https://github.com/fwolff/flex-vectors-example/blob/master/java/org/granite/example/vectors/java/VectorService.java,
which shows how to serialize java arrays / collections as AMF vectors
(sorry this feature isn't well documented yet).

Franck.


2014-06-02 23:18 GMT+02:00 Gary Yang <flashflex...@gmail.com>:

> Hi Frank,
>
> I just did a little test against GraniteDS, it can parse bytes into Java
> Object very well even for strong typed vector array.
>
> But I don't see GraniteDS can convert a Java Array into Actionscript
> Vector, could you help me please?
>
>
> I also took a look in org.granite.messaging.amf.io.AMF3Serializer, it
> serializes all Java Collection into actionscript
> mx.collection.ArrayCollection, does mobile app based on Flex have
> ArrayCollection compiled in? Which is the best way to change this default
> behaviour please?
>
>
> Best,
>
> -Gary
>
>
>
>
>
> On Fri, May 30, 2014 at 12:02 PM, Gary Yang <flashflex...@gmail.com>
> wrote:
>
> > Right, I want to try GraniteDS because
> >
> > 1) Vector support is important!
> >
> > 2) BlazeDS is too old, 2011 code based on JDK5! No one can guarantee it
> > works with JDK8/Servlet3!!
> >
> >
> > But I am very sure BlazeDS can catch up very fast once development back
> on
> > track!
> >
> > -Gary
> >
> >
> > On Fri, May 30, 2014 at 11:50 AM, Christofer Dutz <
> > christofer.d...@c-ware.de> wrote:
> >
> >> Or we will be able to finally start tweaking BlazeDS as soon as we have
> >> the parity release out the door ;-)
> >>
> >> Chris
> >>
> >> -----Ursprüngliche Nachricht-----
> >> Von: Gary Yang [mailto:flashflex...@gmail.com]
> >> Gesendet: Freitag, 30. Mai 2014 17:14
> >> An: users@flex.apache.org
> >> Betreff: Re: AMF3 Serialization Benchmark (GraniteDS 3.1.0.M1 vs.
> BlazeDS
> >> 4.0.0)
> >>
> >> Franck,
> >>
> >> Very impressive!
> >>
> >> I guess it is time to switch to GraniteDS.
> >>
> >> Thanks.
> >>
> >> -Gary
> >>
> >>
> >>
> >> On Fri, May 30, 2014 at 4:41 AM, Franck Wolff <frawo...@gmail.com>
> wrote:
> >>
> >> > Gary,
> >> >
> >> > Just have a look at the link I gave you before:
> >> >
> >> >
> https://github.com/fwolff/amf-benchmark/blob/master/src/org/granite/be
> >> > nchmark/amf/BenchmarkGraniteDSAmf.java
> >> > .
> >> > It doesn't run inside a servlet container, does it?
> >> >
> >> > F.
> >> >
> >> >
> >> > 2014-05-29 17:22 GMT+02:00 Gary Yang <flashflex...@gmail.com>:
> >> >
> >> > > Franck,
> >> > >
> >> > > Does GraniteDS have to run inside a servlet container? I only want
> >> > > to AMF serialization/deserialization function which has nothing to
> >> > > do with network, http or servlet.
> >> > >
> >> > > thanks.
> >> > >
> >> > > -Gary
> >> > >
> >> > >
> >> > > On Thu, May 29, 2014 at 7:44 AM, Franck Wolff <frawo...@gmail.com>
> >> > wrote:
> >> > >
> >> > > > Gary,
> >> > > >
> >> > > > See the benchmark classes:
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> https://github.com/fwolff/amf-benchmark/blob/master/src/org/granite/be
> >> > nchmark/amf/BenchmarkBlazeDSAmf.java
> >> > > > vs.
> >> > > >
> >> > > >
> >> > >
> >> >
> https://github.com/fwolff/amf-benchmark/blob/master/src/org/granite/be
> >> > nchmark/amf/BenchmarkGraniteDSAmf.java
> >> > > >
> >> > > > GraniteDS needs a bit more configuration, but is still very easy
> >> > > > to
> >> > use.
> >> > > >
> >> > > > BTW, about DTOs: you can have a look to our Converter/Reverter
> >> > > > feature, even if it isn't meant to be used this way in the first
> >> > > > place (see documentation
> >> > > >
> >> > > >
> >> > >
> >> >
> http://www.granitedataservices.com/public/docs/latest/docs/reference/f
> >> > lex/graniteds-refguide-flex.html#extensibility.customtypes
> >> > > > ).
> >> > > >
> >> > > > Let's say you have a bean MyBean on your server and you want to
> >> > serialize
> >> > > > MyBeanDTO instead (and vice-versa). You can easily write this kind
> >> > > > of
> >> > > > converter:
> >> > > >
> >> > > > public class MyBeanConverter extends Converter implements Reverter
> >> > > > {
> >> > > >
> >> > > >     public MyBeanConverter(Converters converters) {
> >> > > >         super(converters);
> >> > > >     }
> >> > > >
> >> > > >     // AMF3Deserialization (Converter)...
> >> > > >
> >> > > >     @Override
> >> > > >     protected boolean internalCanConvert(Object value, Type
> >> > targetType) {
> >> > > >     return (value instanceof MyBeanDTO);
> >> > > >     }
> >> > > >
> >> > > >     @Override
> >> > > >     protected Object internalConvert(Object value, Type
> targetType)
> >> {
> >> > > >     MyBean bean = new MyBean();
> >> > > >     MyBeanDTO dto = (MyBeanDTO)value;
> >> > > >     // copy properties from dto to bean...
> >> > > >         return bean;
> >> > > >     }
> >> > > >
> >> > > >     // AMF3Serialization (Reverter)...
> >> > > >
> >> > > >     public boolean canRevert(Object value) {
> >> > > >         return (value instanceof MyBean);
> >> > > >     }
> >> > > >
> >> > > >     public Object revert(Object value) {
> >> > > >     MyBeanDTO dto = new MyBeanDTO();
> >> > > >     MyBean bean = (MyBean)value;
> >> > > >     // copy properties from bean to dto...
> >> > > >         return dto;
> >> > > >     }
> >> > > > }
> >> > > >
> >> > > > Then, just plug this new converter (along with any others) in your
> >> > > > granite-config.xml:
> >> > > >
> >> > > > <granite-config>
> >> > > >   <converters>
> >> > > >     <converter type="path.to.MyBeanConverter" />
> >> > > >   </converters>
> >> > > > </granite-config>
> >> > > >
> >> > > > According to this configuration, all MyBean instances will be
> >> > serialized
> >> > > as
> >> > > > MyBeanDTOs and all MyBeanDTOs will be deserialized as MyBeans (you
> >> > don't
> >> > > > need to anything else, your services can return eg. a collection
> >> > > > of
> >> > > MyBeans
> >> > > > it will be serialized as a collection of MyBeanDTOs). Of course,
> >> > > > it can
> >> > > be
> >> > > > a bit restrictive if you want to have different DTOs classes for a
> >> > > > same bean class...
> >> > > >
> >> > > > Franck.
> >> > > >
> >> > > >
> >> > > > 2014-05-29 2:33 GMT+02:00 Gary Yang <flashflex...@gmail.com>:
> >> > > >
> >> > > > > Sounds great!
> >> > > > >
> >> > > > > Do you think it is possible that I can use the
> >> > > > > serialization/deserialization features as simple as using
> >> > > > > BlazeDS
> >> > like
> >> > > > > below?
> >> > > > >
> >> > > > >
> >> > > > > in pom.xml :
> >> > > > >
> >> > > > >         <dependency>
> >> > > > >             <groupId>org.springframework.flex</groupId>
> >> > > > >             <artifactId>spring-flex-core</artifactId>
> >> > > > >         </dependency>
> >> > > > >
> >> > > > > then in Java file:
> >> > > > >
> >> > > > >         ... ...
> >> > > > >
> >> > > > >         Amf3Output aOut= new Amf3Output(new
> >> SerializationContext());
> >> > > > >         aOut.setOutputStream( outStream );
> >> > > > >         aOut.writeObject(data);
> >> > > > >
> >> > > > >         ... ...
> >> > > > >
> >> > > > >         Amf3Input aIn = new Amf3Input( new
> SerializationContext()
> >> );
> >> > > > >         aIn.setInputStream( inputStream );
> >> > > > >         data = aIn.readObject();
> >> > > > >
> >> > > > > Thanks.
> >> > > > >
> >> > > > >
> >> > > > > - Gary
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > On Wed, May 14, 2014 at 8:51 AM, Franck Wolff
> >> > > > > <frawo...@gmail.com>
> >> > > > wrote:
> >> > > > >
> >> > > > > > Hi everybody,
> >> > > > > >
> >> > > > > > We have just published the benchmark results on the GraniteDS
> >> blog:
> >> > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> http://www.granitedataservices.com/2014/05/14/amf3-benchmark-graniteds
> >> > -3-1-vs-blazeds-4-0
> >> > > > > > .
> >> > > > > >
> >> > > > > > Feedback would be very appreciated.
> >> > > > > >
> >> > > > > > Franck
> >> > > > > > @graniteds
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
> >
>

Reply via email to