KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > deploy > ServerInstance


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.common.deploy;
25
26 /*
27  * ServerInstance.java
28  *
29  * Created on December 12, 2000, 12:15 PM
30  */

31
32 import java.beans.*;
33 import java.util.*;
34 import java.io.File JavaDoc;
35 import javax.swing.JOptionPane JavaDoc;
36 import java.net.InetAddress JavaDoc;
37 import java.net.Socket JavaDoc;
38 import com.sun.enterprise.tools.common.LoginFailureException;
39 import com.sun.enterprise.tools.common.ui.UIMessenger;
40
41 import com.sun.enterprise.admin.servermodel.beans.*;
42 import com.sun.enterprise.admin.servermodel.ServerInstanceManager;
43 import com.sun.enterprise.admin.servermodel.ServerInstanceManagerFactory;
44 import com.sun.enterprise.admin.servermodel.AppServerInstance;
45 import com.sun.enterprise.admin.common.constant.DeploymentConstants;
46 import com.sun.enterprise.admin.common.constant.ConfigAttributeName;
47 import com.sun.enterprise.admin.common.exception.*;
48 import com.sun.enterprise.admin.util.HostAndPort;
49 import com.sun.enterprise.tools.common.util.diagnostics.Reporter;
50 import com.sun.enterprise.tools.common.deploy.NameValuePair;
51
52 /**
53  *
54  * @author administrator
55  * @version
56  */

