FileDocCategorySizeDatePackage
ServerInstance.javaAPI DocGlassfish v2 API58346Fri May 04 22:34:56 BST 2007com.sun.enterprise.tools.common.deploy

ServerInstance

public class ServerInstance extends Object implements Serializable
author
administrator
version

Fields Summary
private String
host
private String
ad_host
private transient PropertyChangeSupport
propertySupport
private String
name
Holds value of property name.
private String
dispName
private String
password
Holds value of property password.
private int
port
Holds value of property port.
private int
ad_port
private String
userName
Holds value of property userName.
public static String
pw_editor
transient boolean
checkAlreadyDone
transient boolean
IAS_Running
transient boolean
checkDone
transient boolean
KJS_Running
transient boolean
instRunning
transient boolean
isEnabled
private transient com.sun.enterprise.admin.servermodel.ServerInstanceManager
manager
private transient com.sun.enterprise.admin.servermodel.AppServerInstance
instance
String
depName
static final ResourceBundle
bundle
private int
debugPort
Constructors Summary
public ServerInstance(String SOM_name, String serv_name, int serv_port, String username, String passwd)
Creates new ServerInstance

 // NOI18N
     
        
               
        propertySupport = new PropertyChangeSupport ( this );
        userName = username;
        password = passwd;
        dispName = SOM_name;
        name = serv_name;
        port = serv_port;
        ad_host = serv_name.substring(serv_name.indexOf("(")+1, serv_name.indexOf(":"));//NOI18N
        ad_port = Integer.parseInt( serv_name.substring(serv_name.indexOf(":")+1, serv_name.indexOf(")")) );//NOI18N
    
public ServerInstance(String SOM_name, String serv_name, int serv_port)

        this(SOM_name,serv_name,serv_port,"admin","admin123");//NOI18N
    
public ServerInstance(String SOM_name, String serv_name)

        this(SOM_name,serv_name,-1);
    
