JavaRebel 2.0 发布-改进了award-winning 1.0


Posted by: Jevgeni Kabanov on ?? 30, 2009
ZeroTurnaround today announced the release of JavaRebel 2.0, a JVM plugin that enables Java developers to see changes to their code immediately, without the need for application or container restarts.
ZeroTurnaround公司今天宣布发布 JavaRebel 2.0版,javaRebel是JVM插件,它能让java开发者在不需要重启应用或容器的情况下看到代码的变化。

Two weeks ago, JavaRebel 1.0 won a JOLT Productivity Award for its role in cutting development time and development team costs — recognition of the significant productivity gains that current customers are reporting.
2周前,javaRebel 1.0 赢得了 一个JOLT(震撼大奖)最佳生产力奖,这项奖项的职责是赋予那些用户反应能消减开发时间和开发团队成本--表扬在生产力上有很大提升的产品
"We're hearing that teams are saving an average of 10-40 minutes per developer, per day, in time otherwise wasted on application restarts", said ZeroTurnaround marketing captain, David Booth, "Using time saved and
”我们听说团队每个开发者每天将节省平均10-40分钟,最后否则会浪费时间在应用重启“ZeroTurnaround市场总监大卫.布斯说,“用节省的时间和开发者的薪水去计算利息,
developer salaries to calculate ROI, we're talking about thousands of dollars in savings, per year, from each member of the team using JavaRebel in their development.” With JavaRebel 2.0's expanded feature set, easy
我们正在讨论的是每年节省的数千美元,这些都是每个团队员他们的开发中用到JavaRebel能办到的。”随着JavaRebel 2.0扩展的功能集,更容易安装并且很明显的优良的 性能,
installation, and dramatically improved performance, ZeroTurnaround looks to build upon the success of the first version.
ZeroTurnaround看起来正构建他们第一个成功的版本.
While the cost savings are beneficial in any economic climate, developers report results of another nature. “We're hearing that the folks who used to look with envy at this feature in dynamic languages like Ruby and
在当前的经济形式 下节省成本是有益的,开发者表达另一方面效果,“我们听说人们经常羡慕动态语言(Ruby和python)的这种功能,
Python, are feeling much more comfortable with their Java applications now”, mentions ZeroTurnaround founder, Jevgeni Kabanov, “they're enjoying the quick feedback and the incremental development techniques that
现在他们感觉非常舒服对于他们的java应用程序”,提起ZeroRurnaround的创始人 Jevgeni kabanov, 他说“他们最喜欢快速的反馈 和不断增加的开发技能,这些都来源于像这样的轻量级的代码风格”
flow naturally from a lightweight coding style like this.”

JavaRebel 2.0 supports:
JavaRebel 2.0 支持功能:

    * Changes to method bodies
    * 方法体的变化
    * Changes to class structure, including adding methods, fields, constructors, changing/adding annotations, and changing interfaces
    * 类结构的改变包含:添加方法,字段,构造函数,改变/添加注释和改变接口。
    * Changes to configurations in Spring, Guice, Wicket, Stripes, Tapestry 4, and Struts2, with an open API for adding further support
      Spring,Guice,wicket,stripes,Tapestry4 and Struts2 这些框架的配置文件的改变,它带的开放API能添加更多的支持对所有主要的虚拟机(JVM)和容器
      All major JVMs and containers
      Exploded and Unexploded Development practices – what does this mean?
      暴露和未暴露开发实践--是什么意思?
      *******************************
         What is exploded and packaged deployment?
         什么是被暴露开发和打包开发
          The classic way of deploying a (web) application to a Java EE container involves packaging all the classes and resources into one file (WAR or EAR) and uploading it to the server, or pointing the server to it.、
          部署web应用程序到javaEE容器,把所有的class文件和资源文件打包成一个war包或ear包,然后上传到服务器上 或指定服务器。
          We refer to such type of deployment as packaged.
         我们把这种部署方式称做 packaged (打包开发)
         Most containers also support an alternative way of deploying an application, where you create a directory with a WAR or EAR structure and point the container to it. This is usually referred to as exploded.
      大部分容器也支持另一个部署方式,你用war或ear包结构创建一个目录使容器指向它。这种方式经常称作 暴露式
      ****************************
      Based on customer feedback, ZeroTurnaround has priced JavaRebel 2.0 for the cost-conscious at 149USD per concurrent user, per annum. They expect most firms will see the tool pay for itself within the first month of use, and offer a 30-day no-questions-asked money-back policy.
      基于用户的反馈,ZeroTurnaround 已经给JavaRebel 2.0定价为149美元每个用户每年,他们期望大多数公司能保证给工具付费在用的第一个月内,并且提供30天有问题退款的策略。