57 public class ServerInstance extends Object JavaDoc implements java.io.Serializable JavaDoc {
58
59     
60     private String JavaDoc host;
61     private String JavaDoc ad_host;
62     transient private PropertyChangeSupport propertySupport;
63
64     /** Holds value of property name. */
65     private String JavaDoc name;
66     
67     private String JavaDoc dispName;
68     
69     /** Holds value of property password. */
70     private String JavaDoc password;
71     
72     /** Holds value of property port. */
73     private int port;
74     private int ad_port;
75     /** Holds value of property userName. */
76     private String JavaDoc userName;
77     
78     public static String JavaDoc pw_editor;
79     
80     transient boolean checkAlreadyDone = false;
81     transient boolean IAS_Running ;
82     transient boolean checkDone = false;
83     transient boolean KJS_Running ;
84     transient boolean instRunning;
85     transient boolean isEnabled;
86     
87     transient private ServerInstanceManager manager;
88     transient private AppServerInstance instance;
89     
90     String JavaDoc depName = null;
91     
92     static final ResourceBundle bundle = ResourceBundle.getBundle("com.sun.enterprise.tools.common.deploy.Bundle"); // NOI18N
93

94     /** Creates new ServerInstance */
95     public ServerInstance(String JavaDoc SOM_name, String JavaDoc serv_name, int serv_port, String JavaDoc username, String JavaDoc passwd) {
96         propertySupport = new PropertyChangeSupport ( this );
97         userName = username;
98         password = passwd;
99         dispName = SOM_name;
100         name = serv_name;
101         port = serv_port;
102         ad_host = serv_name.substring(serv_name.indexOf("(")+1, serv_name.indexOf(":"));//NOI18N
103
ad_port = Integer.parseInt( serv_name.substring(serv_name.indexOf(":")+1, serv_name.indexOf(")")) );//NOI18N
104
}
105     
106     public ServerInstance(String JavaDoc SOM_name, String JavaDoc serv_name, int serv_port) {
107         this(SOM_name,serv_name,serv_port,"admin","admin123");//NOI18N
108
}
109     
110     public ServerInstance(String JavaDoc SOM_name, String JavaDoc serv_name) {
111         this(SOM_name,serv_name,-1);
112     }
113     
114     public static HostAndPort configurInstance(String JavaDoc host_name, int port_no){
115        HostAndPort hp = new HostAndPort(host_name, port_no);
116        return hp;
117     }
118       
119     public String JavaDoc getHost() {
120         return host;
121     }
122
123     public void setHost(String JavaDoc value) {
124         String JavaDoc oldValue = host;
125         host = value;
126         initPropertyChangeSupport();
127         propertySupport.firePropertyChange ("host", oldValue, host);//NOI18N
128
}
129
130     private void initPropertyChangeSupport(){
131          if(propertySupport==null)
132          propertySupport = new PropertyChangeSupport ( this );
133
134     }
135     public void addPropertyChangeListener (PropertyChangeListener listener) {
136         initPropertyChangeSupport();
137            
138         propertySupport.addPropertyChangeListener (listener);
139     }
140
141     public void removePropertyChangeListener (PropertyChangeListener listener) {
142         initPropertyChangeSupport();
143         propertySupport.removePropertyChangeListener (listener);
144     }
145
146     /** Getter for property name.
147      * @return Value of property name.
148  */

149     public String JavaDoc getName() {
150         return name;
151     }
152     
153     /** Setter for property name.
154      * @param name New value of property name.
155  */

156     public void setName(String JavaDoc value) {
157         String JavaDoc oldValue = name;
158         name = value;
159         initPropertyChangeSupport();
160         propertySupport.firePropertyChange ("name", oldValue, name);//NOI18N
161
//ServerInstanceManager.getInstance().getServerInstance(name); needs to be setServerInstanceName()
162
}
163     
164     public String JavaDoc getDisplayName() {
165         return dispName;
166     }
167     
168     /** Setter for property name.
169      * @param name New value of property name.
170  */

171     public void setDisplayName(String JavaDoc value) {
172         String JavaDoc oldValue = dispName;
173         dispName = value;
174         initPropertyChangeSupport();
175         propertySupport.firePropertyChange ("displayname", oldValue, dispName);//NOI18N
176
//ServerInstanceManager.getInstance().getServerInstance(name); needs to be setServerInstanceName()
177
}
178     
179     /** invisible Getter for property password.
180      * @return ****
181  */

182     public String JavaDoc getPrivatePassword() {
183         String JavaDoc pw = getPassword();
184         String JavaDoc passw = "";//NOI18N
185
for(int i=0; i<pw.length(); i++)
186             passw = passw + "*";//NOI18N
187
return passw;
188     }
189     /** Getter for property password.
190      * @return Value of property password.
191  */

192     public String JavaDoc getPassword() {
193         pw_editor = password;
194         return password;
195     }
196     
197     /** Setter for property password.
198      * @param password New value of property password.
199  */

200     public void setPassword(String JavaDoc value) {
201         String JavaDoc oldValue = host;
202         password = value;
203         initPropertyChangeSupport();
204         propertySupport.firePropertyChange ("password", oldValue, password);//NOI18N
205
}
206     
207     /** Getter for property port.
208      * @return Value of property port.
209  */

210     public int getPort() {
211         return port;
212     }
213     
214     /** Setter for property port.
215      * @param port New value of property port.
216  */

217     public void setPort(int value) {
218         Reporter.info("Setting Server Port to " + value);//NOI18N
219
String JavaDoc oldValue = host;
220         port = value;
221         initPropertyChangeSupport();
222         propertySupport.firePropertyChange ("port", null, null);//NOI18N
223
}
224     
225     /** Getter for property userName.
226      * @return Value of property userName.
227  */

228     public String JavaDoc getUserName() {
229         return userName;
230     }
231     
232     /** Setter for property userName.
233      * @param userName New value of property userName.
234  */

235     public void setUserName(String JavaDoc value) {
236         String JavaDoc oldValue = host;
237         userName = value;
238         initPropertyChangeSupport();
239         propertySupport.firePropertyChange ("userName", oldValue, userName);//NOI18N
240
}
241     
242     public String JavaDoc getAdminHost() {
243         return ad_host;
244     }
245
246     public void setAdminHost(String JavaDoc value) {
247         String JavaDoc oldValue = ad_host;
248         ad_host = value;
249         initPropertyChangeSupport();
250         propertySupport.firePropertyChange ("ad_host", oldValue, ad_host);//NOI18N
251
}
252     
253     public int getAdminPort() {
254         return ad_port;
255     }
256
257     public void setAdminPort(int value) {
258         int oldValue = ad_port;
259         ad_port = value;
260         initPropertyChangeSupport();
261         propertySupport.firePropertyChange ("ad_port", oldValue, ad_port);//NOI18N
262
}
263     
264     public String JavaDoc getConnectorUrl(){
265   /* Reporter.info("####### getting the URLConnection ####"); // NOI18N
266         try{
267             if(!getSelectedInstance().isRunning()){
268                 Reporter.info("####### SLEEPING FOR 10000 seconds ####"); // NOI18N
269                 Thread.sleep(10000);
270             }
271             Thread.sleep(10000); //isRunning return true before the server is fully initialize
272         }catch(Exception e){
273             e.printStackTrace();
274         }
275         Reporter.info("####### getting the URLConnection after sleep ####"); // NOI18N*/

276         return "http://"+this.getName().substring(this.getName().indexOf("(")+1, this.getName().indexOf(":")+1)+
277             getPort(); //NOI18N
278
}
279     
280     private synchronized AppServerInstance getSelectedInstance() throws DeploymentException,AFTargetNotFoundException {
281       if(instance == null){
282         Reporter.info("Initializing instance");//NOI18N
283
String JavaDoc host = this.getName().substring(this.getName().indexOf("(")+1, this.getName().indexOf(":"));//NOI18N
284
int port = Integer.parseInt( this.getName().substring(this.getName().indexOf(":")+1, this.getName().indexOf(")")) );//NOI18N
285
HostAndPort hostPort = new HostAndPort(host, port);
286         Reporter.info("getSelectedInstance " + this.getName().substring(0, this.getName().indexOf("(")));//NOI18N
287
Reporter.info(hostPort);
288             manager = ServerInstanceManagerFactory.getFactory().getServerInstanceManager(hostPort,userName,password);
289             Reporter.assertIt(manager);
290             instance = manager.getServerInstance(this.getName().substring(0, this.getName().indexOf("(")));//NOI18N
291
Reporter.assertIt(instance);
292         }
293         return instance;
294     }
295     
296     public void createResource(String JavaDoc fname) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
297           getSelectedInstance().createResource(fname);
298           getSelectedInstance().applyChanges();
299           //Apply(); // this causes the IDE to hang
300
}
301     
302 /*
303     public void createJDBCResource(String fname, String jndiName, NameValuePair[] params) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
304           AppServerInstance inst = getSelectedInstance();
305           inst.createResource(fname);
306           JDBCResource regres = inst.getJDBCResource(jndiName);
307
308           if (params != null && params.length > 0) {
309                 for (int i = 0; i < params.length; i++) {
310                     regres.setAttribute(
311                          ConfigAttributeName.PROPERTY_NAME_PREFIX + params[i].getParamName(),
312                          params[i].getParamValue());
313                 }
314           }
315           inst.applyChanges();
316           //Apply(); // this causes the IDE to hang
317     }
318         
319     public void createJDBCConnectionPool(String fname, String jndiName, NameValuePair[] params) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
320           AppServerInstance inst = getSelectedInstance();
321           inst.createResource(fname);
322           JDBCConnectionPool regres = inst.getJDBCConnectionPool(jndiName);
323
324           if (params != null && params.length > 0) {
325                 for (int i = 0; i < params.length; i++) {
326                     regres.setAttribute(
327                          ConfigAttributeName.PROPERTY_NAME_PREFIX + params[i].getParamName(),
328                          params[i].getParamValue());
329                 }
330           }
331           inst.applyChanges();
332           //Apply(); // this causes the IDE to hang
333     }
334     
335     public void createJMSResource(String fname, String jndiName, NameValuePair[] params) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
336           AppServerInstance inst = getSelectedInstance();
337           inst.createResource(fname);
338           JMSResource regres = inst.getJMSResource(jndiName);
339
340           if (params != null && params.length > 0) {
341                 for (int i = 0; i < params.length; i++) {
342                     regres.setAttribute(
343                          ConfigAttributeName.PROPERTY_NAME_PREFIX + params[i].getParamName(),
344                          params[i].getParamValue());
345                 }
346           }
347           inst.applyChanges();
348           //Apply(); // this causes the IDE to hang
349     }
350     
351     public void createPMFResource(String fname, String jndiName, NameValuePair[] params) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
352           AppServerInstance inst = getSelectedInstance();
353           inst.createResource(fname);
354           PersistenceManagerFactoryResource regres = inst.getPersistenceManagerFactoryResource(jndiName);
355
356           if (params != null && params.length > 0) {
357                 for (int i = 0; i < params.length; i++) {
358                     regres.setAttribute(
359                          ConfigAttributeName.PROPERTY_NAME_PREFIX + params[i].getParamName(),
360                          params[i].getParamValue());
361                 }
362           }
363           inst.applyChanges();
364           //Apply(); // this causes the IDE to hang
365     }
366     
367     public void createMailResource(String fname, String jndiName, NameValuePair[] params) throws AFException,AFResourceException,AFTargetNotFoundException, DeploymentException{
368           AppServerInstance inst = getSelectedInstance();
369           inst.createResource(fname);
370           JavaMailResource regres = inst.getJavaMailResource(jndiName);
371
372           if (params != null && params.length > 0) {
373                 for (int i = 0; i < params.length; i++) {
374                     regres.setAttribute(
375                          ConfigAttributeName.PROPERTY_NAME_PREFIX + params[i].getParamName(),
376                          params[i].getParamValue());
377                 }
378           }
379           inst.applyChanges();
380           //Apply(); // this causes the IDE to hang
381     }
382 */

