您的位置:首页 > 其它

提高开发效率-jrebel插件安装

2011-08-12 14:21 661 查看


什么是JRebel?

JRebel安装一个javaagent监控系统中的classes和resources文件在工作空间的变化,然后在运行的应用服务器上热加载这些变化,支持下面的这些类型的文件改变:改变Java classes文件.
改变框架配置文件 (e.g. Spring XML files and annotations, Struts mappings, etc).
任何静态资源文件 (e.g. JSPs, HTMLs, CSSs, XMLs, .properties, etc)JRebel 是一个节约开发时间的工具,能够热加载改变的代码,不需要重新启动容器或重新发布应用程序.
一个JVM -javaagent 插件.-javaagent 是java5后的一个命令行属性,JRebel使用插件方式安装.JRebel 不是一个IDE插件.提供IDE插件是为了改善用户体验,JRebel在普通的java编译器和文本编辑器是一样可以使用的.
一个框架. JRebel不会在你的应用中引入任何依赖包. 你可以随时随地移除,不会影响你的开发.
一个应用服务器. JRebel可以工作在所有优秀的应用服务器上.
一个自定义的JVM. JRebel不需要改变JVM,它可以工作在所有基于JVM实现的优秀虚拟机.简单地说,它是JVM的一个插件 , 作为java class 加载代理, 监控文件系统中.class文件的变动, 帮助实现类的热加载. 在开发过程中, 可以省下可观的 Tomcat重启的时间.按年统计大约节省3到7周的时间
(官方数据) . 有了它, 你就可以像写PHP代码一样, 边修改边测试!


JRebel怎么工作的?

JRebel integrates with the JVM and application servers mainly on the class
loader level. It does not create any new class loaders, instead, it extends the existing ones with the ability to manage reloaded classes.When a class is loaded JRebel will try to find a corresponding .class file for it. It will search from the classpath (including an application classpath, like WEB-INF/classes)
and from the places specified in the rebel.xml configuration file. If it find a .class file JRebel instruments the loaded class and associates
it with the found .class file. The .class file timestamp is then monitored for changes in the loaded class and updates are propagated
through the extended class loader, to your application.JRebel can also monitor .class files in JARs if they are specified in rebel.xml.Importantly, when loading updates to a class, JRebel preserves all of the existing instances of that class. This allows the application to just continue working, but also means that when adding a new instance field it will not be initialized in the existing
instances, since the constructor will not be rerun.Some common misconceptions:JRebel just wraps class loaders around classes. In fact JRebel does not add a single new class loader to your application. The solution of reloading Java classes by wrapping them in throwaway
classloaders is a well-known one, but unfortunately also very limited. The problem is that unless you also throw away all of the instances of the classes loaded by said class loaders, the code will not reload. However throwing away those instances is only
possible if they are somehow managed by the framework, e.g. as it's done in Tapestry 5.
JRebel just uses Instrumentation
API. The Instrumentation API was introduced in Java 5 and included a limited ability to redefine Java classes on-the-fly. Unfortunately it is limited to only changing method bodies (as is HotSwap) and also suffers from several additional quirks, which
makes it not too useful in a real environment. JRebel agent does use it to instrument the application server class loaders and other basic classes, but the API does not play part in the actual reloading process.


安装Eclipse JRebel插件


1.1 Introduction

JRebel IDE plugins are available for Eclipse, IntelliJ IDEA and NetBeans and provide the following features:Debugger
Support for debugging the application with JRebel agent enabled. Necessary to set breakpoints, inspect expressions and step through code.
Running with JRebel
Support for starting the application or server from withing the IDE with the JRebel agent enabled.
[Missing in NetBeans and IntelliJ IDEA before 8.x]

rebel.xml generation
Support for generating the rebel.xml configuration file from the IDE project definition.
[Missing in NetBeans and IntelliJ IDEA before 8.x]


1.2 Eclipse

安装 JRebel Eclipse插件进入 Help » Install New Software... 并且输入下面的URL :http://www.zeroturnaround.com/update-site/离线安装包下载地址:http://www.zeroturnaround.com/update-site/update-site.zip如果你不选择嵌入JRebel,你需要手动填上jrebel.jar的系统中实际路径. 进入 Window » Preferences » JRebel a看到下面的图然后输入
jrebel.jar的路径

需要设置调试可以进入 Window » Preferences 然后到 Java » Debug » Step Filtering.选中 Use Step Filters, Filter synthetic methods及Step through filters. 现在选中所有的默认filters,然后点击Add Filter按钮,添加com.zeroturnaround.*org.zeroturnaround.*.
进入 Project » Build Automatically 确认以被选中.

Eclipse Tomcat设置


2.2 Eclipse

Tomcat server配置中的不需要自动发布. 双击服务器名称打开服务器配置页面选中Never publish automatically 和(Enable JRebel agent) .
如果你运行一个独立的应用服务器你可以选择enable
JRebel agent.


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: