Java Reference
In-Depth Information
Figure 8.7 Successful HotSwap with the IBM JVM
HOTSWAP WITH JREBEL
Yes, you can do better. A JVM agent called JR ebel (formerly known as JavaRebel;
www.zeroturnaround.com/jrebel/ ) behaves in a way similar to HotSwap but has much
better support for custom class-loading solutions like OSG i. For those who don't know,
a JVM agent is a small native library that attaches to the process on startup and is
granted low-level access to the Java runtime. Whenever you recompile a class, JR ebel
automatically updates the appropriate version loaded in the JVM without affecting any
other versions of the class. This makes it easy to develop, debug, and compare differ-
ent releases of an application at the same time.
What are the downsides? The main downside is reduced performance due to the
extra tracking involved. JR ebel also needs to know how custom class loaders map their
classes and resources to local files. It currently supports the Equinox OSG i implemen-
tation, but there's no guarantee it will work with other OSG i frameworks. Finally, you
need to add an option to the JVM command line to use it, which is problematic in pro-
duction environments that lock down the JVM 's configuration. Some places won't let
you use JVM agents at all because of the potential security issues involved. Agents have
access to the entire process and can redefine almost any class in your application.
Adding an agent to your JVM is like giving root access to a user in Linux. For these rea-
sons, JR ebel is usually best suited to development environments.
But what if you're working somewhere that forbids the use of debuggers or JVM
agents? Is there any other way you can update the broken bundle without restarting
the whole process?
HOTSWAP THE OSGI WAY
Update is the key word here. Back in section 3.7, we discussed the update and refresh
parts of the OSG i lifecycle. Well, you can use them here to deploy your fix without having
Search WWH ::




Custom Search