|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.enunciate.modules.BasicDeploymentModule
org.codehaus.enunciate.modules.FreemarkerDeploymentModule
org.codehaus.enunciate.modules.amf.AMFDeploymentModule
public class AMFDeploymentModule
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.
The "generate" step generates all source code for the AMF API. This includes server-side support classes and client-side ActionScript classes that can be used to access the API via AMF.
During the "compile" step, the AMF module compiles the code that was generated. The generated client-side ActionScript classes are compiled into an SWC file that is made available as an Enunciate artifact. The SWC file can also be made available as a download from the deployed web application (see the configuration). It is also during the "compile" step that the Flex compiler is invoked on any Flex applications that are specified in the configuration.
The AMF module is configured by the "amf" element under the "modules" element of the enunciate configuration file. The AMF module is disabled by default because of the added constraints applied to the service endpoints and because of the additional dependencies required by the module. To enable AMF, be sure to specify disabled="false" on the "amf" element.
The "amf" element supports the following attributes:
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 "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.
The "compiler" element also supports the following subelements:
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:
As an example, consider the following configuration:
<enunciate>
<modules>
<amf disabled="false" 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.
| Field Summary |
|---|
| Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule |
|---|
enunciate |
| Constructor Summary | |
|---|---|
AMFDeploymentModule()
|
|
| Method Summary | |
|---|---|
void |
addFlexApp(FlexApp flexApp)
Adds a flex app to be compiled. |
protected void |
compileSwc(java.util.List<java.lang.String> commandLine)
Compiles the SWC. |
protected void |
doBuild()
Default implementation is a no-op. |
protected void |
doCompile()
Default implementation is a no-op. |
protected void |
doFlexCompile()
Invokes the flex compiler on the apps specified in the configuration file. |
void |
doFreemarkerGenerate()
Generate using Freemarker. |
java.lang.String |
getAmfSubcontext()
The amf subcontext. |
java.io.File |
getClientSideGenerateDir()
Get the generate directory for client-side AMF classes. |
FlexCompilerConfig |
getCompilerConfig()
The compiler configuration. |
org.apache.commons.digester.RuleSet |
getConfigurationRules()
AMF configuration rule set. |
java.lang.String |
getFlexAppDir()
The flex app dir. |
java.util.List<FlexApp> |
getFlexApps()
The amf apps to compile. |
java.lang.String |
getFlexHome()
The amf home directory |
java.lang.String |
getLabel()
The label for the ActionScript API. |
java.lang.String |
getMergeServicesConfigXML()
The services-config.xml file that is to be merged into the Enunciate-generated services-config.xml file. |
protected java.net.URL |
getMergeServicesConfigXmlTemplateURL()
|
java.lang.String |
getName()
The name of the deployment module. |
protected freemarker.template.ObjectWrapper |
getObjectWrapper()
The object wrapper to use for the model. |
java.util.List<java.io.File> |
getProjectResourceDirectories()
Any additional project resource directories to add to the project. |
java.util.List<java.io.File> |
getProjectSources()
Any additional project source roots to add to the project. |
java.util.List<java.io.File> |
getProjectTestResourceDirectories()
Any additional project resource directories to add to the project. |
java.util.List<java.io.File> |
getProjectTestSources()
Any additional project test source roots to add to the project. |
java.io.File |
getServerSideGenerateDir()
Get the generate directory for server-side AMF classes. |
java.io.File |
getSwcCompileDir()
The directory for the destination for the SWC. |
java.lang.String |
getSwcName()
The name of the swc file. |
java.io.File |
getSwfCompileDir()
The directory for the destination for the SWF. |
protected java.net.URL |
getTemplateURL(java.lang.String template)
Get a template URL for the template of the given name. |
Validator |
getValidator()
AMF validator. |
java.io.File |
getXMLGenerateDir()
Get the generate directory for XML configuration. |
void |
init(Enunciate enunciate)
Sets the enunciate mechanism. |
void |
initModel(EnunciateFreemarkerModel model)
Initialize the model. |
protected boolean |
isAMFTransient(com.sun.mirror.declaration.Declaration declaration)
Whether the given type declaration is AMF-transient. |
protected boolean |
isAMFTransient(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the given type declaration is AMF-transient. |
boolean |
isAsSourcesDownloadable()
Whether the generated ActionScript sources are downloadable. |
boolean |
isDisabled()
Whether this deployment module has been disabled, e.g. |
boolean |
isSwcDownloadable()
Whether the swc is downloadable. |
protected freemarker.ext.dom.NodeModel |
loadMergeXmlModel(java.io.InputStream inputStream)
Loads the node model for merging xml. |
void |
onClassesFound(java.util.Set<java.lang.String> classes)
Logic for handling a set of classes that were found on the Enunciate classpath. |
protected java.lang.String |
readResource(java.lang.String resource)
Reads a resource into string form. |
void |
setAmfSubcontext(java.lang.String amfSubcontext)
The amf subcontext. |
void |
setAsSourcesDownloadable(boolean asSourcesDownloadable)
Whether the generated ActionScript sources are downloadable. |
void |
setCompilerConfig(FlexCompilerConfig compilerConfig)
The compiler configuration. |
void |
setFlexAppDir(java.lang.String flexAppDir)
The flex app dir. |
void |
setFlexHome(java.lang.String flexHome)
Set the path to the AMF home directory. |
void |
setLabel(java.lang.String label)
The label for the ActionScript API. |
void |
setMergeServicesConfigXML(java.lang.String mergeServicesConfigXML)
Specifies the services-config.xml file that is to be merged into the Enunciate-generated services-config.xml file. |
void |
setSwcDownloadable(boolean swcDownloadable)
Whether the swc is downloadable. |
void |
setSwcName(java.lang.String swcName)
The name of the swc file. |
| Methods inherited from class org.codehaus.enunciate.modules.FreemarkerDeploymentModule |
|---|
close, doGenerate, getConfiguration, getModel, getModelInternal, getTemplateExceptionHandler, getTemplateLoader, processTemplate, processTemplate, processTemplate, processTemplate |
| Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule |
|---|
debug, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getOrder, getPackageDir, info, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.codehaus.enunciate.modules.DeploymentModule |
|---|
close, getAliases, getOrder, step |
| Constructor Detail |
|---|
public AMFDeploymentModule()
| Method Detail |
|---|
public java.lang.String getName()
DeploymentModule
getName in interface DeploymentModulegetName in class BasicDeploymentModule
public void init(Enunciate enunciate)
throws EnunciateException
BasicDeploymentModule
init in interface DeploymentModuleinit in class BasicDeploymentModuleenunciate - The enunciate mechanism.
EnunciateExceptionpublic void initModel(EnunciateFreemarkerModel model)
EnunciateModelAware
initModel in interface EnunciateModelAwareinitModel in class FreemarkerDeploymentModulemodel - The model to initialize.public void onClassesFound(java.util.Set<java.lang.String> classes)
EnunciateClasspathListener
onClassesFound in interface EnunciateClasspathListenerclasses - The classes that were found.
public void doFreemarkerGenerate()
throws java.io.IOException,
freemarker.template.TemplateException,
EnunciateException
FreemarkerDeploymentModuleFreemarkerDeploymentModule.doGenerate() but can throw a TemplateException.
doFreemarkerGenerate in class FreemarkerDeploymentModulejava.io.IOException
freemarker.template.TemplateException
EnunciateException
protected freemarker.ext.dom.NodeModel loadMergeXmlModel(java.io.InputStream inputStream)
throws EnunciateException
inputStream - The input stream of the xml.
EnunciateException
protected void doFlexCompile()
throws EnunciateException,
java.io.IOException
EnunciateException
java.io.IOException
protected void compileSwc(java.util.List<java.lang.String> commandLine)
throws java.io.IOException,
EnunciateException
commandLine - The command line.
java.io.IOException
EnunciateException
protected void doCompile()
throws EnunciateException,
java.io.IOException
BasicDeploymentModule
doCompile in class BasicDeploymentModuleEnunciateException
java.io.IOException
protected void doBuild()
throws EnunciateException,
java.io.IOException
BasicDeploymentModule
doBuild in class BasicDeploymentModuleEnunciateException
java.io.IOException
protected java.lang.String readResource(java.lang.String resource)
throws java.io.IOException,
EnunciateException
resource - The resource to read.
java.io.IOException
EnunciateExceptionprotected boolean isAMFTransient(com.sun.mirror.declaration.TypeDeclaration declaration)
declaration - The type declaration.
protected boolean isAMFTransient(com.sun.mirror.declaration.Declaration declaration)
declaration - The type declaration.
protected java.net.URL getTemplateURL(java.lang.String template)
template - The specified template.
public java.io.File getServerSideGenerateDir()
public java.io.File getClientSideGenerateDir()
public java.io.File getXMLGenerateDir()
public java.io.File getSwcCompileDir()
public java.io.File getSwfCompileDir()
public org.apache.commons.digester.RuleSet getConfigurationRules()
getConfigurationRules in interface DeploymentModulegetConfigurationRules in class BasicDeploymentModulepublic Validator getValidator()
getValidator in interface DeploymentModulegetValidator in class BasicDeploymentModuleprotected freemarker.template.ObjectWrapper getObjectWrapper()
FreemarkerDeploymentModule
getObjectWrapper in class FreemarkerDeploymentModulepublic java.lang.String getFlexHome()
public void setFlexHome(java.lang.String flexHome)
setFlexHome in interface FlexHomeAwareModuleflexHome - The amf home directorypublic java.util.List<FlexApp> getFlexApps()
public void addFlexApp(FlexApp flexApp)
flexApp - The flex app to be compiled.public FlexCompilerConfig getCompilerConfig()
public void setCompilerConfig(FlexCompilerConfig compilerConfig)
compilerConfig - The compiler configuration.protected java.net.URL getMergeServicesConfigXmlTemplateURL()
public java.lang.String getSwcName()
public void setSwcName(java.lang.String swcName)
swcName - The name of the swc file.public boolean isSwcDownloadable()
public void setSwcDownloadable(boolean swcDownloadable)
swcDownloadable - Whether the swc is downloadable.public boolean isAsSourcesDownloadable()
public void setAsSourcesDownloadable(boolean asSourcesDownloadable)
asSourcesDownloadable - Whether the generated ActionScript sources are downloadable.public java.lang.String getMergeServicesConfigXML()
public void setMergeServicesConfigXML(java.lang.String mergeServicesConfigXML)
mergeServicesConfigXML - the services-config.xml file that is to be merged into the
Enunciate-generated services-config.xml file.public java.lang.String getAmfSubcontext()
public void setAmfSubcontext(java.lang.String amfSubcontext)
amfSubcontext - The amf subcontext.public java.lang.String getFlexAppDir()
public void setFlexAppDir(java.lang.String flexAppDir)
flexAppDir - The flex app dir.public java.lang.String getLabel()
public void setLabel(java.lang.String label)
label - The label for the ActionScript API.public boolean isDisabled()
DeploymentModule
isDisabled in interface DeploymentModuleisDisabled in class BasicDeploymentModulepublic java.util.List<java.io.File> getProjectSources()
ProjectExtensionModule
getProjectSources in interface ProjectExtensionModulepublic java.util.List<java.io.File> getProjectTestSources()
ProjectExtensionModule
getProjectTestSources in interface ProjectExtensionModulepublic java.util.List<java.io.File> getProjectResourceDirectories()
ProjectExtensionModule
getProjectResourceDirectories in interface ProjectExtensionModulepublic java.util.List<java.io.File> getProjectTestResourceDirectories()
ProjectExtensionModule
getProjectTestResourceDirectories in interface ProjectExtensionModule
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||