383     
384     public boolean deployEarFile( String JavaDoc earPath, UIMessenger messenger) throws DeploymentException {
385       final String JavaDoc path = earPath;
386       Reporter.info(earPath);
387       Iterator it = null;
388       InetAddress JavaDoc IP = null;
389       boolean deploySuccess = true;
390       try{
391         IP = InetAddress.getByName(this.getAdminHost());
392         Socket JavaDoc s = new Socket JavaDoc (IP, this.getAdminPort());
393         s.close ();
394         try{
395             Reporter.info("Getting App Name");//NOI18N
396
String JavaDoc appName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
397
boolean exists = false;
398             Reporter.info(appName);
399             try{
400                 it = getSelectedInstance().getDeployedApplications();
401             }catch( AFException e){
402                 throw new DeploymentException(e.getLocalizedMessage());
403                 //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
404
}catch(AFRuntimeStoreException afre){
405                 throw new AFRuntimeStoreException(afre.getLocalizedMessage());
406             }
407             messenger.setProgressMessage(bundle.getString("ExsistingAppCheck"));//NOI18N
408
messenger.setProgressLevel(30);
409             while (it.hasNext())
410             {
411                 depName = it.next().toString();
412                // System.out.println("Deployed App: " + depName);
413
if(depName.equalsIgnoreCase(appName)){
414                     exists = true;
415                     break;
416                 }
417             }
418             Reporter.info(getSelectedInstance().getDeployedApplication(appName));
419             if(exists){
420                 Reporter.info("Calling Redeploy");//NOI18N
421
messenger.setProgressMessage( bundle.getString("RedeployMessage"));//NOI18N
422
messenger.setProgressLevel(55);
423                 deploySuccess = getSelectedInstance().redeployApplication(path,appName);
424             }else{
425                 Reporter.info("Calling Deploy");//NOI18N
426
messenger.setProgressMessage( bundle.getString("DeployMessage"));//NOI18N
427
messenger.setProgressLevel(55);
428                 deploySuccess = getSelectedInstance().deployApplication(path, appName, true, null, true, false, false);
429             }
430 /*
431             
432             try{
433                 it = getSelectedInstance().getDeployedApplications();
434             }catch(AFException ex){
435                 throw new DeploymentException(ex.getLocalizedMessage());
436                 //JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
437             }catch(AFRuntimeStoreException afre){
438                 throw new AFRuntimeStoreException(afre.getLocalizedMessage());
439             }
440  */

441             messenger.setProgressLevel(90);
442     /*ludo Why??? try{
443                 Thread.sleep(10000);// remove when status is available from som
444             }catch (Exception e){
445             }
446      **/

447             messenger.setProgressLevel(100);
448         }catch(AFTargetNotFoundException te){
449             throw new DeploymentException(te.getLocalizedMessage());
450             //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
451
}catch(DeploymentException de){
452             throw new DeploymentException(de.getLocalizedMessage());
453             //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
454
}catch(AFRuntimeStoreException afre){
455             messenger.ConfigXmlChanged(this.getName());
456         }
457       }catch(java.net.UnknownHostException JavaDoc e){
458            throw new DeploymentException(e.getLocalizedMessage());
459       }catch(java.io.IOException JavaDoc con){
460            throw new DeploymentException(con.getLocalizedMessage());
461       }
462       return deploySuccess;
463     }
464         
465     public boolean deployWarFile(String JavaDoc warPath, String JavaDoc waName, String JavaDoc contextRoot, UIMessenger messenger) throws DeploymentException {
466       final String JavaDoc path = warPath;
467       Reporter.info("Context Root" + contextRoot + "War Path" + warPath);//NOI18N
468
Iterator it = null;
469       InetAddress JavaDoc IP = null;
470       boolean deploySuccess = true;
471       try{
472         IP = InetAddress.getByName(this.getAdminHost());
473         Socket JavaDoc s = new Socket JavaDoc (IP, this.getAdminPort());
474         s.close ();
475         try{
476             String JavaDoc webAppName = waName; // path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));
477
Reporter.info("webAppName is : " + webAppName);//NOI18N
478
boolean exists = false;
479             try{
480                 it = getSelectedInstance().getDeployedWebModules();
481             }catch( AFException e){
482                throw new DeploymentException(e.getLocalizedMessage());
483                //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
484
}catch(AFRuntimeStoreException afre){
485                 throw new AFRuntimeStoreException(afre.getLocalizedMessage());
486             }
487             messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
488
messenger.setProgressLevel(30);
489             while (it.hasNext())
490             {
491                 depName = it.next().toString();
492                 if(depName.equalsIgnoreCase(webAppName)){
493                     exists = true;
494                     break;
495                 }
496             }
497             messenger.setProgressMessage( bundle.getString("DeployWar"));//NOI18N
498
if(exists){
499                 Reporter.info("Calling Redeploy");//NOI18N
500
messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
501
messenger.setProgressLevel(55);
502                 deploySuccess = getSelectedInstance().redeployWarModule(path, webAppName, contextRoot);
503             }else{
504                 Reporter.info("Calling Deploy");//NOI18N
505
messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
506
messenger.setProgressLevel(55);
507                 deploySuccess = getSelectedInstance().deployWarModule(path, webAppName, contextRoot, true, null, true, false, false);
508             }
509             messenger.setProgressLevel(90);
510  /*ludo why try{
511                 Thread.sleep(10000);// remove when status is available from som
512             }catch (Exception e){
513                 Reporter.verbose("Error while waiting for request to be completed");//NOI18N
514             }*/

515             messenger.setProgressLevel(100);
516          }catch(AFTargetNotFoundException te){
517             throw new DeploymentException(te.getLocalizedMessage());
518             //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
519
}catch(DeploymentException de){
520             throw new DeploymentException(de.getLocalizedMessage());
521             //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
522
}catch(AFRuntimeStoreException afre){
523                 messenger.ConfigXmlChanged(this.getName());
524          }
525       }catch(java.net.UnknownHostException JavaDoc e){
526            throw new DeploymentException(e.getLocalizedMessage());
527       }catch(java.io.IOException JavaDoc con){
528            throw new DeploymentException(con.getLocalizedMessage());
529       }
530       return deploySuccess;
531     }
532
533     public boolean deployEjbJarFile(String JavaDoc ejbJarName, String JavaDoc ejbjarfilePath, UIMessenger messenger) throws DeploymentException {
534         final String JavaDoc path = ejbjarfilePath;
535         Iterator it = null;
536         Reporter.info(ejbjarfilePath);
537         InetAddress JavaDoc IP = null;
538         boolean deploySuccess = true;
539         try{
540             IP = InetAddress.getByName(this.getAdminHost());
541             Socket JavaDoc s = new Socket JavaDoc (IP, this.getAdminPort());
542             s.close ();
543             try{
544                 //String ejbJarName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
545
Reporter.info("EjbJar Name" + ejbJarName);//NOI18N
546
boolean exists = false;
547                 try{
548                     it = getSelectedInstance().getDeployedEJBModules();
549                 }catch( AFException e){
550                     throw new DeploymentException(e.getLocalizedMessage());
551                     //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
552
}catch(AFRuntimeStoreException afre){
553                    throw new AFRuntimeStoreException(afre.getLocalizedMessage());
554                 }
555                 messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
556
messenger.setProgressLevel(30);
557                 while (it.hasNext())
558                 {
559                     depName = it.next().toString();
560                   // System.out.println("Deployed App: " + depName);
561
if(depName.equalsIgnoreCase(ejbJarName)){
562                         exists = true;
563                         break;
564                     }
565                 }
566                 messenger.setProgressMessage( bundle.getString("DeployEjbJar"));//NOI18N
567
if(exists){
568                     Reporter.info("Calling Redeploy");//NOI18N
569
messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
570
messenger.setProgressLevel(55);
571                     deploySuccess = getSelectedInstance().redeployEJBJarModule(path, ejbJarName);
572                 }else{
573                     Reporter.info("Calling Deploy");//NOI18N
574
messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
575
messenger.setProgressLevel(55);
576                     deploySuccess = getSelectedInstance().deployEJBJarModule(path, ejbJarName);
577                 }
578                 messenger.setProgressLevel(90);
579  /* try{
580                     Thread.sleep(10000);// remove when status is available from som
581                 }catch (Exception e){
582                     Reporter.verbose("Error while waiting for request to be completed");//NOI18N
583                 }*/

584                 messenger.setProgressLevel(100);
585             }catch(AFTargetNotFoundException te){
586                 throw new DeploymentException(te.getLocalizedMessage());
587                 //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
588
}catch(DeploymentException de){
589                 throw new DeploymentException(de.getLocalizedMessage());
590                 //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
591
}catch(AFRuntimeStoreException afre){
592                 messenger.ConfigXmlChanged(this.getName());
593             }
594       }catch(java.net.UnknownHostException JavaDoc e){
595            throw new DeploymentException(e.getLocalizedMessage());
596       }catch(java.io.IOException JavaDoc con){
597            throw new DeploymentException(con.getLocalizedMessage());
598       }
599         return deploySuccess;
600      }
601
602     
603     
604     /*added by ludo: ability to deploy standalone RAR files...
605      **/

