Enabling FastSwap In Your Application Application Types and Changes Supported with FastSwap

3-8 Deploying Applications to Oracle WebLogic Server

3.6.2 Supported FastSwap Application Configurations

The following application configuration are supported when using FastSwap deployment: ■ FastSwap is only supported when WebLogic Server is running in development mode. It is automatically disabled in production mode. ■ Only changes to class files in exploded directories are supported. Modifications to class files in archived applications, as well as archived JAR files appearing in the applications classpath are not supported. Examples are as follows: – When a Web application is deployed as an archived WAR within an EAR, modifications to any of the classes are not picked up by the FastSwap agent. – Within an exploded Web application, modifications to Java classes are only supported in the WEB-INFclasses directory; the FastSwap agent does not pick up changes to archived jars residing in WEB-INFlib.

3.6.3 Enabling FastSwap In Your Application

To enable FastSwap in your application, add the following element to the weblogic-application.xml file. fast-swap enabledtrueenabled fast-swap For more information on the weblogic-application.xml elements, see Enterprise Application Deployment Descriptor Elements in Developing Applications for Oracle WebLogic Server. FastSwap can also be enabled for a standalone Web application by adding the fast-swap element to the weblogic.xml file. For more information on the weblogic.xml elements, see weblogic.xml Deployment Descriptor Elements in Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server.

3.6.4 Overview of the FastSwap Process

The following steps describe how the FastSwap deployment process works: 1. Once FastSwap is enabled at the descriptor level, an appropriate classloader is instantiated when the application is deployed to WebLogic Server. 2. Open a browser to see the application at work. Modify addeditdelete the methods andor classes see Section 3.6.6, Limitations When Using FastSwap and then compile them. It is recommended that you use an IDE such as Eclipse or IntelliJ and setting the compile-on-save option so that Java files are compiled on saving. Also note that the FastSwap agent does not compile Java files. 3. Refresh the browser or send a new request to the application. The FastSwap agent tries to find all classes that have been modified since the last iteration by looking at all directories in the classpath. Considering an exploded application with a single Web application, the following directories are examined for any class file modifications based on their timestamps: ExampleAppAPP-INFclasses ExampleAppwebappWEB-INFclasses Preparing Applications and Modules for Deployment 3-9 The FastSwap agent redefines the modified classes in the application and then serves the request.

3.6.4.1 Using Ant with the JMX Interface

For headless applications that is, applications not fronted by a Web application, class redefinition can be explicitly initiated using the JMX interface. An Ant task that uses the JMX interface can be used to initiate class redefinition, as shown in following Ant FastSwapTask example. Example 3–1 Using Ant with the JMX Interface project name=MyProject default=all taskdef name=fast-swap classname=com.bea.wls.redef.ant.FastSwapTask target name=all -- Redefine classes which have changed since they were last loaded. Required parameters: adminUrl: Connection url user: User name password: User password server: Managed server name application: Deployed application name Optional parameters: module: Name of the module within the application. If not specified, all modules within the application will be processed. failonerror: Default=true. If true, task will fail if fast-swap failed. Otherwise, a message will be displayed and the task will return success. timeout: Default=300. Timeout in seconds. classnames: Comma separated list of classnames to process. If not specified, all classes within specified modules if any in the application will be considered. -- fast-swap adminUrl=t3:localhost:7001 user=weblogic password=weblogic server=myserver application=SimpleApp module=SimpleAppCookie failonerror=false timeout=30 classnames=examples.servlets.CookieCounter1, examples.servlets.CookieCounter2, examples.servlets.CookieCounter target project

3.6.5 Application Types and Changes Supported with FastSwap

FastSwap is supported with POJOs JARs, Web applications WARs and Enterprise applications EARs deployed in an exploded format. FastSwap is not supported with resource adapters RARs. The following types of changes are supported with FastSwap: 3-10 Deploying Applications to Oracle WebLogic Server ■ Addition of static methods ■ Removal of static methods ■ Addition of instance methods ■ Removal of instance methods ■ Changes to static method bodies ■ Changes to instance method bodies ■ Addition of static fields ■ Removal of static fields ■ Addition of instance fields ■ Removal of instance fields The following table lists detailed change types supported with FastSwap: Table 3–1 Supported Application Types and Changes Scope Java Change Type Supported Notes Java Class Add method Yes Addition of the finalize method is not supported. Instance non-abstract Remove method Yes Addition of the finalize method is not supported. a Add field Yes b Remove field Yes c Change method body Yes d Add constructor Yes e Remove constructor Yes f Change field modifiers Yes g Change method modifiers Yes Class-level static Add method Yes Remove method Yes Change body method Yes Class Hierarchy Changes Change list of implemented interfaces No Change extends SuperClass No Abstract Java Class Add abstract method Yes Delete abstract method Yes All other supported changes a–g listed in Instance Yes final Java Class Same supported changes a–g listed in Instance Yes final Java Method Same supported changes a–g listed in Instance Yes final Java Field Same supported changes a–g listed in Instance Yes Enum Add constants No Preparing Applications and Modules for Deployment 3-11

3.6.6 Limitations When Using FastSwap