Methods Summary
public voidApply(com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String server = this.getName();
      try{
        Reporter.info("---------------------Applying changes to Server Instance"); // NOI18N
        class ApplyThread extends Thread{
            public void run () { 
                try{
                    getSelectedInstance().applyChanges();
                    messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_Applyed"), new Object[]  {server}) ); //NOI18N
                }catch(AFTargetNotFoundException te){
		    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
                    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
            }//run
        }
        ApplyThread appl = new ApplyThread();
        appl.start();
        Reporter.info("---------------------After Applying changes to Server Instance"); // NOI18N
        while(appl.isAlive()){
             Thread.sleep(500);
        }
        Reporter.info("---------------------Finished Applying changes to Server Instance"); // NOI18N
      }catch(Exception e){
             e.printStackTrace();
      } 
  
public voidDisable(java.lang.String resName, java.lang.String resType, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String server = this.getName();
      try{
        Reporter.info("---------------------Before Disabling Resource"); // NOI18N
        class DisableThread extends Thread{
            public void run () { 
                try{
                    if(resType.trim().indexOf(".ear") != -1){ // NOI18N
                        DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
                        component.disable();
                    }else{
                        if(resType.trim().indexOf(".jar") != -1){ // NOI18N
                            DeployedEJBModuleComponentBean  component = getSelectedInstance().getDeployedEJBModule(resName);
                            component.disable();
                        }else if(resType.trim().indexOf(".war") != -1){ // NOI18N
                            DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);   
                            component.disable();
                        }else{
                            Reporter.info("####### UNKNOWN Archive Type");//NOI18N
                        }
                    }//else
                    getSelectedInstance().applyChanges();
                    messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinDisable"), new Object[]  {server}) ); //NOI18N
                }catch(AFTargetNotFoundException te){
		    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
		    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
            }//run
        }
        DisableThread disThread = new DisableThread();
        disThread.start();
        Reporter.info("---------------------After Disabling Resource"); // NOI18N
        while(disThread.isAlive()){
             Thread.sleep(500);
        }
        Reporter.info("---------------------Finished Disabling Resource"); // NOI18N
      }catch(Exception e){
             e.printStackTrace();
      } 
  
public voidEnable(java.lang.String resName, java.lang.String resType, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String server = this.getName();
      try{
        Reporter.info("---------------------Enabling Resource"); // NOI18N
        class EnableThread extends Thread{
            public void run () { 
                try{
                    if(resType.trim().indexOf(".ear") != -1){ // NOI18N
                        DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
                        component.enable();
                    }else{
                        if(resType.trim().indexOf(".jar") != -1){ // NOI18N
                            DeployedEJBModuleComponentBean  component = getSelectedInstance().getDeployedEJBModule(resName);
                            component.enable();
                        }else if(resType.trim().indexOf(".war") != -1){ // NOI18N
                            DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);   
                            component.enable();
                        }else{
                            Reporter.info("####### UNKNOWN Archive Type");//NOI18N
                        }
                    }//else
                    getSelectedInstance().applyChanges();
                    messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinEnable"), new Object[]  {server}) ); //NOI18N
                }catch(AFTargetNotFoundException te){
		    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
		    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
            }//run
        }
        EnableThread enThread = new EnableThread();
        enThread.start();
        Reporter.info("---------------------After Enabling Resource"); // NOI18N
        while(enThread.isAlive()){
            Thread.sleep(500);
        }
        Reporter.info("---------------------Finished Enabling Resource"); // NOI18N
      }catch(Exception e){
             e.printStackTrace();
      } 
  
public voidOverwriteConfig()

      getSelectedInstance().overwriteChanges();
  
public static booleanServName(java.lang.String value, java.util.List serv, java.lang.String nod_name, com.sun.enterprise.admin.util.HostAndPort hostport, java.lang.String uName, java.lang.String passwd)

       boolean exists = false;  
       value = value + "(" + nod_name + ")";//NOI18N
       for(int i=0; i<serv.size(); i++){
        IServerInstanceBean instance = (IServerInstanceBean) serv.get(i);
        String inst = instance.getName();
        if(inst.equals(value))
           exists = true;
       }//for 
       Iterator it = ServerInstanceManagerFactory.getFactory().getServerInstanceManager(hostport,uName,passwd).getAllServerInstances();
       while (it.hasNext()){
           String inst1 = ((AppServerInstance)it.next()).toString();
           if(inst1.equals(value))
              exists = true;
       }
      
      return exists;
  
public voidUndeploy(java.lang.String resName, java.lang.String resType, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String server = this.getName();
      try{
        Reporter.info("---------------------Before Undeploy "); // NOI18N
        class UndeployThread extends Thread{
            public void run () { 
                try{
                    if(resType.trim().indexOf(".ear") != -1){ // NOI18N
                        getSelectedInstance().undeployApplication(resName);
                    }else{
                        if(resType.trim().indexOf(".war") != -1){ // NOI18N
                            getSelectedInstance().undeployModule(resName, DeploymentConstants.WAR);
                        }else if(resType.trim().indexOf(".jar") != -1){ // NOI18N
                            getSelectedInstance().undeployModule(resName, DeploymentConstants.EJB);   
                        }else if(resType.trim().indexOf(".rar") != -1){ // NOI18N
                            getSelectedInstance().undeployModule(resName, DeploymentConstants.RAR);   
                        }
                    }//else
                    getSelectedInstance().applyChanges();
                    messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinUndeploy"), new Object[]  {server}) ); //NOI18N
                }catch(AFTargetNotFoundException te){
                    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
                    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
             }//run
        }
        UndeployThread undeploy = new UndeployThread();
        undeploy.start();
        Reporter.info("---------------------After Undeploy"); // NOI18N
        while(undeploy.isAlive()){
             Thread.sleep(500);
        }
        
        Reporter.info("---------------------Finished Undeploy"); // NOI18N
      }catch(Exception e){
             e.printStackTrace();
      } 
  
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)

        initPropertyChangeSupport();
           
        propertySupport.addPropertyChangeListener (listener);
    
public static com.sun.enterprise.admin.util.HostAndPortconfigurInstance(java.lang.String host_name, int port_no)

       HostAndPort hp = new HostAndPort(host_name, port_no);
       return hp;
    
public voidcreateResource(java.lang.String fname)

          getSelectedInstance().createResource(fname);
          getSelectedInstance().applyChanges();
          //Apply(); // this causes the IDE to hang
    
public voiddeleteJdbc(java.lang.String resourceName, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

    final String server = this.getName();
    try{
        Reporter.info("---------------------Before deleting Jdbc"); // NOI18N
        class deleteJdbcThread extends Thread{
            public void run () { 
                try{
                    getSelectedInstance().deleteJDBCResource(resourceName);
                }catch(DeploymentException de){  
		    messenger.setNotify(de.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFTargetNotFoundException te){
		    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
		    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
            }
        }//deleteJDBCThread
        deleteJdbcThread delJdbc = new deleteJdbcThread();
        delJdbc.start();
        Reporter.info("---------------------After deleting Registered Jdbc "); // NOI18N
        while(delJdbc.isAlive()){
           //wait
        }
        getSelectedInstance().applyChanges();
        Reporter.info("---------------------Finished deleting Registered Jdbc"); // NOI18N
    }catch(Exception e){
        e.printStackTrace();
    } 
  
public voiddeleteResource(java.lang.String resourceName, java.lang.String resType, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

    final String server = this.getName();
    try{
        Reporter.info("---------------------Before deleting resource"); // NOI18N
        class deleteResourceThread extends Thread{
            public void run () {
                try{
                    if (resType.equals("JDBC")) // NOI18N
                            getSelectedInstance().deleteJDBCResource(resourceName);
                    else if (resType.equals("CP")) // NOI18N
                            getSelectedInstance().deleteJDBCConnectionPool(resourceName);
                    else if (resType.equals("JMS")) // NOI18N
                            getSelectedInstance().deleteJMSResource(resourceName);
                    else if (resType.equals("PMF")) // NOI18N
                            getSelectedInstance().deletePersistenceManagerFactoryResource(resourceName);
                    else if (resType.equals("Mail")) // NOI18N
                            getSelectedInstance().deleteJavaMailResource(resourceName);
                    else
                            Reporter.error(bundle.getString("Err_NoResource"));
                }catch(DeploymentException de){
		     messenger.setNotify(de.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFTargetNotFoundException te){
		    messenger.setNotify(te.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFException afe){
		    messenger.setNotify(afe.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    messenger.ConfigXmlChanged(server);
                }
            }
        }//deleteResourceThread
        deleteResourceThread del = new deleteResourceThread();
        del.start();
        Reporter.info("---------------------After deleting registered resource"); // NOI18N
        while(del.isAlive()){
           //wait
        }
        getSelectedInstance().applyChanges();
        Reporter.info("---------------------Finished deleting Registered Resource"); // NOI18N
    }catch(Exception e){
        e.printStackTrace();
    }
  
public booleandeployEarFile(java.lang.String earPath, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String path = earPath;
      Reporter.info(earPath);
      Iterator it = null;
      InetAddress IP = null;
      boolean deploySuccess = true;
      try{  
        IP = InetAddress.getByName(this.getAdminHost());
        Socket s = new Socket (IP, this.getAdminPort());
        s.close ();  
        try{
            Reporter.info("Getting App Name");//NOI18N
            String appName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
            boolean exists = false;
            Reporter.info(appName);
            try{
                it = getSelectedInstance().getDeployedApplications();
            }catch( AFException e){
                throw new DeploymentException(e.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(AFRuntimeStoreException afre){
                throw new AFRuntimeStoreException(afre.getLocalizedMessage());
            }  
            messenger.setProgressMessage(bundle.getString("ExsistingAppCheck"));//NOI18N
            messenger.setProgressLevel(30);
            while (it.hasNext())
            {
                depName = it.next().toString();
               // System.out.println("Deployed App: " + depName);
                if(depName.equalsIgnoreCase(appName)){
                    exists = true;
                    break;
                }
            }
            Reporter.info(getSelectedInstance().getDeployedApplication(appName));
            if(exists){
                Reporter.info("Calling Redeploy");//NOI18N
                messenger.setProgressMessage( bundle.getString("RedeployMessage"));//NOI18N
                messenger.setProgressLevel(55);
                deploySuccess = getSelectedInstance().redeployApplication(path,appName);
            }else{
                Reporter.info("Calling Deploy");//NOI18N
                messenger.setProgressMessage( bundle.getString("DeployMessage"));//NOI18N
                messenger.setProgressLevel(55);
                deploySuccess = getSelectedInstance().deployApplication(path, appName, true, null, true, false, false);
            }
/*            
            
            try{
                it = getSelectedInstance().getDeployedApplications();
            }catch(AFException ex){
                throw new DeploymentException(ex.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(AFRuntimeStoreException afre){
                throw new AFRuntimeStoreException(afre.getLocalizedMessage());
            } 
 */
            messenger.setProgressLevel(90);
    /*ludo Why???        try{
                Thread.sleep(10000);// remove when status is available from som
            }catch (Exception e){
            }
     **/
            messenger.setProgressLevel(100);
        }catch(AFTargetNotFoundException te){
            throw new DeploymentException(te.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
        }catch(DeploymentException de){
            throw new DeploymentException(de.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
        }catch(AFRuntimeStoreException afre){
            messenger.ConfigXmlChanged(this.getName());
        } 
      }catch(java.net.UnknownHostException e){ 
           throw new DeploymentException(e.getLocalizedMessage());
      }catch(java.io.IOException con){
           throw new DeploymentException(con.getLocalizedMessage());
      } 
      return deploySuccess;
    
public booleandeployEjbJarFile(java.lang.String ejbJarName, java.lang.String ejbjarfilePath, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

        final String path = ejbjarfilePath;
        Iterator it = null;
        Reporter.info(ejbjarfilePath);
        InetAddress IP = null;
        boolean deploySuccess = true;
        try{  
            IP = InetAddress.getByName(this.getAdminHost());
            Socket s = new Socket (IP, this.getAdminPort());
            s.close (); 
            try{
                //String ejbJarName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
                Reporter.info("EjbJar Name" + ejbJarName);//NOI18N
                boolean exists = false;
                try{
                    it = getSelectedInstance().getDeployedEJBModules();
                }catch( AFException e){
                    throw new DeploymentException(e.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                   throw new AFRuntimeStoreException(afre.getLocalizedMessage());
                }  
                messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
                messenger.setProgressLevel(30);
                while (it.hasNext())
                {
                    depName = it.next().toString();
                  //  System.out.println("Deployed App: " + depName);
                    if(depName.equalsIgnoreCase(ejbJarName)){
                        exists = true;
                        break;
                    }
                }
                messenger.setProgressMessage( bundle.getString("DeployEjbJar"));//NOI18N
                if(exists){
                    Reporter.info("Calling Redeploy");//NOI18N
                    messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
                    messenger.setProgressLevel(55);
                    deploySuccess = getSelectedInstance().redeployEJBJarModule(path, ejbJarName);
                }else{
                    Reporter.info("Calling Deploy");//NOI18N
                    messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
                    messenger.setProgressLevel(55);
                    deploySuccess = getSelectedInstance().deployEJBJarModule(path, ejbJarName);
                }
                messenger.setProgressLevel(90);
 /*               try{
                    Thread.sleep(10000);// remove when status is available from som
                }catch (Exception e){
                    Reporter.verbose("Error while waiting for request to be completed");//NOI18N
                }*/
                messenger.setProgressLevel(100);
            }catch(AFTargetNotFoundException te){
                throw new DeploymentException(te.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(DeploymentException de){
                throw new DeploymentException(de.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(AFRuntimeStoreException afre){
                messenger.ConfigXmlChanged(this.getName());
            }
      }catch(java.net.UnknownHostException e){ 
           throw new DeploymentException(e.getLocalizedMessage());
      }catch(java.io.IOException con){
           throw new DeploymentException(con.getLocalizedMessage());
      }  
        return deploySuccess;
     
public booleandeployRARFile(java.lang.String rarfilePath, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

        final String path = rarfilePath;
        Iterator it = null;
        Reporter.info(rarfilePath);
        InetAddress IP = null;
        boolean deploySuccess = true;
        try{  
            IP = InetAddress.getByName(this.getAdminHost());
            Socket s = new Socket (IP, this.getAdminPort());
            s.close (); 
            try{
                String rarName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
                Reporter.info("rar Name" + rarName);//NOI18N
                boolean exists = false;
                try{
                    it = getSelectedInstance().getDeployedConnectors();
                }catch( AFException e){
                    throw new DeploymentException(e.getLocalizedMessage());
                    //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
                }catch(AFRuntimeStoreException afre){
                    throw new AFRuntimeStoreException(afre.getLocalizedMessage());
                }  
                if(messenger != null) messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
                if(messenger != null) messenger.setProgressLevel(30);
                while (it.hasNext())
                {
                    depName = it.next().toString();
 //                   System.out.println("Deployed App: " + depName);
                    if(depName.equalsIgnoreCase(rarName)){
                        exists = true;
                        break;
                    }
                }
                if(messenger != null) messenger.setProgressMessage( bundle.getString("DeployRar"));//NOI18N
                if(exists){
                    Reporter.info("Calling Redeploy");//NOI18N
                    if(messenger != null)  messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
                        deploySuccess = getSelectedInstance().redeployConnectorModule(path, rarName);
                }else{
                    Reporter.info("Calling Deploy");//NOI18N
                    if(messenger != null) messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
                        deploySuccess = getSelectedInstance().deployConnectorModule(path, rarName);
                }
                if(messenger != null) messenger.setProgressLevel(90);
             /*   try{
                    Thread.sleep(10000);// remove when status is available from som
                }catch (Exception e){
                    Reporter.verbose("Error while waiting for request to be completed");//NOI18N
                }*/
                if(messenger != null) messenger.setProgressLevel(100);
            }catch(AFTargetNotFoundException te){
                throw new DeploymentException(te.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(DeploymentException de){
                throw new DeploymentException(de.getLocalizedMessage());
                //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(AFRuntimeStoreException afre){
                messenger.ConfigXmlChanged(this.getName());
            }
      }catch(java.net.UnknownHostException e){ 
           throw new DeploymentException(e.getLocalizedMessage());
      }catch(java.io.IOException con){
           throw new DeploymentException(con.getLocalizedMessage());
      }  
        return deploySuccess;
     
public booleandeployWarFile(java.lang.String warPath, java.lang.String waName, java.lang.String contextRoot, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      final String path = warPath;
      Reporter.info("Context Root" + contextRoot + "War Path" + warPath);//NOI18N
      Iterator it = null;
      InetAddress IP = null;
      boolean deploySuccess = true;
      try{  
        IP = InetAddress.getByName(this.getAdminHost());
        Socket s = new Socket (IP, this.getAdminPort());
        s.close (); 
        try{
            String webAppName = waName; // path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));
            Reporter.info("webAppName is : " + webAppName);//NOI18N
            boolean exists = false;
            try{
                it = getSelectedInstance().getDeployedWebModules();
            }catch( AFException e){
               throw new DeploymentException(e.getLocalizedMessage());
               //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
            }catch(AFRuntimeStoreException afre){
                throw new AFRuntimeStoreException(afre.getLocalizedMessage());
            }  
            messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
            messenger.setProgressLevel(30);
            while (it.hasNext())
            {
                depName = it.next().toString();
                if(depName.equalsIgnoreCase(webAppName)){
                    exists = true;
                    break;
                }
            }
            messenger.setProgressMessage( bundle.getString("DeployWar"));//NOI18N
            if(exists){
                Reporter.info("Calling Redeploy");//NOI18N
                messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
                messenger.setProgressLevel(55);
                deploySuccess = getSelectedInstance().redeployWarModule(path, webAppName, contextRoot);
            }else{
                Reporter.info("Calling Deploy");//NOI18N
                messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
                messenger.setProgressLevel(55);
                deploySuccess = getSelectedInstance().deployWarModule(path, webAppName, contextRoot, true, null, true, false, false);
            }
            messenger.setProgressLevel(90);
 /*ludo why           try{
                Thread.sleep(10000);// remove when status is available from som
            }catch (Exception e){
                Reporter.verbose("Error while waiting for request to be completed");//NOI18N
            }*/
            messenger.setProgressLevel(100);
         }catch(AFTargetNotFoundException te){
            throw new DeploymentException(te.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
         }catch(DeploymentException de){
            throw new DeploymentException(de.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
         }catch(AFRuntimeStoreException afre){
                messenger.ConfigXmlChanged(this.getName());
         }
      }catch(java.net.UnknownHostException e){ 
           throw new DeploymentException(e.getLocalizedMessage());
      }catch(java.io.IOException con){
           throw new DeploymentException(con.getLocalizedMessage());
      } 
      return deploySuccess;
    
public java.lang.StringgetAdminHost()

        return ad_host;
    
public intgetAdminPort()

        return ad_port;
    
public java.lang.StringgetConnectorUrl()

  /*      Reporter.info("####### getting the URLConnection ####"); // NOI18N
        try{
            if(!getSelectedInstance().isRunning()){
                Reporter.info("####### SLEEPING FOR 10000 seconds ####"); // NOI18N
                Thread.sleep(10000);
            }
            Thread.sleep(10000); //isRunning return true before the server is fully initialize
        }catch(Exception e){
            e.printStackTrace();
        }
        Reporter.info("####### getting the URLConnection after sleep ####"); // NOI18N*/
        return "http://"+this.getName().substring(this.getName().indexOf("(")+1, this.getName().indexOf(":")+1)+
            getPort(); //NOI18N
    
public java.lang.StringgetDisplayName()

        return dispName;
    
public java.lang.StringgetHost()

        return host;
    
public intgetJPDAPortNumber()

        int p =   getSelectedInstance().getServerStatus().getDebugPort();
        Reporter.verbose("getJPDAPortNumber() returns " + p);  //NOI18N
        return p;
  
public java.lang.StringgetName()
Getter for property name.

return
Value of property name.

        return name;
    
public intgetORBPort()

        Integer portObj = (Integer) getSelectedInstance().getORBComponent().getIiopListener("orb-listener-1").getAttribute("port"); //NOI18N
        int port = portObj.intValue(); 
        Reporter.verbose("getORBPort() returns " + port);  //NOI18N
        return port;
  
public java.lang.StringgetPassword()
Getter for property password.

return
Value of property password.

        pw_editor = password;
        return password;
    
public intgetPort()
Getter for property port.

return
Value of property port.

        return port;
    
public java.lang.StringgetPrivatePassword()
invisible Getter for property password.

return
****

        String pw = getPassword();
        String passw = "";//NOI18N
        for(int i=0; i<pw.length(); i++)
            passw = passw + "*";//NOI18N
        return passw;
    
private synchronized com.sun.enterprise.admin.servermodel.AppServerInstancegetSelectedInstance()

      if(instance == null){
        Reporter.info("Initializing instance");//NOI18N
        String host = this.getName().substring(this.getName().indexOf("(")+1, this.getName().indexOf(":"));//NOI18N
        int port = Integer.parseInt( this.getName().substring(this.getName().indexOf(":")+1, this.getName().indexOf(")")) );//NOI18N
        HostAndPort hostPort = new HostAndPort(host, port);
        Reporter.info("getSelectedInstance " + this.getName().substring(0, this.getName().indexOf("(")));//NOI18N
        Reporter.info(hostPort);
            manager = ServerInstanceManagerFactory.getFactory().getServerInstanceManager(hostPort,userName,password);
            Reporter.assertIt(manager);
            instance = manager.getServerInstance(this.getName().substring(0, this.getName().indexOf("(")));//NOI18N
            Reporter.assertIt(instance);
        }
        return instance;
    
public java.lang.StringgetUserName()
Getter for property userName.

return
Value of property userName.

        return userName;
    
private voidinitEngine()

         //if (null == ec) {
         //       ec = new EngineController(getHost(),Integer.toString(getPort()),getUserName(),
         //                                  getPassword(),KSRPCPacket.GXADMIN_ENGTYPE_KJS);

         //}  // ec is not null     
    
private voidinitPropertyChangeSupport()

         if(propertySupport==null)
         propertySupport = new PropertyChangeSupport ( this );

    
public booleanisEnabled(java.lang.String resName, java.lang.String resType, com.sun.enterprise.tools.common.ui.UIMessenger messenger)

        final String server = this.getName();
        Reporter.info("---------------------Before checking if resource is enabled"); // NOI18N
        try{
            if(resType.trim().indexOf(".ear") != -1){ // NOI18N
               DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
               isEnabled = component.isEnabled();
            }else{
               if(resType.trim().indexOf(".war") != -1){ // NOI18N
                  DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);
                  isEnabled = component.isEnabled();
               }else if(resType.trim().indexOf(".jar") != -1){ // NOI18N
                  DeployedEJBModuleComponentBean  component = getSelectedInstance().getDeployedEJBModule(resName);
                  isEnabled = component.isEnabled();
               }
            }//else
            //messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_Applyed"), new Object[]  {server}) );
        }catch(AFTargetNotFoundException te){
            messenger.setNotify(te.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
        }catch(AFException afe){
            messenger.setNotify(afe.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
        }catch(AFRuntimeStoreException afre){
            //messenger.ConfigXmlChanged(server);
        }
        
        Reporter.info("---------------------Finished checking if resource is enabled"); // NOI18N
        return isEnabled;
  
public booleanisLocal()

         try{
            String host=InetAddress.getLocalHost().getHostName();
            return host.equals (getHost());
        }
        catch(java.net.UnknownHostException e){
            throw new DeploymentException(e.getLocalizedMessage());
            //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
        }
    
public booleanisRunning()

        instRunning = false;
        instRunning = getSelectedInstance().isRunning();
        return instRunning;
    
public booleanisUp()

            if (checkAlreadyDone==true)
                  return IAS_Running;
            //IAS_Running = ServerAccess.isKASAlive(getPort(), 1);
            checkAlreadyDone = true;
            Timer aTimer = new Timer();
            TimerTask task = new TimerTask(){
                public void run() {
                            synchronized (this) {
                                checkAlreadyDone = false;
                            }
                }

            };
            aTimer.schedule(task,2000);
            return IAS_Running;

            
        
public voidregisterDatasource(java.lang.String xmlFile)

       //IASDeployer iasDeployer = new IASDeployer();
      //iasDeployer.registerDatasource(this, xmlFile);
     
public voidremoveEngineController()

    
        //if (null != ec) {
        //     ec.disconnect();
        //     ec =null;
        // }
    
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)

        initPropertyChangeSupport();
        propertySupport.removePropertyChangeListener (listener);
    
public voidrestart()

        try{
            Reporter.info("---------------------RESTART"); // NOI18N
            class RestartThread extends Thread{
            public void run () {  
                try{
                    getSelectedInstance().restart();
                    Reporter.info("---------------------AFTER RESTART-------------"); // NOI18N
                }catch(AFTargetNotFoundException te){
                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
                    te.printStackTrace();
                }catch(DeploymentException de){
                    //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
                    de.printStackTrace();
                }catch(ControlException ce){
                    //JOptionPane.showMessageDialog(null, ce.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
                    ce.printStackTrace();
                }catch(AFException afe){
                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
                    afe.printStackTrace();
                }
             }
            }
            RestartThread restart = new RestartThread();
            restart.start();
            //Thread.sleep(5000);
            //while(restart.isAlive()){
                //wait
            //}
            Reporter.info("---------------------Ready after restart"); // NOI18N
        }catch(Exception e){
             e.printStackTrace();
        } 
    
    
public voidsetAdminHost(java.lang.String value)

        String oldValue = ad_host;
        ad_host = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("ad_host", oldValue, ad_host);//NOI18N
    
public voidsetAdminPort(int value)

        int oldValue = ad_port;
        ad_port = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("ad_port", oldValue, ad_port);//NOI18N
    
public voidsetDisplayName(java.lang.String value)
Setter for property name.

param
name New value of property name.

        String oldValue = dispName;
        dispName = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("displayname", oldValue, dispName);//NOI18N
       //ServerInstanceManager.getInstance().getServerInstance(name); needs to be setServerInstanceName()
    
public voidsetHost(java.lang.String value)

        String oldValue = host;
        host = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("host", oldValue, host);//NOI18N
    
public voidsetName(java.lang.String value)
Setter for property name.

param
name New value of property name.

        String oldValue = name;
        name = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("name", oldValue, name);//NOI18N
       //ServerInstanceManager.getInstance().getServerInstance(name); needs to be setServerInstanceName()
    
public voidsetPassword(java.lang.String value)
Setter for property password.

param
password New value of property password.

        String oldValue = host;
        password = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("password", oldValue, password);//NOI18N
    
public voidsetPort(int value)
Setter for property port.

param
port New value of property port.

        Reporter.info("Setting Server Port to " + value);//NOI18N
        String oldValue = host;
        port = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("port", null, null);//NOI18N
    
public voidsetUserName(java.lang.String value)
Setter for property userName.

param
userName New value of property userName.

        String oldValue = host;
        userName = value;
        initPropertyChangeSupport();
        propertySupport.firePropertyChange ("userName", oldValue, userName);//NOI18N
    
public intstartInDebugMode(com.sun.enterprise.tools.common.ui.UIMessenger messenger)

      debugPort = -1;
      try{
          Reporter.info("---------------------STARTANYKJS"); // NOI18N
          class StartDebugThread extends Thread{
              public void run() {
                  try{
                      if(!getSelectedInstance().isRunning()){
                          
                          debugPort = getSelectedInstance().startInDebugMode();
                      }
                      Reporter.info("---------------------AFTER START-------------"); // NOI18N
                  }catch(AFTargetNotFoundException te){
                       messenger.setNotify(te.getLocalizedMessage());
                  }catch(DeploymentException de){
                       messenger.setNotify(de.getLocalizedMessage());
                  }catch(InstanceAlreadyRunningException iare){
                       messenger.setNotify(iare.getLocalizedMessage());
                  }catch(ControlException ce){
                       messenger.setNotify(ce.getLocalizedMessage());
                  }catch(AFException afe){
                      messenger.setNotify(afe.getLocalizedMessage());
                  }
              }
          }
          
          StartDebugThread debug_server = new StartDebugThread();
          debug_server.start();
          Thread.sleep(500);
          
          while(debug_server.isAlive()){
              Thread.sleep(1000);
          }
          Reporter.info("---------------------Ready after start"); // NOI18N
      }catch(Exception e){
          e.printStackTrace();
      }
      return debugPort;
  
public intstartInDebugMode()

      debugPort = -1;
      Reporter.info("---------------------STARTANYKJS"); // NOI18N
      if(!getSelectedInstance().isRunning()){
          debugPort = getSelectedInstance().startInDebugMode();
      }
      Reporter.info("---------------------AFTER START-------------"); // NOI18N
      return debugPort;
  
public voidstartInstance(com.sun.enterprise.tools.common.ui.UIMessenger messenger)

        try{
            Reporter.info("---------------------STARTANYKJS"); // NOI18N
            class StartThread extends Thread{
            public void run () {  
                try{
                    if(!getSelectedInstance().isRunning()){
                            getSelectedInstance().start();
                    }
                    Reporter.info("---------------------AFTER START-------------"); // NOI18N
                }catch(AFTargetNotFoundException te){
                    messenger.setNotify(te.getLocalizedMessage());
                }catch(DeploymentException de){
                    messenger.setNotify(de.getLocalizedMessage());
                }catch(InstanceAlreadyRunningException iare){
                    messenger.setNotify(iare.getLocalizedMessage());
                }catch(ControlException ce){
                    messenger.setNotify(ce.getLocalizedMessage());
                }catch(AFException afe){
                   messenger.setNotify(afe.getLocalizedMessage());
                }
             }
            }
            
            StartThread start_server = new StartThread();
            start_server.start();
           // Thread.sleep(500);
            while(start_server.isAlive()){
                Thread.sleep(1000);
            }
            Reporter.info("---------------------Ready after start"); // NOI18N
        }catch(Exception e){
             e.printStackTrace();
        } 
    
    
public booleanstartInstance()

        Reporter.info("---------------------STARTANYKJS"); // NOI18N
        boolean status = false;
        if(!getSelectedInstance().isRunning()){
            status = getSelectedInstance().start();
        }
        Reporter.info("---------------------AFTER START-------------"); // NOI18N
        return status;
        //    messenger.setErrorMsg(bundle.getString ("Err_NoTarget"), bundle.getString ("Err_StartServer"));* //NOI18N
    
public voidstopInstance(com.sun.enterprise.tools.common.ui.UIMessenger messenger)

        try{
            Reporter.info("---------------------stopInstance"); // NOI18N
            class StopThread extends Thread{
            public void run () {  
                try{
                    if(getSelectedInstance().isRunning()){
                            getSelectedInstance().stop();
                    }
                    Reporter.info("---------------------AFTER STOP-------------"); // NOI18N
                }catch(AFTargetNotFoundException te){
                    messenger.setNotify(te.getLocalizedMessage());
                }catch(DeploymentException de){
                    messenger.setNotify(de.getLocalizedMessage());
                }catch(InstanceNotRunningException inre){
                    messenger.setNotify(inre.getLocalizedMessage());
                }catch(ControlException ce){
                   messenger.setNotify(ce.getLocalizedMessage());
                }catch(AFException afe){
                    messenger.setNotify(afe.getLocalizedMessage());
                }
                
             }
            }
            StopThread stop_server = new StopThread();
            stop_server.start();
            Thread.sleep(500);
            while(stop_server.isAlive()){
              Thread.sleep(1000);
            }
            Reporter.info("---------------------After stop server"); // NOI18N
        }catch(Exception e){
             e.printStackTrace();
        } 
    
public booleanstopInstance()

        Reporter.info("---------------------STARTANYKJS"); // NOI18N
        boolean status = false;
        if(getSelectedInstance().isRunning())
             status = getSelectedInstance().stop();
        Reporter.info("---------------------AFTER START-------------"); // NOI18N
        return status;
    
public voiduseManualConfig()

      getSelectedInstance().useManualChanges();