606         public boolean deployRARFile(String JavaDoc rarfilePath, UIMessenger messenger) throws DeploymentException {
607         final String JavaDoc path = rarfilePath;
608         Iterator it = null;
609         Reporter.info(rarfilePath);
610         InetAddress JavaDoc IP = null;
611         boolean deploySuccess = true;
612         try{
613             IP = InetAddress.getByName(this.getAdminHost());
614             Socket JavaDoc s = new Socket JavaDoc (IP, this.getAdminPort());
615             s.close ();
616             try{
617                 String JavaDoc rarName = path.substring(path.lastIndexOf(File.separator)+1, path.lastIndexOf("."));//NOI18N
618
Reporter.info("rar Name" + rarName);//NOI18N
619
boolean exists = false;
620                 try{
621                     it = getSelectedInstance().getDeployedConnectors();
622                 }catch( AFException e){
623                     throw new DeploymentException(e.getLocalizedMessage());
624                     //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
625
}catch(AFRuntimeStoreException afre){
626                     throw new AFRuntimeStoreException(afre.getLocalizedMessage());
627                 }
628                 if(messenger != null) messenger.setProgressMessage( bundle.getString("ExsistingModuleCheck"));//NOI18N
629
if(messenger != null) messenger.setProgressLevel(30);
630                 while (it.hasNext())
631                 {
632                     depName = it.next().toString();
633  // System.out.println("Deployed App: " + depName);
634
if(depName.equalsIgnoreCase(rarName)){
635                         exists = true;
636                         break;
637                     }
638                 }
639                 if(messenger != null) messenger.setProgressMessage( bundle.getString("DeployRar"));//NOI18N
640
if(exists){
641                     Reporter.info("Calling Redeploy");//NOI18N
642
if(messenger != null) messenger.setProgressMessage( bundle.getString("RedeployModuleMessage")); //NOI18N
643
deploySuccess = getSelectedInstance().redeployConnectorModule(path, rarName);
644                 }else{
645                     Reporter.info("Calling Deploy");//NOI18N
646
if(messenger != null) messenger.setProgressMessage( bundle.getString("DeployModuleMessage")); //NOI18N
647
deploySuccess = getSelectedInstance().deployConnectorModule(path, rarName);
648                 }
649                 if(messenger != null) messenger.setProgressLevel(90);
650              /* try{
651                     Thread.sleep(10000);// remove when status is available from som
652                 }catch (Exception e){
653                     Reporter.verbose("Error while waiting for request to be completed");//NOI18N
654                 }*/

655                 if(messenger != null) messenger.setProgressLevel(100);
656             }catch(AFTargetNotFoundException te){
657                 throw new DeploymentException(te.getLocalizedMessage());
658                 //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
659
}catch(DeploymentException de){
660                 throw new DeploymentException(de.getLocalizedMessage());
661                 //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("ErrorDeploying"), JOptionPane.ERROR_MESSAGE);//NOI18N
662
}catch(AFRuntimeStoreException afre){
663                 messenger.ConfigXmlChanged(this.getName());
664             }
665       }catch(java.net.UnknownHostException JavaDoc e){
666            throw new DeploymentException(e.getLocalizedMessage());
667       }catch(java.io.IOException JavaDoc con){
668            throw new DeploymentException(con.getLocalizedMessage());
669       }
670         return deploySuccess;
671      }
672     
673      public void registerDatasource (String JavaDoc xmlFile) throws DeploymentException {
674        //IASDeployer iasDeployer = new IASDeployer();
675
//iasDeployer.registerDatasource(this, xmlFile);
676
}
677      
678      private void initEngine() throws LoginFailureException {
679          //if (null == ec) {
680
// ec = new EngineController(getHost(),Integer.toString(getPort()),getUserName(),
681
// getPassword(),KSRPCPacket.GXADMIN_ENGTYPE_KJS);
682

683          //} // ec is not null
684
}
685     public void removeEngineController(){
686         //if (null != ec) {
687
// ec.disconnect();
688
// ec =null;
689
// }
690
}
691     
692 // public synchronized void cleanupPreviousTaskLaunchedByTheIDE(){
693
//if (ec==null)// optimization: the engine did not start and we try to kill a process: not need to start i!!!
694
// return;
695
//ec.start();
696