New and Noteworthy in JavaRebel 2.0
Download JavaRebel 2.0 Trial
www.zeroturnaround.com/javarebel
******************************************************************************************
JavaRebel 2.0的配置方法
Quick Start

    * On Java 5 add -noverify -javaagent:/path/to/javarebel.jar to the JVM command line.
    * On Java 1.4 you need to run java -jar javarebel.jar and then add -Xbootclasspath/p:/path/to/javarebel-bootstrap.jar;/path/to/javarebel.jar to the JVM command line.
    * If you use exploded development or a standalone application then set IDE to compile to WEB-INF/classes or system classpath and changes will be picked up immediately on save.
    * If you deploy as a WAR or an EAR then you need to create a rebel.xml configuration file as described further.

Some platforms and tools have their specific gotchas, so definitely take a look at the rest of the manual.
Step 0: Select your environment
Java version: Java 5 or later
Operating system:Windows
Platform: Tomcat 5+
Step 1: Configure the Platform
第一步:配置服务器平台
Tomcat

File: %TOMCAT_HOME%\bin\catalina.bat
找到文件:File: %TOMCAT_HOME%\bin\catalina.bat
Add the following line:
添加下面一行:
set JAVA_OPTS=-noverify -javaagent:javarebel.jar %JAVA_OPTS%

If you use the windows service or system tray startup use the following parameters instead:
如果你用的是windows service 服务或 系统托盘启动 那麽就用下面参数替代

-Xverify:none -javaagent:javarebel.jar

Step 2: Configure the Application
第二步:配置应用程序

There are two ways to specify classes that will be monitored by JavaRebel for changes:
有两种方式去指定JavaRebel监控类的变化:

All .class files in application classpath will be monitored by default (including system classpath, WEB-INF/classes, EJB module root, but exluding packaged JARs, WARs and EARs). If you use exploded or standalone
应用程序classpath路径下的所有.class文件默认情况下被监视(包含系统classpath,WEB-INF/classes,EJB module root,但不包含JARs包,WARs包和EARs包)。如果你用暴露式或独立式开发

development it is suggested to set the IDE compile output to application classpath and changes will be picked up on save.
那么建议你设置IDE的编译输出到应用的路径,如果保存时有变化就会被提交到javaRebel。

   1. You can put a rebel.xml file in the application or module classpath to mount external folders to the application classpath. There should be one rebel.xml file per application or module. It can be placed in:
      你应该把rebel.xml文件放到应用查询或模块的classpath下,那样安装扩展文件夹到应用程序的classpath中。你要保证一个应用或模块一个rebel.xml文件。他可以放在下面几个地方:
          * WEB-INF/classes
          * APP-INF/classes
          * EJB Module JAR root
          * Library JAR root
      NB! Never place rebel.xml in system/server classpath as it will cause classloading errors
      注意! 不要把rebel.xml放到系统或服务的classpath下,否则就会报错!
      The rest of this section applies only to rebel.xml configuration. If you're using exploded or standalone development feel free to skip right ahead to the Configuring Tools section.
      这一个章节剩下的就是配置rebel.xml,如果你用的是暴露式或独立式开发的话,你可以直接跳到Configuring Tools部分。

