IBM WebSphere Application ServerTM
Release 7

com.ibm.websphere.management.application.client
Class AppDeploymentController

java.lang.Object
  extended by com.ibm.websphere.management.application.client.AppDeploymentController
All Implemented Interfaces:
java.io.Serializable

public class AppDeploymentController
extends java.lang.Object
implements java.io.Serializable

The AppDeploymentController instance is used to prepare an application EAR file before installing it in WebSphere cell. The prparation phase involves collecting WebSphere-specific information, collectively known as bindings, that are used to tie deployment descriptors of application and its modules to WebSphere runtime.

The AppDeploymentController instance is created using a static factory method. It takes a local EAR file and creates a sequence of AppDeploymentTask objects (tasks) that are used collect various pieces of information needed to prepare the application. Once all the tasks are processed and the necessary information is collected, the AppDeploymentController instance is saved which saves some of the task data back into the EAR file and the rest to a hashtable. The updated EAR file and the hashtable returned by the AppDeploymentController can be passed to the AppManagement MBean in its installApplication API. The following sample code shows this operation -


 // Create controller
 String earFile = "C:/temp/foo.ear"; // EAR file to be installed
 Hashtable tbl = new Hashtable();
 tbl.put (AppConstants.APPDEPL_LOCALE, Locale.getDefault());

 // One can also optionally put default binding generation options as follows.
 Properties props = new Properties();
 tbl.put (AppConstants.APPDEPL_DFLTBNDG, props); // if not specified then default binding generation will not run
 // You can specify any of the following
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_VHOST, "default_host");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_DDSJNDI, "jdbc/MyDataSource");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_DDSUSER, "username");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_DDSPASS, "password");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_EJBJNDIPREFIX, "ejb");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_CFJNDI, "cf/MyFactory");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_CFRESAUTH, "Container");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_STRATEGY, "C:/mydir/strategy.xml");
 props.put (AppConstants.APPDEPL_DFLTLTBNDG_FORCE, AppConstants.YES_KEY);

 AppDeploymentController controller = AppDeploymentController.readArchive (earFile, tbl);

 // iterate through tasks
 AppDeploymentTask installTask = controller.getFirstTask();
 while (installTask != null)
 {
         // display the task
      String[][] data = installTask.getTaskData();

         // The task data is displayed in client specific manner.
         // Or it can be used to set specific task data by looking for a particular task name.

         installTask.setTaskData (data); // once it is changed
         installTask = controller.getNextTask();
 }

 // save the data back into ear file and the options table owned by the controller
 controller.saveAndClose();

 // get options saved by controller
 Hashtable options = controller.getAppOptions();

 // use the ear file and options table to install the app
 AdminClient adminClient = // create admin client
 AppManagementProxy proxy = AppManagementProxy.getJMXProxyForClient (adminClient);
 proxy.installApplication (earFile, "SomeAppName", options, null);

See Also:
Serialized Form

Field Summary
protected  long _deploymentMode
           
protected  AdminClient adminClient
           
protected  java.util.List changedTaskProcessList
           
protected  ConfigService configService
           
protected  Session configSession
           
protected  int currentTask
           
protected  com.ibm.websphere.management.application.client.AppDeploymentInfo deploymentInfo
           
protected  java.util.Hashtable preferences
           
protected  java.util.ResourceBundle resBundle
           
protected  java.util.Hashtable taskDataChangeListeners
           
static java.lang.String taskHelperSuffix
           
protected  java.util.Vector taskInfo
           
protected  java.util.Vector taskNames
           
protected  java.util.Vector tasks
           
 
Constructor Summary
AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info, java.util.Hashtable prefs, java.util.Vector taskI)
          Returns a new AppDeploymentController instance.
AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info, java.util.Vector tAll, java.util.Hashtable prefs, java.util.Vector taskI)
          Returns a new AppDeploymentController instance.
AppDeploymentController(java.util.Vector tAll, java.util.Vector taskI, java.util.Hashtable prefs)
          Returns a new AppDeploymentController instance.
 
Method Summary
 boolean checkIfEnhancedEar()
           
 void close(boolean bSave, boolean bValidate, boolean bClose)
          Closes the archive and saves it optionally.