697 // }
698
public void stopInstance(final UIMessenger messenger){
699         try{
700             Reporter.info("---------------------stopInstance"); // NOI18N
701
class StopThread extends Thread JavaDoc{
702             public void run () {
703                 try{
704                     if(getSelectedInstance().isRunning()){
705                             getSelectedInstance().stop();
706                     }
707                     Reporter.info("---------------------AFTER STOP-------------"); // NOI18N
708
}catch(AFTargetNotFoundException te){
709                     messenger.setNotify(te.getLocalizedMessage());
710                 }catch(DeploymentException de){
711                     messenger.setNotify(de.getLocalizedMessage());
712                 }catch(InstanceNotRunningException inre){
713                     messenger.setNotify(inre.getLocalizedMessage());
714                 }catch(ControlException ce){
715                    messenger.setNotify(ce.getLocalizedMessage());
716                 }catch(AFException afe){
717                     messenger.setNotify(afe.getLocalizedMessage());
718                 }
719                 
720              }
721             }
722             StopThread stop_server = new StopThread();
723             stop_server.start();
724             Thread.sleep(500);
725             while(stop_server.isAlive()){
726               Thread.sleep(1000);
727             }
728             Reporter.info("---------------------After stop server"); // NOI18N
729
}catch(Exception JavaDoc e){
730              e.printStackTrace();
731         }
732     }
733     
734     public boolean stopInstance() throws AFTargetNotFoundException, InstanceNotRunningException,
735                                                                 ControlException, AFException, DeploymentException{
736         Reporter.info("---------------------STARTANYKJS"); // NOI18N
737
boolean status = false;
738         if(getSelectedInstance().isRunning())
739              status = getSelectedInstance().stop();
740         Reporter.info("---------------------AFTER START-------------"); // NOI18N
741
return status;
742     }
743     
744     public void restart(){
745         try{
746             Reporter.info("---------------------RESTART"); // NOI18N
747
class RestartThread extends Thread JavaDoc{
748             public void run () {
749                 try{
750                     getSelectedInstance().restart();
751                     Reporter.info("---------------------AFTER RESTART-------------"); // NOI18N
752
}catch(AFTargetNotFoundException te){
753                     //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
754
te.printStackTrace();
755                 }catch(DeploymentException de){
756                     //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
757
de.printStackTrace();
758                 }catch(ControlException ce){
759                     //JOptionPane.showMessageDialog(null, ce.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
760
ce.printStackTrace();
761                 }catch(AFException afe){
762                     //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Err_RestartServer"), JOptionPane.ERROR_MESSAGE);//NOI18N
763
afe.printStackTrace();
764                 }
765              }
766             }
767             RestartThread restart = new RestartThread();
768             restart.start();
769             //Thread.sleep(5000);
770
//while(restart.isAlive()){
771
//wait
772
//}
773
Reporter.info("---------------------Ready after restart"); // NOI18N
774
}catch(Exception JavaDoc e){
775              e.printStackTrace();
776         }
777     
778     }
779     
780     public void startInstance(final UIMessenger messenger){
781         try{
782             Reporter.info("---------------------STARTANYKJS"); // NOI18N
783
class StartThread extends Thread JavaDoc{
784             public void run () {
785                 try{
786                     if(!getSelectedInstance().isRunning()){
787                             getSelectedInstance().start();
788                     }
789                     Reporter.info("---------------------AFTER START-------------"); // NOI18N
790
}catch(AFTargetNotFoundException te){
791                     messenger.setNotify(te.getLocalizedMessage());
792                 }catch(DeploymentException de){
793                     messenger.setNotify(de.getLocalizedMessage());
794                 }catch(InstanceAlreadyRunningException iare){
795                     messenger.setNotify(iare.getLocalizedMessage());
796                 }catch(ControlException ce){
797                     messenger.setNotify(ce.getLocalizedMessage());
798                 }catch(AFException afe){
799                    messenger.setNotify(afe.getLocalizedMessage());
800                 }
801              }
802             }
803             
804             StartThread start_server = new StartThread();
805             start_server.start();
806            // Thread.sleep(500);
807
while(start_server.isAlive()){
808                 Thread.sleep(1000);
809             }
810             Reporter.info("---------------------Ready after start"); // NOI18N
811
}catch(Exception JavaDoc e){
812              e.printStackTrace();
813         }
814     
815     }
816     
817     public boolean startInstance() throws AFTargetNotFoundException, InstanceAlreadyRunningException,
818                                                                 ControlException, AFException, DeploymentException{
819         Reporter.info("---------------------STARTANYKJS"); // NOI18N
820
boolean status = false;
821         if(!getSelectedInstance().isRunning()){
822             status = getSelectedInstance().start();
823         }
824         Reporter.info("---------------------AFTER START-------------"); // NOI18N
825
return status;
826         // messenger.setErrorMsg(bundle.getString ("Err_NoTarget"), bundle.getString ("Err_StartServer"));* //NOI18N
827
}
828     
829     public boolean isRunning() throws AFException, AFTargetNotFoundException, DeploymentException, AFRuntimeStoreException{
830         instRunning = false;
831         instRunning = getSelectedInstance().isRunning();
832         return instRunning;
833     }
834     
835     public boolean isLocal() throws DeploymentException {
836          try{
837             String JavaDoc host=InetAddress.getLocalHost().getHostName();
838             return host.equals (getHost());
839         }
840         catch(java.net.UnknownHostException JavaDoc e){
841             throw new DeploymentException(e.getLocalizedMessage());
842             //JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
843
}
844     }
845      public boolean isUp(){
846             if (checkAlreadyDone==true)
847                   return IAS_Running;
848             //IAS_Running = ServerAccess.isKASAlive(getPort(), 1);
849
checkAlreadyDone = true;
850             Timer aTimer = new Timer();
851             TimerTask task = new TimerTask(){
852                 public void run() {
853                             synchronized (this) {
854                                 checkAlreadyDone = false;
855                             }
856                 }
857
858             };
859             aTimer.schedule(task,2000);
860             return IAS_Running;
861
862             
863         }
864         
865                
866     public static boolean ServName(String JavaDoc value, List serv, String JavaDoc nod_name, HostAndPort hostport,String JavaDoc uName,String JavaDoc passwd){
867        boolean exists = false;
868        value = value + "(" + nod_name + ")";//NOI18N
869
for(int i=0; i<serv.size(); i++){
870         IServerInstanceBean instance = (IServerInstanceBean) serv.get(i);
871         String JavaDoc inst = instance.getName();
872         if(inst.equals(value))
873            exists = true;
874        }//for
875
Iterator it = ServerInstanceManagerFactory.getFactory().getServerInstanceManager(hostport,uName,passwd).getAllServerInstances();
876        while (it.hasNext()){
877            String JavaDoc inst1 = ((AppServerInstance)it.next()).toString();
878            if(inst1.equals(value))
879               exists = true;
880        }
881       
882       return exists;
883   }
884   
885   public void Undeploy(final String JavaDoc resName, final String JavaDoc resType, final UIMessenger messenger){
886       final String JavaDoc server = this.getName();
887       try{
888         Reporter.info("---------------------Before Undeploy "); // NOI18N
889
class UndeployThread extends Thread JavaDoc{
890             public void run () {
891                 try{
892                     if(resType.trim().indexOf(".ear") != -1){ // NOI18N
893
getSelectedInstance().undeployApplication(resName);
894                     }else{
895                         if(resType.trim().indexOf(".war") != -1){ // NOI18N
896
getSelectedInstance().undeployModule(resName, DeploymentConstants.WAR);
897                         }else if(resType.trim().indexOf(".jar") != -1){ // NOI18N
898
getSelectedInstance().undeployModule(resName, DeploymentConstants.EJB);
899                         }else if(resType.trim().indexOf(".rar") != -1){ // NOI18N
900
getSelectedInstance().undeployModule(resName, DeploymentConstants.RAR);
901                         }
902                     }//else
903
getSelectedInstance().applyChanges();
904                     messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinUndeploy"), new Object JavaDoc[] {server}) ); //NOI18N
905
}catch(AFTargetNotFoundException te){
906                     messenger.setNotify(te.getLocalizedMessage());
907                     //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
908
}catch(AFException afe){
909                     messenger.setNotify(afe.getLocalizedMessage());
910                     //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
911
}catch(AFRuntimeStoreException afre){
912                     messenger.ConfigXmlChanged(server);
913                 }
914              }//run
915
}
916         UndeployThread undeploy = new UndeployThread();
917         undeploy.start();
918         Reporter.info("---------------------After Undeploy"); // NOI18N
919
while(undeploy.isAlive()){
920              Thread.sleep(500);
921         }
922         
923         Reporter.info("---------------------Finished Undeploy"); // NOI18N
924
}catch(Exception JavaDoc e){
925              e.printStackTrace();
926       }
927   }//Undeploy
928

