15. Jetty Launcher
public class Launcher {
public static void main(String[] args) {
Server server = new Server();
SelectChannelConnector connector
= new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
WebAppContext context = new WebAppContext("war", "/");
server.setHandler(context);
server.start();
}
}
16. “…I know about JRebel, but I cannot
pay for it, so I tried Maven…”
- Stackoverflow
22. Why Code Reloading is Hard?
Externalized Temporary
State
Serializable Derivative
23. How To Reload a Class?
OldClassLoader NewClassLoader
MyObject.class MyObject.class
Recreate object
MyObject MyObject
24. Serialize/deserialize
init()
Session Session
Sevlet New Sevlet
Classes
Classes
App App
New State
Libraries State
Libraries
OldClassLoader NewClassLoader
25. Session Session
Sevlet New Sevlet
Classes
Classes
App App
New State
State
Libraries
OldClassLoader NewClassLoader
26.
27.
28. Component State
New New
Class Object
Class Object
Old Component New Component
ClassLoader ClassLoader
29. HotSwap
Make changes in IDE
OldClassLoader
MyObject.class
New
HotSwap
Code code
Debugger
111000100
101000101
101010010
100010010 New code
111000100
101010010
MyObject
Vendors make money on production => development is secondaryOperations rule development, best practices are heavily influenced by production needsMultiple participants in the standard working groups means a choice between reducing scope of the standard or reducing its qualityStory: when we tried pitching JRebel to a large Java app server vendor the answer was: why bother?
Jetty has support for any app layout, but docs are missing. Maven Jetty plugin is the only workable application of this functionality.RAD & Websphere have decent integration that tries to copy the minimal amount of files possible. Copying isn’t a great idea, though.Weblogic has the split directory structure functionality which is powerful on paperEclipse, NetBeans and IntelliJ IDEA have support for publishing applications from the IDE, which varies from decent to awful.SpringSource has fairly decent integration between tooling and server, but only for tc Server.Jboss used to run Ant on every update in Eclipse, Netbeans still does that
Externalized ~= PHP, Database, memcachedetcTemporary ~= StatelessJava frameworks/servers often have too much derivative state and it takes too long to createSerializing helps when it can§
If you want to preserve the state, this is what you have to do.
Class loader scopeEvery deployed application gets a dedicated class loaderState recreationApplication state is recovered by reinitializationSession state is (optionally) serialized and deserialized in the new class loaderReloading timeApplication reinitialization time, typically around one minuteProblemsLeaks memoryLazy caches need to be warmed up every time
Class loader scopeEvery deployed application gets a dedicated class loaderState recreationApplication state is recovered by reinitializationSession state is (optionally) serialized and deserialized in the new class loaderReloading timeApplication reinitialization time, typically around one minuteProblemsLeaks memoryLazy caches need to be warmed up every time
Class loader scopeClass loader per component/serviceState recreationState restored by framework (component/service recreated)Reloading time(Almost) InstantProblemsOnly managed components can be reloadedManaged components referring unmanaged code can be a problem (twin class issues)