Providing AMF REST Resources in Java. 01.package net.java.ws.providers; 03.import javax.ws.rs.Consumes; 04.import javax.ws.rs.Produces; 05.import javax.ws.rs.WebApplicationException; 06.import javax.ws.rs.core.MediaType; 07.import javax.ws.rs.core.MultivaluedMap; 08.import javax.ws.rs.ext.MessageBodyReader; 09.import javax.ws.rs.ext.MessageBodyWriter; 10.import javax.ws.rs.ext.Provider; 11.import java.io.IOException; 12.import java.io.InputStream; 13.import java.io.OutputStream; 14.import java.lang.annotation.Annotation; 15.import java.lang.reflect.Type; 16.import flex.messaging.io.SerializationContext; 17.import flex.messaging.io.amf.Amf3Input; 18.import flex.messaging.io.amf.Amf3Output; 24. 25. 26. 27.public class AMFProvider implements MessageBodyReader, MessageBodyWriter { 29. public boolean isReadable(Class realType, Type genericType, Annotation[] annotations, MediaType mediaType) { 30. return true; 34. throws IOException, WebApplicationException { 35. 36. 37. input.setInputStream(stream); 38. return input.readObject(); 42. return true; 46.
OpenAMF - Java Flash Remoting | Get OpenAMF - Java Flash Remotin. 5 1/2 blog » Hacking AMFPHP into submission: Caching - Mozilla F. AMFEXT (An extension for AMFPHP performance boosting) I have been recently studying the AMF3.0. During this period had an impression that AMFPHP is faster than XML however after some research i had to look for some performance boosting tips for AMFPHP as the benchmarks by Mike Potter clearly says that the XML is having an upper hand in terms of data processing. Obviously i havn’t tested it yet on remote machines however some comment shows that this is an ideal case scenerio where the xml is not getting created instead it is just getting echoed in php.
Anyway i thought to keep on doing some research to find in more details on it. After some research i came across AMFEXT which is a PHP extension written in C that implements encoding and decoding of AMF and AMF3 messages for the PHP language. The major thing is that the performance with use of this extension boosts to 50-200 times which is exceptionally fast than using it with pure PHP setup. Here is the link to Patrick’s performance tests and some more details about the extension. Flash remoting for PHP: A responsive Client-Server Architecture. 5 1/2 blog. Development for the masses: AMF serialization from Java to Flex.
Import com.google.inject.Inject;import flex.messaging.endpoints.BaseHTTPEndpoint;import flex.messaging.io.SerializationContext;import flex.messaging.io.amf.Amf3Input;import flex.messaging.io.amf.Amf3Output;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import sun.misc.BASE64Decoder;import sun.misc.BASE64Encoder; /** * * @author ronen */public class AmfSerializer { @Inject private SerializationContext context; public <T> String toAmf(final T source) throws IOException { final StringBuffer buffer = new StringBuffer(); final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Amf3Output amf3Output = new Amf3Output(context); amf3Output.setOutputStream(bout); amf3Output.writeObject(source); amf3Output.flush(); amf3Output.close(); final BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(bout.toByteArray()); } package com.jdftm.vo; import java.util.Date; public class CurrentDayVO {