929   public void Apply(final UIMessenger messenger){
930       final String JavaDoc server = this.getName();
931       try{
932         Reporter.info("---------------------Applying changes to Server Instance"); // NOI18N
933
class ApplyThread extends Thread JavaDoc{
934             public void run () {
935                 try{
936                     getSelectedInstance().applyChanges();
937                     messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_Applyed"), new Object JavaDoc[] {server}) ); //NOI18N
938
}catch(AFTargetNotFoundException te){
939             messenger.setNotify(te.getLocalizedMessage());
940                     //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
941
}catch(AFException afe){
942                     messenger.setNotify(afe.getLocalizedMessage());
943                     //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
944
}catch(AFRuntimeStoreException afre){
945                     messenger.ConfigXmlChanged(server);
946                 }
947             }//run
948
}
949         ApplyThread appl = new ApplyThread();
950         appl.start();
951         Reporter.info("---------------------After Applying changes to Server Instance"); // NOI18N
952
while(appl.isAlive()){
953              Thread.sleep(500);
954         }
955         Reporter.info("---------------------Finished Applying changes to Server Instance"); // NOI18N
956
}catch(Exception JavaDoc e){
957              e.printStackTrace();
958       }
959   }//Apply
960

961   public void Enable(final String JavaDoc resName, final String JavaDoc resType, final UIMessenger messenger){
962       final String JavaDoc server = this.getName();
963       try{
964         Reporter.info("---------------------Enabling Resource"); // NOI18N
965
class EnableThread extends Thread JavaDoc{
966             public void run () {
967                 try{
968                     if(resType.trim().indexOf(".ear") != -1){ // NOI18N
969
DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
970                         component.enable();
971                     }else{
972                         if(resType.trim().indexOf(".jar") != -1){ // NOI18N
973
DeployedEJBModuleComponentBean component = getSelectedInstance().getDeployedEJBModule(resName);
974                             component.enable();
975                         }else if(resType.trim().indexOf(".war") != -1){ // NOI18N
976
DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);
977                             component.enable();
978                         }else{
979                             Reporter.info("####### UNKNOWN Archive Type");//NOI18N
980
}
981                     }//else
982
getSelectedInstance().applyChanges();
983                     messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinEnable"), new Object JavaDoc[] {server}) ); //NOI18N
984
}catch(AFTargetNotFoundException te){
985             messenger.setNotify(te.getLocalizedMessage());
986                     //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
987
}catch(AFException afe){
988             messenger.setNotify(afe.getLocalizedMessage());
989                     //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
990
}catch(AFRuntimeStoreException afre){
991                     messenger.ConfigXmlChanged(server);
992                 }
993             }//run
994
}
995         EnableThread enThread = new EnableThread();
996         enThread.start();
997         Reporter.info("---------------------After Enabling Resource"); // NOI18N
998
while(enThread.isAlive()){
999             Thread.sleep(500);
1000        }
1001        Reporter.info("---------------------Finished Enabling Resource"); // NOI18N
1002
}catch(Exception JavaDoc e){
1003             e.printStackTrace();
1004      }
1005  }//Enabled
1006

