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());
    
     // 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_DFLTBNDG_VHOST, "default_host");
     props.put (AppConstants.APPDEPL_DFLTBNDG_DDSJNDI, "jdbc/MyDataSource");
     props.put (AppConstants.APPDEPL_DFLTBNDG_DDSUSER, "username");
     props.put (AppConstants.APPDEPL_DFLTBNDG_DDSPASS, "password");
     props.put (AppConstants.APPDEPL_DFLTBNDG_EJBJNDIPREFIX, "ejb");
     props.put (AppConstants.APPDEPL_DFLTBNDG_CFJNDI, "cf/MyFactory");
     props.put (AppConstants.APPDEPL_DFLTBNDG_CFRESAUTH, "Container");
     props.put (AppConstants.APPDEPL_DFLTBNDG_STRATEGY, "C:/mydir/strategy.xml");
     props.put (AppConstants.APPDEPL_DFLTBNDG_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 Detail

      • taskHelperSuffix

        @Deprecated
        public static final java.lang.String taskHelperSuffix
        Deprecated. 
        See Also:
        Constant Field Values
      • HIGHEST_CLIENT_MAJOR_VERSION

        public static final int HIGHEST_CLIENT_MAJOR_VERSION
        See Also:
        Constant Field Values
      • taskInfo

        protected java.util.Vector<com.ibm.websphere.management.application.client.AppDeploymentTaskInfo> taskInfo
      • taskNames

        protected java.util.Vector<java.lang.String> taskNames
      • 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
      • configSession

        protected Session configSession
      • 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
        Name Value
        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<java.lang.String,?> preferences)
                                  throws com.ibm.websphere.management.application.client.AppDeploymentException
        Throws:
        com.ibm.websphere.management.application.client.AppDeploymentException
      • getDeploymentMode

        public long getDeploymentMode()
      • getClientMajorVersion

        public int getClientMajorVersion()
        Returns the major version of the client code associated with this controller. Typically this is useful only when tasks are created on the application server for editing. In that scenario, if a remote client (e.g. wsadmin) running a lower level WebSphere calls a WebSphere server code (AppManagement.getApplicationInfo) then the server code needs to figure out the client version to know what task information to pass back. If a task in v5 has new columns added in v6 then they can not be passed to the remote wsadmin client since the runtime on that client will know nothing about the new columns. In this case, the client version is helpful in determining what to pass back. For all other scenarios (install, local mode install/edit, update) the client version is treated as the highest version i.e. version that can handle the latest version of the tasks.
        Returns:
        int remote client major version for edit mode, highest version in all other cases.
      • handlePreferences

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

        public com.ibm.ws.management.application.client.DefaultBinding getDefaultBindingTask(java.util.Hashtable prefs)
                                                                                      throws com.ibm.websphere.management.application.client.AppDeploymentException
        Called by the client code to return an instance of DefaultBinding task. This method should be used together with completeDefaultBindingTask to get/set the default binding options. The call should be done before getFirstTask is called if default bindings is to be performed. Code snippets:
             DefaultBinding task = appController.getDefaultBindingTask(optProps);
              
             // codes implemented by client to display the binding options
             // and inputs from user, or under the cover to set up the
             // values
        
             appController.completeDefaultBindingTask(task);
        
             AppDeploymentTask task = appController.getFirstTask();
             ...
             ...
         
        That is all client needs to do for default bindings.
        Parameters:
        prefs - perference table
        Returns:
        an instance of DefaultBinding task
        Throws:
        com.ibm.websphere.management.application.client.AppDeploymentException
      • completeDefaultBindingTask

        public void completeDefaultBindingTask(com.ibm.ws.management.application.client.DefaultBinding task)
                                        throws com.ibm.websphere.management.application.client.AppDeploymentException
        Called by the client code to complete the DefaultBinding task. See getDefaultBindingTask(java.util.Hashtable) for more information.
        Parameters:
        task - an instance of DefaultBinding task
        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
        Create application deployment tasks.
        Throws:
        com.ibm.websphere.management.application.client.AppDeploymentException
      • getTaskHelper

        protected com.ibm.websphere.management.application.client.AppDeploymentTaskHelper getTaskHelper(java.lang.String taskName)
                                                                                                 throws com.ibm.websphere.management.application.client.AppDeploymentException
        Returns task helper for task.
        Parameters:
        taskName -
        Returns:
        AppDeploymentTaskHelper
        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
        Returns task helper for task.
        Parameters:
        taskIndex -
        Returns:
        AppDeploymentTaskHelper
        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
      • checkIfSufficientlyDoneInTaskHelper

        public void checkIfSufficientlyDoneInTaskHelper(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
      • 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()
      • isClientModuleEnabled

        public boolean isClientModuleEnabled()
        Returns:
        whether client module is deployed
      • isEJBDeploySupportedForApp

        public boolean isEJBDeploySupportedForApp()
        EJBDeploy tool is not able to support EJB 3.0 starting with EE5. However, it is a no-op when it is called with EE5 and EE6 modules. With EE7, we will disable EJBDeploy when EE7 app/ejb/web DD is detected.
        Returns:
        whether EJBDeploy is supported for the app/ejb/web version
IBM WebSphere Application ServerTM
Release 9.0