If you are using Maven to build your application, we'd suggest you to use the Maven JavaRebel plugin to generate rebel.xml for you. You can read about it in the Configuring Tools section.
如果你用Maven构建你的应用,我们建议你用Maven JavaRebel 插件去产生rebel.xml.你也可以读一下 Configuring Tools部分。

Configuring JARs

JARs are usually not deployed on their own, but as a part of application (e.g. WEB-INF/lib in WARs or EJB modules in EARs). However often you still want to update their code on-the-fly. Let's assume that we have a module my-business-module.jar deployed in WEB-INF/lib. You can propagate the changes from your workspace by adding the following rebel.xml to the root of the JAR file:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath>     <dir name="c:\myWorkspace\myBusinessModule\target\classes"/>
<dir name="c:\myWorkspace\myBusinessModule\src\main\resources"/>
</classpath></application>

This will mount classes and resources in directories c:\myWorkspace\myBusinessModule\target\classes and c:\myWorkspace\myBusinessModule\src\main\resources before the classes and resources in the JAR file. Changes to those classes and resources will propagate to the application.

Configuring WARs

In the case of a web application you have web application resources, like JSPs, HTML files, graphic files and so on in addition to the classpath. To configure a web application deployed as a WAR file we create a rebel.xml file in the WEB-INF/classes directory:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath>     <dir name="c:\myWorkspace\myWar\target\classes"/>
<dir name="c:\myWorkspace\myWar\src\main\resources"/>
</classpath> <web>     <link target="/">
<dir name="c:\myWorkspace\myWar\src\main\webapp"/>
</link>     <link target="/jsps/">
<dir name="c:\myWorkspace\myWar\src\main\jsps"/>
</link> </web></application>