1007  public void Disable(final String JavaDoc resName, final String JavaDoc resType, final UIMessenger messenger){
1008      final String JavaDoc server = this.getName();
1009      try{
1010        Reporter.info("---------------------Before Disabling Resource"); // NOI18N
1011
class DisableThread extends Thread JavaDoc{
1012            public void run () {
1013                try{
1014                    if(resType.trim().indexOf(".ear") != -1){ // NOI18N
1015
DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
1016                        component.disable();
1017                    }else{
1018                        if(resType.trim().indexOf(".jar") != -1){ // NOI18N
1019
DeployedEJBModuleComponentBean component = getSelectedInstance().getDeployedEJBModule(resName);
1020                            component.disable();
1021                        }else if(resType.trim().indexOf(".war") != -1){ // NOI18N
1022
DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);
1023                            component.disable();
1024                        }else{
1025                            Reporter.info("####### UNKNOWN Archive Type");//NOI18N
1026
}
1027                    }//else
1028
getSelectedInstance().applyChanges();
1029                    messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_FinDisable"), new Object JavaDoc[] {server}) ); //NOI18N
1030
}catch(AFTargetNotFoundException te){
1031            messenger.setNotify(te.getLocalizedMessage());
1032                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1033
}catch(AFException afe){
1034            messenger.setNotify(afe.getLocalizedMessage());
1035                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1036
}catch(AFRuntimeStoreException afre){
1037                    messenger.ConfigXmlChanged(server);
1038                }
1039            }//run
1040
}
1041        DisableThread disThread = new DisableThread();
1042        disThread.start();
1043        Reporter.info("---------------------After Disabling Resource"); // NOI18N
1044
while(disThread.isAlive()){
1045             Thread.sleep(500);
1046        }
1047        Reporter.info("---------------------Finished Disabling Resource"); // NOI18N
1048
}catch(Exception JavaDoc e){
1049             e.printStackTrace();
1050      }
1051  }//Disabled
1052

1053  
1054  public boolean isEnabled(final String JavaDoc resName, final String JavaDoc resType, final UIMessenger messenger){
1055        final String JavaDoc server = this.getName();
1056        Reporter.info("---------------------Before checking if resource is enabled"); // NOI18N
1057
try{
1058            if(resType.trim().indexOf(".ear") != -1){ // NOI18N
1059
DeployedApplicationComponentBean component = getSelectedInstance().getDeployedApplication(resName);
1060               isEnabled = component.isEnabled();
1061            }else{
1062               if(resType.trim().indexOf(".war") != -1){ // NOI18N
1063
DeployedWebModuleComponentBean component = getSelectedInstance().getDeployedWebModule(resName);
1064                  isEnabled = component.isEnabled();
1065               }else if(resType.trim().indexOf(".jar") != -1){ // NOI18N
1066
DeployedEJBModuleComponentBean component = getSelectedInstance().getDeployedEJBModule(resName);
1067                  isEnabled = component.isEnabled();
1068               }
1069            }//else
1070
//messenger.setStatusText(java.text.MessageFormat.format(bundle.getString("Msg_Applyed"), new Object[] {server}) );
1071
}catch(AFTargetNotFoundException te){
1072            messenger.setNotify(te.getLocalizedMessage());
1073            //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1074
}catch(AFException afe){
1075            messenger.setNotify(afe.getLocalizedMessage());
1076            //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1077
}catch(AFRuntimeStoreException afre){
1078            //messenger.ConfigXmlChanged(server);
1079
}
1080        
1081        Reporter.info("---------------------Finished checking if resource is enabled"); // NOI18N
1082
return isEnabled;
1083  }//isEnabled
1084

1085  
1086  
1087  public void deleteJdbc(final String JavaDoc resourceName, final UIMessenger messenger){
1088    final String JavaDoc server = this.getName();
1089    try{
1090        Reporter.info("---------------------Before deleting Jdbc"); // NOI18N
1091
class deleteJdbcThread extends Thread JavaDoc{
1092            public void run () {
1093                try{
1094                    getSelectedInstance().deleteJDBCResource(resourceName);
1095                }catch(DeploymentException de){
1096            messenger.setNotify(de.getLocalizedMessage());
1097                    //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1098
}catch(AFTargetNotFoundException te){
1099            messenger.setNotify(te.getLocalizedMessage());
1100                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1101
}catch(AFException afe){
1102            messenger.setNotify(afe.getLocalizedMessage());
1103                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1104
}catch(AFRuntimeStoreException afre){
1105                    messenger.ConfigXmlChanged(server);
1106                }
1107            }
1108        }//deleteJDBCThread
1109
deleteJdbcThread delJdbc = new deleteJdbcThread();
1110        delJdbc.start();
1111        Reporter.info("---------------------After deleting Registered Jdbc "); // NOI18N
1112
while(delJdbc.isAlive()){
1113           //wait
1114
}
1115        getSelectedInstance().applyChanges();
1116        Reporter.info("---------------------Finished deleting Registered Jdbc"); // NOI18N
1117
}catch(Exception JavaDoc e){
1118        e.printStackTrace();
1119    }
1120  }//deleteJdbc
1121