protected  void createAppDeploymentTasks()
           
 void createDeploymentPlan(java.io.OutputStream out)
           
 AdminClient getAdminClient()
           
 java.util.Vector getAllTasks()
          Returns all tasks.
 java.util.Hashtable getAppDeploymentSavedResults()
          Returns the saved results at the end of app preparation phase.
 java.lang.String[] getAppDeploymentTaskNames()
          Returns the task names for all the tasks that should be executed during app preparation phase.
 java.util.Hashtable getAppOptions()
          Returns the app deployment options from the AppDeploymentInfo instance.
 int getAppVersion()
           
 int getAppVersion(boolean checkForFeature)
           
 ConfigService getConfigService()
           
 Session getConfigSession()
           
 com.ibm.ws.management.application.client.DataHolder getDataHolder()
           
protected  void getDependencyTask(int i)
           
 void getDependencyTask(java.lang.String taskName)
          Executes the dependency resolver for the given task
 long getDeploymentMode()
           
 org.eclipse.emf.ecore.resource.Resource getEnhancedEarDeploymentResource(java.lang.String resName)
           
 AppDeploymentTask getFirstTask()
          Returns the first Task object in the client side preparation process.
 java.lang.String[][] getModifiedTaskData(java.lang.String taskName, java.lang.String[][] data)
           
 AppDeploymentTask getNextTask()
          Returns the next Task object in the client side preparation process.
protected  AppDeploymentTask getNthTask(int i)
           
 int getRarVersion()
           
 java.lang.String getSecurityPolicyData()
           
 java.lang.String getSecurityPolicyWarning()
           
 java.util.List getSelectedOptions()
           
 java.util.Hashtable getServerTable()
           
 AppDeploymentTask getTaskByName(java.lang.String taskName)
          Returns the task with a given name
 AppDeploymentTask getTaskByName(java.lang.String taskName, boolean b)
          Returns the task with a given name
protected  com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(int taskIndex)
           
protected static com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(java.lang.String taskName)
           
 com.ibm.websphere.management.application.client.AppDeploymentTaskInfo getTaskInfo()
          Deprecated. Returns AppDeploymentTaskInfo instance for current task.
 com.ibm.websphere.management.application.client.AppDeploymentTaskInfo getTaskInfo(java.lang.String taskName)
          Deprecated. Returns AppDeploymentTaskInfo instance for given task.
protected  void handlePreferences(java.util.Hashtable instPrefs)
           
protected  void initializeEncoderDecoder()
           
 boolean isPartialDeploymentInfo()
          Returns whether the archive for this AppDeploymentController is opened for editing/viewing.
 void postAllPrepareTask(com.ibm.websphere.management.application.client.AppDeploymentInfo appInstallInfo, AppDeploymentTask task)
           
 AppDeploymentTask preAllCompleteTask(AppDeploymentTask t)
           
protected  void prepareTask(int i, AppDeploymentTask task)
           
static AppDeploymentController readArchive(java.lang.String ear, java.util.Hashtable preferences)
          Creates a new instance of AppDeploymentController for a given application EAR file and a set of preferences.
static AppDeploymentController readArchive(java.lang.String ear, java.util.Hashtable preferences, java.util.Vector taskI)
          Creates a new instance of AppDeploymentController for a given application EAR file and a set of preferences.
 void readDeploymentPlan(java.io.File file)
           
 void readDeploymentPlan(java.io.InputStream in)
           
 void resetDataHolder()
           
 void saveAndClose()
          Saves the task data back into application archive.
 void saveAsFile(java.lang.String moduleUri, java.lang.String fileUriInModule, java.io.InputStream inputStream)
          Save the input stream as a file in the specified location
 void setAppOptions(java.util.Hashtable tbl)
          Sets the app deployment options from the AppDeploymentInfo instance.
protected  void setDeploymentMode(java.util.Hashtable prefs)
           
 void setVariableMap(java.util.Vector vtask)
           
 java.lang.String[] validate()
          Validates the task data.
 java.lang.String[] validateInTaskHelper(java.lang.String taskName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskHelperSuffix

public static final java.lang.String taskHelperSuffix
See Also:
Constant Field Values

taskInfo

protected java.util.Vector taskInfo

taskNames

protected java.util.Vector taskNames

tasks

protected java.util.Vector tasks

currentTask

protected int currentTask

preferences

protected java.util.Hashtable preferences

deploymentInfo

protected transient com.ibm.websphere.management.application.client.AppDeploymentInfo deploymentInfo

resBundle

protected transient java.util.ResourceBundle resBundle

_deploymentMode

protected long _deploymentMode

configService

protected ConfigService configService

configSession

protected Session configSession

adminClient

protected AdminClient adminClient

taskDataChangeListeners

protected java.util.Hashtable taskDataChangeListeners

changedTaskProcessList

protected java.util.List changedTaskProcessList
Constructor Detail

AppDeploymentController

public AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info,
                               java.util.Hashtable prefs,
                               java.util.Vector taskI)
                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns a new AppDeploymentController instance. This constructor should never be called directly. Instead AppDeploymentController.readArchive (ear, prefs) method should be used.