This will mount classes and resources in directories c:\myWorkspace\myWar\target\classes and c:\myWorkspace\myWar\src\main\resources to the application classpath before the deployed classes and resources. This means that those classes and resources will override the ones in WEB-INF/classes and WEB-INF/lib/*.jar. Changes to those classes and resources will propagate to the application.

This will also map the web resources in the c:\myWorkspace\myWar\src\main\webapp directory to the root ("/") of the web application context and the web resources in c:\myWorkspace\myWar\src\main\jsps directory under the /jsps/ URI of the web application context. You may map several directories to one context target if necessary.

Configuring EARs

To configure a EAR you need to create a separate rebel.xml file for each EAR module. Web modules should be configured same as individually deployed WARs, EJB modules should be configured same as JARs. If your container supports APP-INF/classes you may also add a rebel.xml to that folder and mount classes and resources that belong to the EAR as a whole.
Tips and Tricks

    * Putting absolute paths in the rebel.xml might be a bad idea as you'd like to share it with other team members. Luckily JavaRebel will expand expressions like "${myProject.root}" in rebel.xml to a system property that you can pass to the application container as -DmyProject.root=c:/myWorkspace/myProject. This allows to use a single configuration for everyone and then customize it when starting the server.
    * You are not limited to mounting directories to classpath. You can also mount JARs with <jar>.
    * If you need to mount a bunch of directories or JARs at once you can use <dirset> or <jarset> that accepts Ant-style patterns to specify the specific directories.
    * You can use Ant FileSet-style include and exclude directives in <dir> and <jar> entries.

Read about those options and more in the configuration manual.
Step 3: Configuring Tools
步骤3:配置开发工具
IntelliJ IDEA

To enable debugger to work with JavaRebel you should install this plugin.

You should configure the debugger to ignore synthetic methods. To do that open up debugger properties (File -> Settings -> Debugger). On the lower left corner of the debugger settings page make the necessary changes. Be sure to tick Skip synthetic methods checkbox and add the filters for com.zeroturnaround.* and org.zeroturnaround.*. You should also untick the checkbox Synthetic fields in the Show block of File -> Settings -> IDE settings -> Debugger -> Data Views

To stop IDEA from rebuilding the WAR file on every save right click on the web application, go to File -> Project Structure, click on the Web component of your web project (it's a blue icon.), and then click on Java EE Build Settings. Uncheck both Create web facet war file, and Web Facet Exploded Directory.
Eclipse 3.x

You should also configure the debugger to ignore synthetic methods. To configure Eclipse go to Window -> Preferences and from there to Java -> Debug -> Step Filtering (or just search for "Step filtering").
你应该配置调式模式下忽略手工添加的方法,配置Eclipse window-->Prefernces-->Java-->Debug-->Step Filtering(或搜索"Step filtering")

Enable step filters and Filter synthetic methods. Make sure that Step through filters is also on. Now enable all the default filters and add com.zeroturnaround.* and org.zeroturnaround.*.
勾选step filters 和 Filter synthetic methods ,确认Step through filters也是勾选打开的。然后 勾选上所有默认过滤类 再点击右边的“Add filters”添加 com.zeroturenaround.* 和org.zeroturnaround.*.

See also:也可参考

******************************************************************************************
JavaRebel and Eclipse WTP configuration
August 11th, 2008 by Toomas Römer

There has been a lot of discussion regarding the use of JavaRebel with Eclipse Web Tools Project (WTP). JavaRebel does work with WTP but the configuration is not that straightforward. In this article we’ll try to give step by step instructions on how to make WTP and JavaRebel get along.

The article is divided into two parts. If you have JavaRebel installed under WTP you can skip to the configuration section. If you are an old time WTP user just enable autopublishing and disable auto reloading for modules.
JavaRebel Installation under WTP

Lets get started by downloading the JavaRebel zip archive from the download page. Unzip the archive somewhere on your harddisk. Copy the javarebel.jar from the uncompressed folder to a location that you can use later on. We’ll assume on Windows that this is c:\javarebel.jar and on Linux /home/john/javarebel.jar.

We’ll configure the startup of the container next. I will be using Tomcat v6.0 version. Open up the “Run Configurations” dialog from the Eclipse menu Run » Run Configurations. You should see the following dialog.

Click for original size - Run Configurations dialog

Next open the (x)= Arguments tab in the dialog and edit the VM arguments text area as seen on the next screenshot. Add the following option to the end of the area.

Windows
-noverify -javaagent:c:\javarebel.jar

Linux
-noverify -javaagent:/home/john/javarebel.jar

Click for original size - Run Configurations JavaRebel Configured

Now apply the settings and run the configuration. You should see the following message in the console output.

Installation Confirmation

You have installed JavaRebel under WTP now. Next you need to configure some WTP options so that WTP auto publish would not interfere with JavaRebel class reloading.
WTP Specific Configurations

Automatic publishing should be enabled in the server configuration. Double click on your server name and a configuration page opens. Under the Publish section you should have the Automatically publish when resources change option selected. I’ve outlined the automatic publishing settings in the following screenshot.

Click for original size - Automatic Publishing Settings

All your modules should have Auto Reload disabled. You can achieve this by opening the Modules tab of the server configuration and editing each module to disable auto reloading.

Click for original size - Disable Auto reloading

This is it. Once you have these configurations in place and you have restarted the container you are ready to use JavaRebel with WTP.

Make changes to your Java source files and they will be reloaded by JavaRebel. Make changes to your static content under you WebContent and they will be copied by WTP to your deployment folder.

If you have any questions or problems about setting up WTP and JavaRebel leave a comment or send an email to support [at] zeroturnaround.com.

Eclipse 3.4 and WTP 3.0 were used to test the functionality. The article is inspired by Utilisation de JavaRebel avec Eclipse.

猜你喜欢

转载自xiaocaiinlove.iteye.com/blog/890356