source:http://www.dzone.com/links/r/rad_with_scala_and_vaadin.html
I’ve had an opportunity recently to work on a product that needed an RIA web interface, and I chose my recent favorite tool for this,Vaadin. The services for this project needed to be highly scalable, and lent themselves well to functional techniques, so I selectedScalaas my language of choice. I build my projects with Maven, for reasons I won’t go into right now, and I do much of my JVM-language work in Intellij’s excellent IDEA IDE.
Given these tools, I found a way to facilitate very rapid development of web UI’s, and I thought I’d pass it along.
Another technique I use, which I’ll expound on later, is creating “dummy” implementations of all of my backing services for my application. The “real” implementations are written as OSGi services, in separate modules from my UI. The UI is packaged as a war, but is also OSGi aware, with a bundle activator. This activator only gets called if the war is deployed into an OSGi container, and not otherwise. This allows the app to select which implementation of the services it uses – the “dummy” ones when it’s deployed outside of OSGi, and the “real” ones when they’re available.
This means I can use the handyMaven jetty pluginto quickly spin up my application and test it on my local workstation, without needing all of the dependencies (like a data store and such) of my real services. That’s good, in that I can get my “cycle time” down to a few seconds, where “cycle time” is the time between making a change and actually being able to test it in my browser.
We can do better, though.
I’m using Scala as my language of choice for building the UI as well, as it works just fine with Vaadin (and with everything else in the JVM ecosystem, for that matter, which is why I didn’t choose a non-JVM language – but that’s yet another rant).
I compile my Scala with theMaven scala plugin– here’s where the next handy bit comes into play. Turns out the Scala plugin has agoal called “cc”, for continuous compilation. Using this, I can fire up Maven with a “mvn scala:cc” command, and leave it running. Then I also use the “mvn jetty:run” command in another window to fire up the web application, and leave it running as well.
Here’s my configuration for the Scala plugin:
02 |
< groupid >org.scala-tools</ groupid >
|
03 |
< artifactid >maven-scala-plugin</ artifactid >
|
04 |
< version >2.9.1</ version >
|
09 |
< goal >testCompile</ goal >
|
14 |
< scalaversion >${scala.version}</ scalaversion >
|
16 |
< arg >-target:jvm-1.5</ arg >
|
And for Jetty:
02 |
< groupid >org.mortbay.jetty</ groupid >
|
03 |
< artifactid >maven-jetty-plugin</ artifactid >
|
04 |
< version >6.1.9</ version >
|
06 |
< scanintervalseconds >10</ scanintervalseconds >
|
07 |
< webappsourcedirectory >src/main/webapp</ webappsourcedirectory >
|
08 |
< jettyconfig >jetty.xml</ jettyconfig >
|
10 |
< userrealm implementation = "org.mortbay.jetty.security.HashUserRealm" >
|
12 |
< config >realm.properties</ config >
|
15 |
< stopkey >stop</ stopkey >
|
16 |
< stopport >8889</ stopport >
|
Now I go back to my IntelliJ and start coding. Every time IntelliJ saves (which it does automatically unless you tell it not to), the Scala plugin compiles the files. This generates a new .class file, which the Jetty plugin (well, technically, Jetty itself) detects, and in response, reloads the running classes for the web application.
Net effect is that I can make my change and by the time I switch back to the browser, my new code is running. I test my change, emit the appropriate profanity, and go back to editing, all within a second or two.
This has profound effects on how you develop a UI, which every dynamic language aficionado knows (e.g. like Ruby/Rails or Python/Django). You don’t hesitate to experiment, and you get to see the visual effect of your changes right away. The good news is that I get to do this with my language of choice, and with all the power of the JVM ecosystem to support it.
The technique is not perfect – I’ve found that if you edit some resources or webapp files (images and such), it’s possible the Jetty plugin doesn’t “see” the change. Of course, two things help with that considerably: first, it’s lightning-fast to just Control-C the jetty plugin task and re-launch it, and second a Vaadin app generally doesn’t use many resources, unlike JSP or many other frameworks that make extensive use of templates.
Once in a while I’ve found the scala:cc task will report that it’s lost it’s connection to the “fsc” (fast scala compiler) background process – again, quickly control-c-ing the task and starting it again solves the problem every time.
Overall, I can crank UI out pretty darn quick with this method, and given that I can TDD even my UI code using Vaadin, I find the overall combination very effective and efficient.
分享到:
相关推荐
RAD Studio XE8 With Update 1 Green 1.3.rar
RAD Studio Seattle Kg and more.7z
SPACEVPX单板计算机资料。 The SBC is designed to support operation as either a payload ...daughter card with PCI, RapidIO, and/ or SpaceWire interfaces can be used to personalize the SBC for unique needs.
Embarcadero RAD Studio XE Architect 15.0.3953.35171 (Update1) with RadPHP XE 3.0.0.1319 Crack
RAD Studio XE(Delphi 2011 and BC 2011) 下载地址
可能用的人太少,网上大部分链接的版本都比较老的,从2ccc找到的也是2004年的。好容易才找到一个2009的V7版。
RAD Studio Alexandria11.1 ,详细安装说明请下载附件查看! 1、装载光盘映像文件RADStudio_11_1_esd_10_8973a.iso,将光盘上全部文件拷贝到硬盘目录; 2、以管理员身份启动安装程序[ radstudio_11_esd_108973a.exe] 3...
FastReport VCL 5 for RAD Studio, Delphi and C++Builder XE7 2014-11-11
8. 如果你已经安装好了,但是使用的是试用版,请将 [RAD Studio 10.1.2 Berlin 柏林 RAD10.1UP2 架构师版 bin exe] 目录里的 bds.exe 替换到安装目录的 bin 目录里,否则后果自负。 9. 注意:压缩包的密码是 ...
Hotfix 1 for RAD Studio, ...Available to registered users of Delphi XE5, RAD Studio XE5, and Embarcadero All-Access XE This hotfix supplies some missing lib file when installing Delphi XE5 Update 2
Embarcadero RAD Studio 11.1 Alexandria Architect 版本 28.0.44500.8973 KEY RAD Studio 11是最完整的Android 32-64位、Windows 11、10、Mac OSX 32-64位、iOS 32-64位和Linux64,以及物联网移动设备的应用开发...
RAD Studio 10.3 Rio is supported Support of UPPER and LOWER functions for Unified SQL is added Bug with using the FieldOrigins property is fixed Bug with using the TrimFixedChar property is fixed Bug ...
RAD Studio 10.1RTM Berlin 柏林 RAD10.1RTM 架构师安装破解指导
RADStudio10.4.2KeyPatch
RAD Studio 10.2 Updata2 keygen 支持delphi c++builder10.2.2的一键激活!同时向下兼容激活10.0 10.1 10.2等版本。 支持: 1、Rad Studio 10.2.2.2004 Tokyo Not Hot Release 2 Enterprise/Architet/Ultimate 2、...
RAD Studio 10.3 Rio is supported Support of UPPER and LOWER functions for Unified SQL is added Bug with using the FieldOrigins property is fixed Bug with using the TrimFixedChar property is fixed Bug ...
1) Install RAD Studio XE2 with this s/n "3AAD-DCS8KK****************" 2) Go to "%your_bds_dir%\bin\" 3) Make backup of original "bds.exe" 4) Copy "bds.exe" and "bds.dll" from this arch to the bds dir...
=============================================================== ! !在安装最新版本之前,必须彻底卸载以前的RAD Studio版本!! =========================================...从RAD Studio ISO镜像[radstudio_11_es
RAD Studio 10.2.3 Tokyo 东京 RAD10.2 Release 3 架构师安装破解指导 包含破解注册工具
RAD Studio 12 安装激活说明及常见问题