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

java.lang.Object
  |
  +--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());
 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  int currentTask
           
protected  com.ibm.websphere.management.application.client.AppDeploymentInfo deploymentInfo
           
protected  java.util.ResourceBundle resBundle
           
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
 void close(boolean bSave, boolean bValidate, boolean bClose)
          Closes the archive and saves it optionally.
protected static java.util.Vector createAppDeploymentDependencyTaskHelpers()
           
protected static java.util.Vector createAppDeploymentTaskHelpers(java.util.Vector tNames)
           
protected static java.util.Vector createAppDeploymentTaskNames()
           
protected  void createAppDeploymentTasks()
           
 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.
static java.util.Vector getDefaultTaskInfo(com.ibm.websphere.management.application.client.AppDeploymentInfo appInfo)
          Deprecated. Returns the default task info objects that are used to create the default tasks during app preparation.
static java.util.Vector getDefaultTaskInfo(com.ibm.websphere.management.application.client.AppDeploymentInfo appInfo, java.util.Hashtable prefs)
          Deprecated. Returns the default task info objects that are used to create the default tasks during app preparation.
protected  void getDependencyTask(int i)
           
 void getDependencyTask(java.lang.String taskName)
          Executes the dependency resolver for the given task
 com.ibm.websphere.management.application.client.AppDeploymentTask getFirstTask()
          Returns the first Task object in the client side preparation process.
 com.ibm.websphere.management.application.client.AppDeploymentTask getNextTask()
          Returns the next Task object in the client side preparation process.
protected  com.ibm.websphere.management.application.client.AppDeploymentTask getNthTask(int i)
           
 java.lang.String getSecurityPolicyData()
           
 java.lang.String getSecurityPolicyWarning()
           
 com.ibm.websphere.management.application.client.AppDeploymentTask getTaskByName(java.lang.String taskName)
          Returns the task with a given name
 com.ibm.websphere.management.application.client.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.
protected  void prepareTask(int i, com.ibm.websphere.management.application.client.AppDeploymentTask task)
           
static com.ibm.websphere.management.application.client.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 com.ibm.websphere.management.application.client.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 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.
 java.lang.String[] validate()
          Validates the task data.
 
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

deploymentInfo

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

resBundle

protected transient java.util.ResourceBundle resBundle
Constructor Detail

AppDeploymentController

public AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info,
                               java.util.Hashtable prefs,
                               java.util.Vector taskI)
                        throws 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

AppDeploymentController

public AppDeploymentController(java.util.Vector tAll,
                               java.util.Vector taskI,
                               java.util.Hashtable prefs)
                        throws 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

AppDeploymentController

public AppDeploymentController(com.ibm.websphere.management.application.client.AppDeploymentInfo info,
                               java.util.Vector tAll,
                               java.util.Hashtable prefs,
                               java.util.Vector taskI)
                        throws 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
Method Detail

readArchive

public static com.ibm.websphere.management.application.client.AppDeploymentController readArchive(java.lang.String ear,
                                                                                                  java.util.Hashtable preferences)
                                                                                           throws 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
AppDeploymentException

readArchive

public static com.ibm.websphere.management.application.client.AppDeploymentController readArchive(java.lang.String ear,
                                                                                                  java.util.Hashtable preferences,
                                                                                                  java.util.Vector taskI)
                                                                                           throws 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
AppDeploymentException

getDefaultTaskInfo

public static java.util.Vector getDefaultTaskInfo(com.ibm.websphere.management.application.client.AppDeploymentInfo appInfo)
                                           throws AppDeploymentException
Deprecated. Returns the default task info objects that are used to create the default tasks during app preparation.

Parameters:
appInfo - The AppDeploymentInfo instance that wraps the ear file and the deployment options
Returns:
Returns the vector of default TaskInfo objects.
AppDeploymentException

getDefaultTaskInfo

public static java.util.Vector getDefaultTaskInfo(com.ibm.websphere.management.application.client.AppDeploymentInfo appInfo,
                                                  java.util.Hashtable prefs)
                                           throws AppDeploymentException
Deprecated. Returns the default task info objects that are used to create the default tasks during app preparation.

Parameters:
appInfo - The AppDeploymentInfo instance that wraps the ear file and the deployment options
prefs - preferences where you can provide an entry to specify the locale to create the AppDeploymentMessages
Returns:
Returns the vector of default TaskInfo objects.
AppDeploymentException

createAppDeploymentTaskNames

protected static java.util.Vector createAppDeploymentTaskNames()

createAppDeploymentTaskHelpers

protected static java.util.Vector createAppDeploymentTaskHelpers(java.util.Vector tNames)
                                                          throws AppDeploymentException
AppDeploymentException

createAppDeploymentDependencyTaskHelpers

protected static java.util.Vector createAppDeploymentDependencyTaskHelpers()

handlePreferences

protected void handlePreferences(java.util.Hashtable instPrefs)
                          throws AppDeploymentException
AppDeploymentException

initializeEncoderDecoder

protected void initializeEncoderDecoder()
                                 throws AppDeploymentException
AppDeploymentException

createAppDeploymentTasks

protected void createAppDeploymentTasks()
                                 throws AppDeploymentException
AppDeploymentException

getTaskHelper

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

getTaskHelper

protected com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(int taskIndex)
                                                                                         throws AppDeploymentException
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 com.ibm.websphere.management.application.client.AppDeploymentTask getFirstTask()
                                                                               throws AppDeploymentException
Returns the first Task object in the client side preparation process.

Returns:
The first task object
AppDeploymentException

getNthTask

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

prepareTask

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

getNextTask

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

Returns:
The next task object
AppDeploymentException

getTaskByName

public com.ibm.websphere.management.application.client.AppDeploymentTask getTaskByName(java.lang.String taskName,
                                                                                       boolean b)
                                                                                throws 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
AppDeploymentException

getAllTasks

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

Returns:
A vector of tasks

getTaskByName

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

Parameters:
taskName - The task name
Returns:
The task instance
AppDeploymentException

getDependencyTask

protected void getDependencyTask(int i)
                          throws AppDeploymentException
AppDeploymentException

getDependencyTask

public void getDependencyTask(java.lang.String taskName)
                       throws AppDeploymentException
Executes the dependency resolver for the given task

Parameters:
taskName - The task name
AppDeploymentException

close

public void close(boolean bSave,
                  boolean bValidate,
                  boolean bClose)
           throws 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
AppDeploymentException

saveAndClose

public void saveAndClose()
                  throws AppDeploymentException
Saves the task data back into application archive.

AppDeploymentException

validate

public java.lang.String[] validate()
                            throws 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
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.


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 AppDeploymentException
Returns:
the contents of the was.policy file in string format
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 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
AppDeploymentException


 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.