Using FastSwap to speed up development

A fast turnaround time is something that most developers appreciate and since JDK 5 it is possible to redefine a class without dropping the class loader. However, the support provided by the JDK is limited and does not allow the developer to reshape the class, i.e., fields and methods cannot be changed/altered. FastSwap is a feature within WLS that, when enabled, is designed to overcome these limitations. For example, it will allow the developer to add new methods to an already loaded class and see those changes take effect immediately.

Enabling FastSwap

In order to take advantage of FastSwap, WLS must be running in development mode and FastSwap must have been turned on for that particular deployment. For applications deployed as an EAR, adding the element to the weblogic-application.xml file enables FastSwap and for applications deployed as a WAR, the element should be inserted into the weblogic.xml file instead.


<fast-swap>
<enabled>true</enabled>
</fast-swap>

FastSwap will only monitor changes of classes in exploded directories so if an exploded EAR contains an archived WAR, any changes to that WAR will not be detected. Therefore, the WAR also needs to be unpacked and then FastSwap will monitor all the classes found under the web application's WEB-INF/classes directory. Note that any jars residing in WEB-INF/lib will not be monitored.

Developing with FastSwap

Once FastSwap has been enabled for a particular deployment, it will pick up any change made to a monitored class at runtime, allowing the change to take place immediately.

Using a web application as an example, the typical development flow would be:


  • Deploy the exploded web application

  • Access the application through a web browser

  • Modify the code, compile the changes and have the corresponding class files saved to the correct location under the exploded application.

  • Access the application through a web browser once again, and your changes will now have been applied and should be visible.

Note that FastSwap will not redefine any classes as soon as they have changed on the file system. The reason is because a change to one class file can affect other classes (e.g. when a method signature is changed) so all classes must be redefined at the same time. Therefore, the developer will need to tell FastSwap when it should start its operation. For web applications, this is accomplished by going through a servlet but for other applications the developer has to use the JMX interface for FastSwap. However, there is an Ant task accessing this JMX interface that can used to trigger FastSwap, as shown in the below example.


<project name='MyProject' default='all'>
<taskdef name='fast-swap' classname='com.bea.wls.redef.ant.FastSwapTask'/>
<target name='all'>
<fast-swap
adminUrl='t3://localhost:7001'
user='weblogic'
password='weblogic'
server='myserver'
application='SimpleApp'
/>
</target>
</project>

Where the parameters are:


  • adminUrl: connection url

  • user: user name

  • password: user password

  • server: managed server name

  • application: deployed application name

Limitations & Further Reading

Even though FastSwap is an improvement over the default support found in the JDK there are still some limitations to what it can accomplish. For a list of these limitations as well as more information regarding FastSwap, please visit the following link:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/deployment/deployunits.html#wp1053872

Comments:

just a fyi, this page shows up weird on my browser

Posted by traffic law on September 29, 2010 at 10:38 AM PDT #

just a fyi, this page shows up weird on my browser

Posted by dui south on September 29, 2010 at 10:47 AM PDT #

Please, if someone could elaborate a bit more, to help clear up any confusion here. Thanks.

Posted by Pedro Hempe on December 23, 2010 at 12:41 PM PST #

Definitely believe that which you stated. Your favorite justification appeared to be on the internet the easiest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they just do not know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thanks

Posted by posicionamiento google on February 03, 2011 at 04:58 AM PST #

Definitely believe that which you stated. Your favorite reason appeared to be on the web the easiest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just don't know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

Posted by posicionamiento web on February 03, 2011 at 05:38 AM PST #

Undeniably believe that which you stated. Your favorite reason seemed to be on the internet the easiest thing to be aware of. I say to you, I certainly get annoyed while people think about worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks

Posted by posicionamiento google on February 03, 2011 at 06:32 AM PST #

Love all the opinions expressed here! How is everyone? :)

Posted by Shante Lofton on February 03, 2011 at 05:08 PM PST #

having fast-swap enabled in weblogic.xml for an exploded war, I am unable to get remote debugging working for any java class files in the war. Is there a way to have both fast-swap and remote-debugging working at the same time?

Posted by sd on February 24, 2011 at 04:45 AM PST #

thanks 1

Posted by Sharon on March 01, 2011 at 10:13 AM PST #

The new Zune browser is surprisingly good, but not as good as the iPod's. It works well, but isn't as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that's not an issue, but if you're planning to browse the web alot from your PMP then the iPod's larger screen and better browser may be important.

Posted by amazon on March 05, 2011 at 09:01 PM PST #

This is getting a bit more subjective, but I much prefer the Zune Marketplace. The interface is colorful, has more flair, and some cool features like 'Mixview' that let you quickly see related albums, songs, or other users related to what you're listening to. Clicking on one of those will center on that item, and another set of "neighbors" will come into view, allowing you to navigate around exploring by similar artists, songs, or users. Speaking of users, the Zune "Social" is also great fun, letting you find others with shared tastes and becoming friends with them. You then can listen to a playlist created based on an amalgamation of what all your friends are listening to, which is also enjoyable. Those concerned with privacy will be relieved to know you can prevent the public from seeing your personal listening habits if you so choose.

Posted by amazon.com on March 06, 2011 at 06:40 AM PST #

Please for the love of FSM implement some comment spam removal for this commenting system. A good start would be to remove the completely obsolete "URL" field - this is only used by spammers, and was only useful in the previous millenium. There is actually one other real commenter, who has an interesting question.

Posted by Anon on April 06, 2011 at 11:13 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

The official blog for Oracle WebLogic Server fans and followers!

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today