Using FastSwap to reduce deployment time

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.

Note

Remember that this doesn't mean you don't have to publish a project after changing the source code—FastSwap only makes the deployment process quicker, but you still have to command Eclipse to execute the deployment procedure (if automatic publishing is disabled, obviously).

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 application must be deployed as an exploded archive—this is configured when you map the server in OEPE, as we just saw in the previous section
  • Classes inside packaged files aren't eligible to use it
  • Changing enums isn't supported

Tip

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:

  1. Open the weblogic.xml file located in the folder /WebContent/WEB-INF.
  2. In the Outline tree, click on General, and then click on FastSwap.
  3. Check the Enable class redefinition checkbox as shown in the following screenshot:
    Using FastSwap to reduce deployment time
  4. Save the file.

The other parameters available on the FastSwap configuration screen are:

  • Refresh interval (seconds): This value sets the interval at which FastSwap's engine will check for changes in the application classes, and fire up redefinition tasks, if needed. This parameter is only applied when using automatic publishing and an exploded archive deployment. The default value is 10 seconds.
  • Redefinition task limit: This sets the maximum number of redefinition tasks (the act of changing the bytecode) that can be monitored by JMX interfaces. Only the most recent tasks are kept available—when this limit is reached and a new redefinition task is created, the oldest task being monitored is discarded.

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:

Using FastSwap to reduce deployment time

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.

Note

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).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.170.65