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
describing its parameter object and is therefore not type-safe and its use is subject to many syntax errors.
GraniteDS provides a Java-like reflection API that encapsulates describeType calls and offers a type-safe, object-oriented, set of
reflection classes and methods
caches its results for better performance
supports advanced features such as ApplicationDomain
and namespaces
Gas3 uses the principle of "Base" and customizable inherited classes that let you add methods to generated classes without facing the risk
of losing them when a new generation process is executed
5.3. Java Classes and Corresponding Templates
summary of templates used by the generator depending on the kind of Java class it encounters:
these templates are bundled in the granite-generator.jar archive, in the org.granite.generator.template
package and accessible as resources via the class loader
class: protocol is used because all standard templates are available in the classpath
Alternatively, you may use the file: protocol to load your template from the filesystem. These templates can be
specified either by using absolute paths (eg. file:/absolute/path/to/mytemplate.gsp) or paths relative to your
current Eclipse project root directory (eg. path/to/mytemplate.gsp).
ActionScript 3 generator is able to write AS3 typed client proxies for exposed remote services
Compared to the usual Flex RemoteObject, this can greatly help development by bringing
auto-completion
improved type-safety
in Flex
when using remote services.
replicate validation annotations in order to use the Flex side validation framework
Known Limitations
Gas3 does not support inner classes
must declare your classes in separated source files
if you want them to be correctly handled by the generator
JSR-303 (“Bean Validation”) ActionScript3 framework for form validation
validation framework is a specific adaptation of the JSR-303 (Bean Validation) specification to Flex: like its Java counterpart, it relies on validation annotations placed on bean properties and provides an engine API that lets you validate your forms without writing by hand a specific validator for each of your input fields
code generation tools provided by GraniteDS so that when you write your Java entity bean with validation annotations, they are automatically replicated in your ActionScript3 beans
problem with LCDS is mainly that it promotes a strict “client / server” architecture, with – roughly speaking – a heavy Flex client application connected to a server almost reduced to a database frontend
big majority of these organizations use BlazeDS, a free and open-source subset of LCDS
need more advanced mechanisms than just Remoting start looking for open-source libraries to enable deeper integrations with the Java business layer, and GraniteDS is for sure the most popular project
“Flex Data Services” (now renamed to “Live Cycle Data Services”)
GraniteDS have added support for Bean Validation into their project and hence Bean Validation is usable by all Flex users
Because they do not run on the JVM, they basically have reimplemented the full specification in Flex:
you can annotate your ActionScript3 objects with constraints: it supports all the standard constraints and you can write your own constraints
you can execute the validation logic and retrieve the error report
you can make use of most of the feature including advanced ones like groups, group sequence etc
for GraniteDS users keeping their Java domain model and ActionScript3 domain model in sync via Gas3, the constraints are kept in sync
a couple of gotchas to be aware of
the constraint implementation is in the same class as the constraint declaration (not a problem in a dynamic language)
@Pattern has a sightly different semantic because the regexp engine in Flex is a bit different.
instead of the features provided by ConstraintValidatorContext, you can define a properties attribute in your constraints to make it belong to several sub-properties. not as flexible but good enough in many cases.
possible to define common handlers for particular fault codes on the client-side, and exception converters on the server-side, to convert server exceptions to common fault codes
* instead of *wrapping* the server-side exception and rethrowing it to the client,
** extract only details relevant to the client (eg. include: human-friendly error message and any helpful parametrized data, exclude: stack traces),
** "wrap" it in a generic ServiceException, which gets "thrown" remotely to the client
* client can check ServiceException.getCode() to implement behavior tailored to server-side exception 'type'
GraniteDS comes with a powerful MXML/ActionScript3 compiler you may deploy in your servlet container. This servlet will compile your MXML code on the fly each time you have modified it and return a SWF
download the graniteds-webcompiler-***.zip bundle on SourceForge.
must declare your classes in separated source files if you want them to be correctly handled by the generator
Java enums
enum.gsp
JPA entity beans
entity.gsp
Java interfaces
interface.gsp
Java services
remote.gsp
Java events
bean.gsp
All other Java classes
bean.gsp
beanBase.gsp
beanBase.gsp
remoteBase.gsp, or tideRemoteBase.gsp
entityBase.gsp, or tideEntityBase.gsp
@Entity
@MappedSuperclass
@RemoteDestination
@TideEvent
templates are bundled in the granite-generator.jar
accessible as resources via the class loader
GraniteDS comes with an ActionScript3 code generator that writes AS3 beans for all externalized JavaBeans, with specific support for lazily loaded EJB 3 entities