Flash Player (GMT +X) -> IExternizable methods (GMT + X - X = GMT + 0) - > AMF over HTTP (GMT + 0) -> Granite AMF0Deserializer (GMT + 0) -> Granite Converter (GMT + 0 + Y = GMT + Y) -> Java Services (GMT + Y)Java Services (GMT + Y) -> Granite Converter (GMT + Y - Y = GMT + 0) -> Granite AMF0Deserializer (GMT + 0) -> AMF over HTTP (GMT + 0) -> IExternizable methods (GMT + 0 + X = GMT + X) -> Flash Player (GMT + X)
We use
GMT + 0
for AMF for convention
define a
fixed timezone
for your AMF that is over HTTP
GMT + X
: timezone for your flex client
GMT + Y
: timezone for your server
don't want to modify the default templates
override the readExternal / writeExternal methods and do the conversion here.
The patch is to use a custom template for generating your as files with a conversion to GMT 0 in the implementations of IExternalizable methods.On the server-side you add a Converter to convert dates GMT 0 to dates GMT + Y.
differences between CDI beans and EJBs is that EJBs are :
Transactional
Remote or local
Able to passivate stateful beans freeing up resources
Able to make use of timers
Can be asynchronous
Stateless EJBs can be thought of as thread safe single-use beans that don’t maintain any state between two web requests
Stateful EJBs do hold state and can be created and sit around for as long as they are needed until they are disposed of
Stateless beans must have a dependent scope while a stateful session bean can have any scope. By default they are transactional, but you can use the transaction attribute annotation.
CDI beans can be injected into EJBs and EJBs can be injected into CDI beans
When to use which bean
How do you know when to use which bean? Simple.
In general, you should use CDI beans unless you need the advanced functionality available in the EJBs such as transactional functions. You can write your own interceptor to make CDI beans transactional, but for now, its simpler to use an EJB until CDI gets transactional CDI beans which is just around the corner
Comparing JSF Beans, CDI Beans and EJBs
JSF Managed Beans
In short, don’t use them if you are developing for Java EE 6 and using CDI. They provide a simple mechanism for dependency injection and defining backing beans for web pages, but they are far less powerful than CDI beans.
JSF beans cannot be mixed with other kinds of beans without some kind of manual coding.
CDI Beans
includes a complete, comprehensive managed bean facility
interceptors, conversation scope, Events, type safe injection, decorators, stereotypes and producer methods
JSF-like features, you can define the scope of the CDI bean using one of the scopes defined in the javax.enterprise.context package (namely, request, conversation, session and application scopes). If you want to use the CDI bean from a JSF page, you can give it a name using the javax.inject.Named annotation
List becomes ArrayList
SortedSet becomes TreeSet
Set becomes HashSet
Collection becomes ArrayList
Array (sparse)
java.util.Map
java.util.Map
java.util.Map
If a Map interface is specified, creates a new java.util.HashMap for java.util.Map and a new java.util.TreeMap for java.util.SortedMap.
BlazeDS passes an instance of java.util.ArrayList to parameters typed with the java.util.List interface and any other interface that extends java.util.Collection. Then these types are
sent back to the client as mx.collections.ArrayCollection instances
If you require normal ActionScript Arrays sent back to the client, you must set the legacy-collection element to true in the serialization section of a channel-definition's properties; for more information, see Configuring AMF serialization on a channel.
legacy-collection
Default value is false. When true, instances of
java.util.Collection
are returned as
ActionScript Arrays
legacy-map
Default value is false. When true, java.util.Map instances are serialized as an ECMA Array or associative array instead of an anonymous Object.
A typical reason to use custom serialization is to avoid passing all of the properties of either the client-side or server-side representation of an object across the network tier.
standard serialization scheme, all public properties are passed back and forth between the client and the server.
Explicitly mapping ActionScript and Java objects
Private properties, constants, static properties, and read-only properties, and so on, are not serialized
Updated Groovy template for GraniteDS Builder (gas3)
also stripped out the specialized GraniteDS datatypes in favor of the LCDS serialization convention that Adobe uses (i.e. a Java map should translate to an 'Object' type, a Java enum should translate to a 'String', and Java collections should always serialize as 'ArrayCollection')
didn't do a 'base' version and a version that doesnt get touched by the code generator, but you could easily do so by modifying this template
Deault interface implementations - Shiro provides default Hash (aka Message Digests in the JDK) implementations out-of-the-box, such as MD5, SHA1, SHA-256
Built-in Hex and Base64 conversion - Shiro Hash instances can automatically provide Hex and Base-64 encoding of hashed data via their toHex() and toBase64() methods
Due to the limited capabilities of the ActionScript 3 reflection API than cannot access private fields, it is necessary to create
an externalizable AS3 class (implementing flash.utils.IExternalizable and its corresponding externalizable Java class
writeExternal
In both classes you have to implement two methods
the Gas3 generator can automatically generate the writeExternal and readExternal methods.
With GraniteDS automated externalization and without any modification made to our bean, we may serialize all properties of the Person class,
private or not
In order to externalize the Person.java entity bean, we must tell GraniteDS which classes we want to externalize
with a
externalize all classes named com.myapp.entity.Person by using the org.granite.hibernate.HibernateExternalizer
you could use this declaration, but note that type in the example above
is replaced by