Introduction:
I just wanted to inform everyone that Apache MyFaces Extension-Scripting works out of the box with Apache TomEE.
What is Apache MyFaces Ext-Scripting?
For all people who don't know what Ext-Script is (probably most of you). Apache MyFaces Extension Scripting short Ext-Script is an Apache MyFaces extension which provides scripting language support and dynamic recompilation for Apache MyFaces. This means you can code the JSF parts of your project in Groovy, Scala, Java and soon in JRuby and you get jsp like dynamic recompilation of those parts for free.
It does not work with all app servers due to server limitations (mostly in the classloader section) but so far it has been tested with
- Tomcat
- Jetty
- Websphere Liberty Profile
- Glassfish and
- TomEE
More information about Apache MyFaces Ext-Scripting here.
This blogpost is about TomEE and how to get it up and running with this excellent lightweight server.
What is TomEE:
TomEE is a project, which provides a full JEE Web Profile to a Tomcat, it does not touch Tomcat but provides the entire JEE web profile stack (and more) within a standard Tomcat war container. Thats right no EAR anymore just drop a war and you will get JSF CDI etc... out of the box from the container.
More information on Apache TomEE here. No more bundling of JSF CDI etc... all is provided by a lightweight servlet container with great startup times.
Combination of both
So how do we combine both containers? The answer is simple, drop
Ext-Scripting:
- extscript-myfaces20-bundle-1.0.4.jar
and its dependencies :
- commons-beanutils.jar version 1.8.3 or above
- commons-codec.jar version 1.3 or above
- commons-collections.jar version 3.2 or above
- commons-io.jar version 1.4 or above
- groovy-all.jar version 1.7.2 or above
- scala-compiler.jar version 2.10.0-M2 or above
- scala-library.jar version 2.10.0-M2 or above
(Note if you use Maven then Maven will do the job for you) into your war WEB-INF/LIB and set following configuration entries:
<context-param> <description> Initializes the plugins for our groovy handlers </description> <param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name> <param-value>
org.apache.myfaces.extensions.scripting.jsf.startup.StartupServletContextPluginChainLoader </param-value> </context-param>
This is the most important entry and under normal Servlet containers now we would be set and could start coding, however we have to set additional parameters for TomEE:
<context-param> <description>Additional comma separated loader paths to allow direct editing on the sources directory instead of the deployment dir </description> <param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name> <param-value> /whatever/myfaces20-extscript-helloworld/src/main/webapp/WEB-INF/groovy </param-value> </context-param> <context-param> <description>Additional comma separated loader paths to allow direct editing on the sources directory instead of the deployment dir </description> <param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name> <param-value> /whatever/myfaces20-extscript-helloworld/src/main/webapp/WEB-INF/java </param-value> </context-param> <context-param> <description>Additional comma separated loader paths to allow direct editing on the sources directory instead of the deployment dir </description> <param-name>org.apache.myfaces.extensions.scripting.scala.LOADER_PATHS</param-name> <param-value> /whatever/myfaces20-extscript-helloworld/src/main/webapp/WEB-INF/scala </param-value> </context-param> <context-param> <description>Additional comma separated loader paths to allow direct editing on the source directories of the deployment dir. </description> <param-name>org.apache.myfaces.extensions.scripting.ruby.LOADER_PATHS</param-name> <param-value> /whatever/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/ruby </param-value> </context-param>
Those paths point to your source directories hosting the source files. (Note that the Ruby loader paths are only valid with the latest 1.0.5-SNAPSHOTS, 1.0.4 has no Ruby support)
Once done you can start coding in the code hosted at the respective directories.
More information about setting up Ext-Script can be found here.
Keine Kommentare:
Kommentar veröffentlichen