Skip to content
Dylan Janeke edited this page Mar 23, 2017 · 2 revisions

AMF Module

Enunciate 1.x only

The AMF deployment module generates the server-side and client-side libraries used to support an Action Message Format API. The client-side library is a set of ActionScript classes that are type-safe wrappers around the ActionScript remoting API that are designed to add clarity and to be easy to consume for Flex development. Furthermore, the server-side support classes add an extra degree of security to your Data Services by ensuring that only your public methods are made available for invocation via AMF. There is also support for invoking the Adobe Flex compiler to compile a set of Flash applications that can be added to your Enunciate-generated web application.

The AMF API leverages the Blaze DS package that was recently made available as an open source product by Adobe. To use the AMF module, you will have to have the Flex SDK installed.

This documentation is an overview of how to use Enunciate to build your Flex Data Services (AMF API) and associated Flash application(s). The reader is redirected to the documentation for Flex for instructions on how to use Flex. There are also two sample applications you may find useful, petclinic and addressbook, that you will find bundled with the Enunciate distribution.

Configuration

The AMF module is configured by the amf element under the modules element of the enunciate configuration file. The amf element supports the following attributes:

attribute description
flexHome The "flexHome" attribute must be supplied. It is the path to the directory where the Flex SDK is installed.
label The "label" attribute is used to determine the name of the client-side artifact files. The default is the Enunciate project label.
swcName The "swcName" attribute specifies the name of the compiled SWC. By default, the name is determined by the Enunciate project label (see the main configuration docs).
swcDownloadable The "swcDownloadable" attribute specifies whether the generated SWC is to be made available as a download from the generated web application. Default: "false".
asSourcesDownloadable The "asSourcesDownloadable" attribute specifies whether the generated ActionScript source files are downloadable from generated web application. Default: "false".
mergeServicesConfigXML The "mergeServicesConfigXML" attribute specifies the services-config.xml file that is to be merged into the Enunciate-generated services-config.xml file. No file will be merged if none is specified.
enforceNoFieldAccessors The "enforceNoFieldAccessors" attribute specifies whether to enforce that a field accessor cannot be used for AMF mapping. Note: whether this option is enabled or disabled, there currently MUST be a getter and setter for each accessor. This option only disables the compile-time validation check.

Elements

The amf element supports the following child elements:

war

The "war" element under the "amf" element is used to configure the webapp that will host the AMF endpoints and Flex applications. It supports the following attributes:

  • The "amfSubcontext" attribute is the subcontext at which the amf endpoints will be mounted. Default: "/amf".
  • The "flexAppDir" attribute is the directory in the war to which the flex applications will be put. The default is the root of the war.

compiler

The "compiler" element under the "amf" element is used to configure the compiler that will be used to compile the SWC and the Flex applications. It supports the following attributes, associated directly to the Flex compiler options. For details, see the documentation for the Flex compiler.

  • contextRoot (default: the Enunciate project label)
  • flexConfig (default: "$FLEX_SDK_HOME/frameworks/flex-config.xml")
  • locale (default: unspecified)
  • optimize (boolean, default: unspecified)
  • debug (boolean, default: unspecified)
  • profile (boolean, default: unspecified)
  • strict (boolean, default: unspecified)
  • useNetwork (boolean, default: unspecified)
  • incremental (boolean, default: unspecified)
  • warnings (boolean, default: unspecified)
  • showActionscriptWarnings (boolean, default: unspecified)
  • showBindingWarnings (boolean, default: unspecified)
  • showDeprecationWarnings (boolean, default: unspecified)
  • flexCompileCommand (default "flex2.tools.Compiler")
  • swcCompileCommand (default "flex2.tools.Compc")

The compiler element also supports the following subelements:

  • "JVMArg" (additional JVM arguments, passed in order to the JVM used to invoke the compiler, supports a single attribute: "value")
  • "arg" (additional compiler arguments, passed in order to the compiler)
  • "license" (supports attributes "product" and "serialNumber")

app

The AMF module supports the development of Flex apps that can be compiled and packaged with the generated Enunciate app. The "app" element supports the folowing attributes:

  • The "name" attribute is the name of the Flex app. This attribute is required.
  • The "srcDir" attribute specifies the source directory for the application. This attribute is required.
  • The "mainMxmlFile" attribute specifies the main mxml file for the app. This attribute is required. The path to this file is resolved relative to the enunciate.xml file (not to the "srcDir" attribute of the app).
  • The "outputPath" attribute specified the output directory for the application, relative to the "flexAppDir".

facets

Facet configuration for the module. See Facets.

Example

As an example, consider the following configuration:

<enunciate>
  <modules>
    <amf swcName="mycompany-amf.swc" flexHome="/home/myusername/tools/flex-sdk-2">
      <app srcDir="src/main/flexapp" name="main" mainMxmlFile="src/main/flexapp/com/mycompany/main.mxml"/>
      <app srcDir="src/main/anotherapp" name="another" mainMxmlFile="src/main/anotherapp/com/mycompany/another.mxml"/>
    </amf>
  </modules>
</enunciate>

This configuration enables the AMF module and gives a specific name to the compiled SWC for the client-side ActionScript classes.

There also two Flex applications defined. The first is located at "src/main/flexapp". The name of this app is "main". The MXML file that defines this app sits at "src/main/flexapp/com/mycompany/main.mxml", relative to the enunciate configuration file. The second application, rooted at "src/main/anotherapp", is named "another". The mxml file that defines this application sits at "src/main/anotherapp/com/mycompany/another.mxml".

After the "compile" step of the AMF module, assuming everything compiles correctly, there will be two Flash applications, "main.swf" and "another.swf", that sit in the applications directory (see "artifacts" below).

For a less contrived example, see the "petclinic" sample Enunciate project bundled with the Enunciate distribution.

Clone this wiki locally