1122  public void deleteResource(final String JavaDoc resourceName, final String JavaDoc resType, final UIMessenger messenger){
1123    final String JavaDoc server = this.getName();
1124    try{
1125        Reporter.info("---------------------Before deleting resource"); // NOI18N
1126
class deleteResourceThread extends Thread JavaDoc{
1127            public void run () {
1128                try{
1129                    if (resType.equals("JDBC")) // NOI18N
1130
getSelectedInstance().deleteJDBCResource(resourceName);
1131                    else if (resType.equals("CP")) // NOI18N
1132
getSelectedInstance().deleteJDBCConnectionPool(resourceName);
1133                    else if (resType.equals("JMS")) // NOI18N
1134
getSelectedInstance().deleteJMSResource(resourceName);
1135                    else if (resType.equals("PMF")) // NOI18N
1136
getSelectedInstance().deletePersistenceManagerFactoryResource(resourceName);
1137                    else if (resType.equals("Mail")) // NOI18N
1138
getSelectedInstance().deleteJavaMailResource(resourceName);
1139                    else
1140                            Reporter.error(bundle.getString("Err_NoResource"));
1141                }catch(DeploymentException de){
1142             messenger.setNotify(de.getLocalizedMessage());
1143                    //JOptionPane.showMessageDialog(null, de.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1144
}catch(AFTargetNotFoundException te){
1145            messenger.setNotify(te.getLocalizedMessage());
1146                    //JOptionPane.showMessageDialog(null, bundle.getString ("Err_NoTarget"), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1147
}catch(AFException afe){
1148            messenger.setNotify(afe.getLocalizedMessage());
1149                    //JOptionPane.showMessageDialog(null, afe.getLocalizedMessage(), bundle.getString ("Error"), JOptionPane.ERROR_MESSAGE);//NOI18N
1150
}catch(AFRuntimeStoreException afre){
1151                    messenger.ConfigXmlChanged(server);
1152                }
1153            }
1154        }//deleteResourceThread
1155
deleteResourceThread del = new deleteResourceThread();
1156        del.start();
1157        Reporter.info("---------------------After deleting registered resource"); // NOI18N
1158
while(del.isAlive()){
1159           //wait
1160
}
1161        getSelectedInstance().applyChanges();
1162        Reporter.info("---------------------Finished deleting Registered Resource"); // NOI18N
1163
}catch(Exception JavaDoc e){
1164        e.printStackTrace();
1165    }
1166  }//deleteResource
1167

1168  private int debugPort;
1169  public int startInDebugMode(final UIMessenger messenger){
1170      debugPort = -1;
1171      try{
1172          Reporter.info("---------------------STARTANYKJS"); // NOI18N
1173
class StartDebugThread extends Thread JavaDoc{
1174              public void run() {
1175                  try{
1176                      if(!getSelectedInstance().isRunning()){
1177                          
1178                          debugPort = getSelectedInstance().startInDebugMode();
1179                      }
1180                      Reporter.info("---------------------AFTER START-------------"); // NOI18N
1181
}catch(AFTargetNotFoundException te){
1182                       messenger.setNotify(te.getLocalizedMessage());
1183                  }catch(DeploymentException de){
1184                       messenger.setNotify(de.getLocalizedMessage());
1185                  }catch(InstanceAlreadyRunningException iare){
1186                       messenger.setNotify(iare.getLocalizedMessage());
1187                  }catch(ControlException ce){
1188                       messenger.setNotify(ce.getLocalizedMessage());
1189                  }catch(AFException afe){
1190                      messenger.setNotify(afe.getLocalizedMessage());
1191                  }
1192              }
1193          }
1194          
1195          StartDebugThread debug_server = new StartDebugThread();
1196          debug_server.start();
1197          Thread.sleep(500);
1198          
1199          while(debug_server.isAlive()){
1200              Thread.sleep(1000);
1201          }
1202          Reporter.info("---------------------Ready after start"); // NOI18N
1203
}catch(Exception JavaDoc e){
1204          e.printStackTrace();
1205      }
1206      return debugPort;
1207  }
1208 
1209  public int startInDebugMode() throws AFTargetNotFoundException, DeploymentException, ControlException,
1210                                                                InstanceAlreadyRunningException, AFException{
1211      debugPort = -1;
1212      Reporter.info("---------------------STARTANYKJS"); // NOI18N
1213
if(!getSelectedInstance().isRunning()){
1214          debugPort = getSelectedInstance().startInDebugMode();
1215      }
1216      Reporter.info("---------------------AFTER START-------------"); // NOI18N
1217
return debugPort;
1218  }
1219  
1220  public void OverwriteConfig() throws AFException{
1221      getSelectedInstance().overwriteChanges();
1222  }
1223  
1224  public void useManualConfig() throws AFException{
1225      getSelectedInstance().useManualChanges();
1226  }
1227  
1228  public int getORBPort() throws AttributeNotFoundException, AccessViolationException,AFTargetNotFoundException, DeploymentException, AFException {
1229        Integer JavaDoc portObj = (Integer JavaDoc) getSelectedInstance().getORBComponent().getIiopListener("orb-listener-1").getAttribute("port"); //NOI18N
1230
int port = portObj.intValue();
1231        Reporter.verbose("getORBPort() returns " + port); //NOI18N
1232
return port;
1233  }
1234  
1235  /* return -1 if the server is not running in debug mode, otherwise, returns the JPDA port number to listen to , using dt_socket mode
1236   **/

1237  public int getJPDAPortNumber() throws AFException {
1238        int p = getSelectedInstance().getServerStatus().getDebugPort();
1239        Reporter.verbose("getJPDAPortNumber() returns " + p); //NOI18N
1240
return p;
1241  }
1242}
1243
Popular Tags