flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Yang <flashflex...@gmail.com>
Subject Re: AMF3 Serialization Benchmark (GraniteDS 3.1.0.M1 vs. BlazeDS 4.0.0)
Date Thu, 29 May 2014 15:22:10 GMT
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 <frawolff@gmail.com> wrote:

> Gary,
>
> See the benchmark classes:
>
>
> https://github.com/fwolff/amf-benchmark/blob/master/src/org/granite/benchmark/amf/BenchmarkBlazeDSAmf.java
> vs.
>
> https://github.com/fwolff/amf-benchmark/blob/master/src/org/granite/benchmark/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/flex/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 <flashflexpro@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 <frawolff@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
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message