To speed up the deployment process, we can enable the FastSwap feature, instructing the container to update bytecode without dropping the existing instances of the affected classes or reloading the classloader. This means that a class binary can be loaded into the container's memory without dropping the class' instances that are already in use—it's like updating a static file using the exploded directory archive (explained in the previous section) and making it immediately available to the container, but we're actually replacing binaries.
Not every change made to a class is a candidate to use the FastSwap feature, though. Here are a few requirements and constraints we need to observe to use this feature:
The complete list of supported changes and limitations can be found here: http://docs.oracle.com/cd/E24329_01/web.1211/e24443/deployunits.htm#i1054385
To show how to enable FastSwap, let's do it for the project theater:
The other parameters available on the FastSwap configuration screen are:
The configuration we just changed will create the
fast-swap
tag in the project's weblogic.xml
file as follows:
<wls:weblogic-web-app> <wls:weblogic-version>12.1.1</wls:weblogic-version> <wls:context-root>store</wls:context-root> ... <wls:fast-swap> <wls:enabled>true</wls:enabled> </wls:fast-swap> </wls:weblogic-web-app>
While publishing a module, you should see messages similar to the ones shown in the following screenshot in Eclipse's Error Log window, stating that the FastSwap feature is active:
If you make a change to a class that is not supported by FastSwap, an error message is shown, and the regular deployment procedure is executed.
There is an issue with FastSwap and
Contexts and Dependency Injection (CDI) that renders some projects unable to use the FastSwap feature—if a project contains classes annotated with ApplicationScoped
or SessionScoped
, for instance, the deployment procedure may raise an error and abort. At the time of writing, there was no definition about this issue being a problem or a design decision (bug # 13572166 at Oracle Support).