Parameters:
info - The application information object
prefs - Preferences
taskI - The task related information
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

AppDeploymentController

public AppDeploymentController(java.util.Vector tAll,
                               java.util.Vector taskI,
                               java.util.Hashtable prefs)
                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns a new AppDeploymentController instance. This constructor should never be called directly. Instead AppDeploymentController.readArchive (ear, prefs) method should be used.

Parameters:
tAll - All tasks
prefs - Preferences
taskI - The task related information
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

AppDeploymentController

public AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info,
                               java.util.Vector tAll,
                               java.util.Hashtable prefs,
                               java.util.Vector taskI)
                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns a new AppDeploymentController instance. This constructor should never be called directly. Instead AppDeploymentController.readArchive (ear, prefs) method should be used.

Parameters:
info - The application information object
tAll - All tasks
prefs - Preferences
taskI - The task related information
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException
Method Detail

readArchive

public static AppDeploymentController readArchive(java.lang.String ear,
                                                  java.util.Hashtable preferences)
                                           throws com.ibm.websphere.management.application.client.AppDeploymentException
Creates a new instance of AppDeploymentController for a given application EAR file and a set of preferences. This controller instance is then used to create and manage various tasks (AppDeploymentTask instances) performed during application installation.

Parameters:
ear - The application EAR file name
preferences - The preferences table. The hashtable can have following keys
AppConstants.APPDEPL_LOCALE java.util.Locale
Returns:
AppDeploymentController instance
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

readArchive

public static AppDeploymentController readArchive(java.lang.String ear,
                                                  java.util.Hashtable preferences,
                                                  java.util.Vector taskI)
                                           throws com.ibm.websphere.management.application.client.AppDeploymentException
Creates a new instance of AppDeploymentController for a given application EAR file and a set of preferences. This controller instance is then used to create and manage various tasks (AppDeploymentTask instances) performed during application installation.

Parameters:
ear - The application EAR file name
preferences - The preferences table
taskI - Should always be null
Returns:
AppDeploymentController instance
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

setDeploymentMode

protected void setDeploymentMode(java.util.Hashtable prefs)
                          throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getDeploymentMode

public long getDeploymentMode()

handlePreferences

protected void handlePreferences(java.util.Hashtable instPrefs)
                          throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

initializeEncoderDecoder

protected void initializeEncoderDecoder()
                                 throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

createAppDeploymentTasks

protected void createAppDeploymentTasks()
                                 throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getTaskHelper

protected static com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(java.lang.String taskName)
                                                                                                throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getTaskHelper

protected com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(int taskIndex)
                                                                                         throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getAppDeploymentTaskNames

public java.lang.String[] getAppDeploymentTaskNames()
Returns the task names for all the tasks that should be executed during app preparation phase.

Returns:
The array of task names.

getFirstTask

public AppDeploymentTask getFirstTask()
                               throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns the first Task object in the client side preparation process.

Returns:
The first task object
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getNthTask

protected AppDeploymentTask getNthTask(int i)
                                throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

prepareTask

protected void prepareTask(int i,
                           AppDeploymentTask task)
                    throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getNextTask

public AppDeploymentTask getNextTask()
                              throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns the next Task object in the client side preparation process.

Returns:
The next task object
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getTaskByName

public AppDeploymentTask getTaskByName(java.lang.String taskName,
                                       boolean b)
                                throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns the task with a given name

Parameters:
taskName - The task name
b - The boolean that specifies if the returned task becomes the current task in the preparation phase
Returns:
The task instance
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getAllTasks

public java.util.Vector getAllTasks()
Returns all tasks.

Returns:
A vector of tasks

getTaskByName

public AppDeploymentTask getTaskByName(java.lang.String taskName)
                                throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns the task with a given name

Parameters:
taskName - The task name
Returns:
The task instance
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getDependencyTask

protected void getDependencyTask(int i)
                          throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getDependencyTask

public void getDependencyTask(java.lang.String taskName)
                       throws com.ibm.websphere.management.application.client.AppDeploymentException
Executes the dependency resolver for the given task

Parameters:
taskName - The task name
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

close

public void close(boolean bSave,
                  boolean bValidate,
                  boolean bClose)
           throws com.ibm.websphere.management.application.client.AppDeploymentException
Closes the archive and saves it optionally.

