|
|||||||||
| 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.gwt.GWTDeploymentModule
public class GWTDeploymentModule
The GWT deployment module generates the server-side and client-side libraries used to support a GWT RPC API. There is also support for invoking the GWTCompiler to compile a set a GWT applications that can be included in the generated Enunciate web application.
The order of the GWT deployment module is 0, as it doesn't depend on any artifacts exported by any other module.
This documentation is an overview of how to use Enunciate to build your GWT-RPC API and (optional) associated GWT application. The reader is redirected to the documentation for the GWT for instructions on how to use GWT. You may also find the petclinic sample application useful as an illustration. The sample petclinic application is included with the Enunciate distribution.
The "generate" step generates all source code for the GWT-RPC API.
During the "compile" step, the GWT module compiles the code that was generated. It is also during the "compile" step that the GWTCompiler is invoked on any GWT applications that were specified in the configuration.
The "build" step assembles the client-side GWT jar.
The GWT module is configured by the "gwt" element under the "modules" element of the enunciate configuration file. The GWT module is disabled by default because of the added constraints applied to the service endpoints. To enable GWT, be sure to specify disabled="false" on the "gwt" element.
The "gwt" element supports the following attributes:
false.The "war" element under the "gwt" element is used to configure the webapp that will host the GWT endpoints and GWT applications. It supports the following attributes:
The GWT module supports the development of GWT AJAX apps. Each app is comprised of a set of GWT modules that will be compiled into JavaScript. The "app" element supports the folowing attributes:
Each "app" element may contain an arbitrary number of "module" child elements that specify the modules that are included in the app. The "module" element supports the following attributes:
The "gwtCompileJVMArg" element is used to specify additional JVM parameters that will be used when invoking GWTCompile. It supports a single "value" attribute.
The "gwtCompilerArg" element is used to specify additional arguments that will be psssed to the GWT compiler. It supports a single "value" attribute.
As an example, consider the following configuration:
<enunciate>
<modules>
<gwt disabled="false"
rpcModuleName="com.mycompany.MyGWTRPCModule"
gwtHome="/home/myusername/tools/gwt-linux-1.5.2">
<app srcDir="src/main/mainapp">
<module name="com.mycompany.apps.main.MyRootModule"/>
<module name="com.mycompany.apps.main.MyModuleTwo" outputDir="two"/>
</app>
<app srcDir="src/main/anotherapp" name="another">
<module name="com.mycompany.apps.another.AnotherRootModule"/>
<module name="com.mycompany.apps.another.MyModuleThree" outputDir="three"/>
</app>
...
</gwt>
</modules>
</enunciate>
The configuration enables the GWT Enunciate module and will publish the web service endpoints under the module name "com.mycompany.MyGWTRPCModule".
There are also two GWT applications defined. The first is located at "src/main/mainapp". Since there is no "name" applied to this application, it will be generated into the root of the applications directory. This first application has two GWT modules defined, the first named "com.mycompany.apps.main.MyRootModule" and the second named "com.mycompany.apps.main.MyModuleTwo". "MyRootModule", since it has to output path defined, will be generated into the root of its application directory (which is the root of the main applications directory). "MyModuleTwo", however, will be generated into the subdirectory "two".
The second application, rooted at "src/main/anotherapp", is named "another", so it will be generated into the "another" subdirectory of the main applications directory. It also has two modules, one named "com.mycompany.apps.another.AnotherRootModule", and another named "com.mycompany.apps.another.MyModuleThree". "AnotherRootModule" will be generated into the root of its application directory ("another") and "MyModuleThree" will be generated into "another/three".
All modules are defined by their associated ".gwt.xml" module definition files. After the "compile" step of the GWT module, the main applications directory will look like this:
|--[output of com.mycompany.apps.main.MyRootModule]
|--two
|----[output of com.mycompany.apps.main.MyModuleTwo]
|--another
|----[output of com.mycompany.apps.another.AnotherRootModule]
|----three
|------[output of com.mycompany.apps.another.MyModuleThree]
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 | |
|---|---|
GWTDeploymentModule()
|
|
| Method Summary | |
|---|---|
void |
addGWTApp(GWTApp gwtApp)
Adds a gwt app to be compiled. |
void |
addGwtCompileJVMArg(java.lang.String arg)
Extra JVM args for the GWT compile. |
void |
addGwtCompilerArg(java.lang.String arg)
Additional argument to pass to the GWT compiler. |
protected void |
buildClientJar()
|
protected void |
doBuild()
Default implementation is a no-op. |
protected void |
doCompile()
Default implementation is a no-op. |
void |
doFreemarkerGenerate()
Generate using Freemarker. |
protected void |
doGWTCompile()
Invokes GWTCompile on the apps specified in the configuration file. |
protected boolean |
existsAnyJsonResourceMethod(java.util.List<RootResource> rootResources)
Whether any root resources exist that produce json. |
java.io.File |
getAppGenerateDir()
The base generate dir for the gwt applications. |
protected java.io.File |
getAppGenerateDir(java.lang.String appName)
The generate dir for the specified app. |
java.lang.String |
getClientJarName()
The name of the client jar. |
java.io.File |
getClientSideCompileDir()
Get the compile directory for client-side GWT classes. |
java.io.File |
getClientSideGenerateDir()
Get the generate directory for client-side GWT classes. |
org.apache.commons.digester.RuleSet |
getConfigurationRules()
GWT configuration rule set. |
java.lang.String |
getGwtAppDir()
The gwt app dir. |
java.util.List<GWTApp> |
getGwtApps()
The gwt apps to compile. |
java.util.List<java.lang.String> |
getGwtCompileJVMArgs()
Extra JVM args for the GWT compile. |
java.util.List<java.lang.String> |
getGwtCompilerArgs()
Additional arguments to pass to the GWT compiler. |
java.lang.String |
getGwtCompilerClass()
The GWT compiler class. |
java.io.File |
getGwtGenDir()
The GWT gen directory. |
java.lang.String |
getGwtHome()
The gwt home directory |
java.io.File |
getGwtScriptDir()
The base generate dir for the gwt scripts (e.g. |
java.lang.String |
getGwtSubcontext()
The GWT subcontext. |
java.lang.String |
getLabel()
The label for the GWT client API. |
protected java.lang.String |
getModuleId(java.lang.String moduleName)
Get the module id of the specified GWT module. |
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.lang.String |
getRpcModuleName()
The generated RPC module name. |
java.lang.String |
getRpcModuleNamespace()
The generated RPC module namespace. |
java.io.File |
getServerSideGenerateDir()
Get the generate directory for server-side GWT classes. |
java.io.File |
getShellScriptFile(java.lang.String appName,
java.lang.String moduleName)
Get the GWT shell script file for the specified module, app. |
protected java.net.URL |
getTemplateURL(java.lang.String template)
Get a template URL for the template of the given name. |
Validator |
getValidator()
GWT validator. |
protected boolean |
gwtVersionGreaterThan(int major,
int minor)
|
void |
init(Enunciate enunciate)
Sets the enunciate mechanism. |
void |
initModel(EnunciateFreemarkerModel model)
Initialize the model. |
boolean |
isClientJarDownloadable()
Whether the client jar is downloadable. |
boolean |
isDisableCompile()
Whether to disable the compilation of the java sources (default: false). |
boolean |
isEnforceNamespaceConformance()
Whether to enforce namespace conformace on the server-side classes. |
boolean |
isEnforceNoFieldAccessors()
Whether to enforce that field accessors can't be used. |
boolean |
isGenerateJsonOverlays()
Whether to generate JSON overlays. |
boolean |
isGenerateRPCSupport()
Whether to generate the RPC support classes. |
protected boolean |
isGWTTransient(com.sun.mirror.declaration.Declaration declaration)
Whether the given type declaration is GWT-transient. |
protected boolean |
isGWTTransient(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the given type declaration is GWT-transient. |
boolean |
isUseWrappedServices()
Whether to generated wrapped GWT remote services in the client-code. |
void |
onClassesFound(java.util.Set<java.lang.String> classes)
Logic for handling a set of classes that were found on the Enunciate classpath. |
protected int[] |
parseGwtVersion(java.lang.String version)
|
protected java.lang.String |
readResource(java.lang.String resource)
Reads a resource into string form. |
void |
setClientJarDownloadable(boolean clientJarDownloadable)
Whether the client jar is downloadable. |
void |
setClientJarName(java.lang.String clientJarName)
The name of the client jar. |
void |
setDisableCompile(boolean disableCompile)
Whether to disable the compilation of the java sources (default: false). |
void |
setEnforceNamespaceConformance(boolean enforceNamespaceConformance)
Whether to enforce namespace conformace on the server-side classes. |
void |
setEnforceNoFieldAccessors(boolean enforceNoFieldAccessors)
Whether to enforce that field accessors can't be used. |
void |
setGenerateJsonOverlays(boolean generateJsonOverlays)
Whether to generate JSON overlays. |
void |
setGwtAppDir(java.lang.String gwtAppDir)
The gwt app dir. |
void |
setGwtCompilerClass(java.lang.String gwtCompilerClass)
The GWT compiler class. |
void |
setGwtHome(java.lang.String gwtHome)
Set the path to the GWT home directory. |
void |
setGwtModuleName(java.lang.String gwtModuleName)
Deprecated. Use setRpcModuleName(String) |
void |
setGwtSubcontext(java.lang.String gwtSubcontext)
The gwt subcontext. |
void |
setGwtVersion(java.lang.String version)
Sets the GWT version that Enunciate will target. |
void |
setLabel(java.lang.String label)
The label for the ActionScript API. |
void |
setRpcModuleName(java.lang.String rpcModuleName)
The generated RPC module name. |
void |
setUseWrappedServices(boolean useWrappedServices)
Whether to generated wrapped GWT remote services in the client-code. |
| 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, isDisabled, 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, isDisabled, step |
| Constructor Detail |
|---|
public GWTDeploymentModule()
| 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.
EnunciateException
protected boolean gwtVersionGreaterThan(int major,
int minor)
public 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 void doGWTCompile()
throws EnunciateException,
java.io.IOException
EnunciateException
java.io.IOException
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 void buildClientJar()
throws java.io.IOException,
EnunciateException
java.io.IOException
EnunciateException
protected java.lang.String readResource(java.lang.String resource)
throws java.io.IOException,
EnunciateException
resource - The resource to read.
java.io.IOException
EnunciateExceptionprotected boolean isGWTTransient(com.sun.mirror.declaration.TypeDeclaration declaration)
declaration - The type declaration.
protected boolean isGWTTransient(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 getGwtGenDir()
public java.io.File getClientSideCompileDir()
public java.io.File getAppGenerateDir()
public java.io.File getGwtScriptDir()
public java.io.File getShellScriptFile(java.lang.String appName,
java.lang.String moduleName)
appName - The app name.moduleName - The module name.
protected java.lang.String getModuleId(java.lang.String moduleName)
moduleName - The module name.
protected java.io.File getAppGenerateDir(java.lang.String appName)
appName - The app name.
public java.lang.String getClientJarName()
public void setClientJarName(java.lang.String clientJarName)
clientJarName - The name of the client jar.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 getRpcModuleName()
public java.lang.String getRpcModuleNamespace()
public void setGwtModuleName(java.lang.String gwtModuleName)
setRpcModuleName(String)
gwtModuleName - The gwt module name.public void setRpcModuleName(java.lang.String rpcModuleName)
rpcModuleName - The generated RPC module name.public boolean isClientJarDownloadable()
public void setClientJarDownloadable(boolean clientJarDownloadable)
clientJarDownloadable - Whether the client jar is downloadable.public boolean isEnforceNamespaceConformance()
public void setEnforceNamespaceConformance(boolean enforceNamespaceConformance)
enforceNamespaceConformance - Whether to enforce namespace conformace on the server-side classes.public boolean isEnforceNoFieldAccessors()
public void setEnforceNoFieldAccessors(boolean enforceNoFieldAccessors)
enforceNoFieldAccessors - Whether to enforce that field accessors can't be used.public java.lang.String getGwtHome()
public void setGwtHome(java.lang.String gwtHome)
setGwtHome in interface GWTHomeAwareModulegwtHome - The gwt home directorypublic java.util.List<java.lang.String> getGwtCompileJVMArgs()
public void addGwtCompileJVMArg(java.lang.String arg)
arg - Extra JVM args for the GWT compile.public java.util.List<java.lang.String> getGwtCompilerArgs()
public void addGwtCompilerArg(java.lang.String arg)
arg - The additional arg.public java.lang.String getGwtCompilerClass()
public void setGwtCompilerClass(java.lang.String gwtCompilerClass)
gwtCompilerClass - The GWT compiler class.public java.util.List<GWTApp> getGwtApps()
public void addGWTApp(GWTApp gwtApp)
gwtApp - The gwt app to be compiled.public java.lang.String getGwtSubcontext()
public void setGwtSubcontext(java.lang.String gwtSubcontext)
gwtSubcontext - The gwt subcontext.public java.lang.String getGwtAppDir()
public void setGwtAppDir(java.lang.String gwtAppDir)
gwtAppDir - The gwt app dir.public boolean isUseWrappedServices()
public void setUseWrappedServices(boolean useWrappedServices)
useWrappedServices - Whether to generated wrapped GWT remote services in the client-code.public boolean isGenerateJsonOverlays()
public boolean isGenerateRPCSupport()
public void setGenerateJsonOverlays(boolean generateJsonOverlays)
generateJsonOverlays - Whether to generate JSON overlays.public java.lang.String getLabel()
public void setLabel(java.lang.String label)
label - The label for the ActionScript API.public void setGwtVersion(java.lang.String version)
version - The GWT version Enunciate will target.
protected int[] parseGwtVersion(java.lang.String version)
throws java.lang.NumberFormatException
java.lang.NumberFormatExceptionprotected boolean existsAnyJsonResourceMethod(java.util.List<RootResource> rootResources)
rootResources - The root resources.
public 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 ProjectExtensionModulepublic boolean isDisableCompile()
public void setDisableCompile(boolean disableCompile)
disableCompile - Whether to disable the compilation of the java sources (default: false).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||