Parameters:
bSave - Specifies if the task data should be saved
bValidate - Specifies if the task data should be validated
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

saveAndClose

public void saveAndClose()
                  throws com.ibm.websphere.management.application.client.AppDeploymentException
Saves the task data back into application archive.

Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

validate

public java.lang.String[] validate()
                            throws com.ibm.websphere.management.application.client.AppDeploymentException
Validates the task data. Checked to see if all tasks are sifficiently done.

Returns:
The string array of empty and/or syntatically invalid task data
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

validateInTaskHelper

public java.lang.String[] validateInTaskHelper(java.lang.String taskName)
                                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getAppOptions

public java.util.Hashtable getAppOptions()
Returns the app deployment options from the AppDeploymentInfo instance.

Returns:
The app deployment options

setAppOptions

public void setAppOptions(java.util.Hashtable tbl)
Sets the app deployment options from the AppDeploymentInfo instance.

Parameters:
The - app deployment options

getAppDeploymentSavedResults

public java.util.Hashtable getAppDeploymentSavedResults()
Returns the saved results at the end of app preparation phase. This method should be called AFTER the saveAndClose method is called.

Returns:
The app deployment options

getTaskInfo

public com.ibm.websphere.management.application.client.AppDeploymentTaskInfo getTaskInfo()
Deprecated. Returns AppDeploymentTaskInfo instance for current task.

Returns:
The AppDeploymentTaskInfo instance

getTaskInfo

public com.ibm.websphere.management.application.client.AppDeploymentTaskInfo getTaskInfo(java.lang.String taskName)
Deprecated. Returns AppDeploymentTaskInfo instance for given task.

Returns:
The AppDeploymentTaskInfo instance

isPartialDeploymentInfo

public boolean isPartialDeploymentInfo()
Returns whether the archive for this AppDeploymentController is opened for editing/viewing.

Returns:
true if archive is opened for editing or viewing.

getSecurityPolicyData

public java.lang.String getSecurityPolicyData()
                                       throws com.ibm.websphere.management.application.client.AppDeploymentException
Returns:
the contents of the was.policy file in string format
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getSecurityPolicyWarning

public java.lang.String getSecurityPolicyWarning()
Returns:
the warning message if the enterprise application is a J2EE 1.2 application and a was.policy file is added to grant all permissions to the applicaiton.

saveAsFile

public void saveAsFile(java.lang.String moduleUri,
                       java.lang.String fileUriInModule,
                       java.io.InputStream inputStream)
                throws com.ibm.websphere.management.application.client.AppDeploymentException
Save the input stream as a file in the specified location

Parameters:
moduleUri - The name of the module file within the archive
fileUriInModule - The relative location and name of the file to be saved as within the module file
inputStream - The input stream to be saved
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

createDeploymentPlan

public void createDeploymentPlan(java.io.OutputStream out)
                          throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

readDeploymentPlan

public void readDeploymentPlan(java.io.File file)
                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

readDeploymentPlan

public void readDeploymentPlan(java.io.InputStream in)
                        throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getSelectedOptions

public java.util.List getSelectedOptions()

getAppVersion

public int getAppVersion()

getAppVersion

public int getAppVersion(boolean checkForFeature)

getRarVersion

public int getRarVersion()
                  throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getServerTable

public java.util.Hashtable getServerTable()
                                   throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getAdminClient

public AdminClient getAdminClient()

getConfigSession

public Session getConfigSession()

getConfigService

public ConfigService getConfigService()
                               throws java.lang.Exception
Throws:
java.lang.Exception

checkIfEnhancedEar

public boolean checkIfEnhancedEar()

getEnhancedEarDeploymentResource

public org.eclipse.emf.ecore.resource.Resource getEnhancedEarDeploymentResource(java.lang.String resName)

postAllPrepareTask

public void postAllPrepareTask(com.ibm.websphere.management.application.client.AppDeploymentInfo appInstallInfo,
                               AppDeploymentTask task)

setVariableMap

public void setVariableMap(java.util.Vector vtask)

preAllCompleteTask

public AppDeploymentTask preAllCompleteTask(AppDeploymentTask t)
                                     throws com.ibm.websphere.management.application.client.AppDeploymentException
Throws:
com.ibm.websphere.management.application.client.AppDeploymentException

getModifiedTaskData

public java.lang.String[][] getModifiedTaskData(java.lang.String taskName,
                                                java.lang.String[][] data)

resetDataHolder

public void resetDataHolder()

getDataHolder

public com.ibm.ws.management.application.client.DataHolder getDataHolder()

IBM WebSphere Application ServerTM
Release 7