KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > adm > JonasAdmin


1 /**
2  * JOnAS: Java(TM) Open Application Server Copyright (C) 1999-2004 Bull S.A.
3  * Contact: jonas-team@objectweb.org This library is free software; you can
4  * redistribute it and/or modify it under the terms of the GNU Lesser General
5  * Public License as published by the Free Software Foundation; either version
6  * 2.1 of the License, or any later version. This library is distributed in the
7  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
9  * the GNU Lesser General Public License for more details. You should have
10  * received a copy of the GNU Lesser General Public License along with this
11  * library; if not, write to the Free Software Foundation, Inc., 59 Temple
12  * Place, Suite 330, Boston, MA 02111-1307 USA
13  * --------------------------------------------------------------------------
14  * $Id: JonasAdmin.java,v 1.31 2005/07/13 06:28:35 durieuxp Exp $
15  * --------------------------------------------------------------------------
16  */

17
18 package org.objectweb.jonas.adm;
19
20 import java.io.BufferedReader JavaDoc;
21 import java.io.IOException JavaDoc;
22 import java.io.InputStreamReader JavaDoc;
23 import java.rmi.RemoteException JavaDoc;
24 import java.util.Enumeration JavaDoc;
25 import java.util.Properties JavaDoc;
26 import java.util.Vector JavaDoc;
27
28 import javax.naming.InitialContext JavaDoc;
29 import javax.rmi.PortableRemoteObject JavaDoc;
30
31 import org.objectweb.jonas.ear.EarServiceException;
32 import org.objectweb.jonas.resource.ResourceServiceException;
33 import org.objectweb.jonas.web.JWebContainerServiceException;
34
35 /*
36  * This class implements a rmi client to administrate the server. JonasAdmin may
37  * be run either in interactive mode or command mode. @author Philippe Coq
38  * Contributor(s): Florent Benoit & Ludovic Bert : Methods for wars and ear
39  * files
40  */

41 public class JonasAdmin {
42
43     private static final String JavaDoc SERVERNAME = "JOnAS server ";
44
45     private static String JavaDoc jonasName = null;
46
47     private static AdmInterface admI = null;
48
49     private static int state = -1;
50
51     private static boolean reachable = false;
52
53     private static boolean isNotEJB = false;
54
55     private static boolean isError = false;
56
57     private static void checkAdm() {
58
59         // Gets reference on Adm object
60
String JavaDoc admName = jonasName + Adm.ADMNAME_SUFFIX;
61         try {
62             InitialContext JavaDoc initialContext = new InitialContext JavaDoc();
63             admI = (AdmInterface) PortableRemoteObject.narrow(initialContext.lookup(admName), AdmInterface.class);
64             state = admI.getServerState();
65             reachable = (state == Adm.READY);
66             if (reachable) {
67                 isNotEJB = !admI.isEJBContainer();
68             }
69         } catch (Exception JavaDoc e) {
70             reachable = false;
71         }
72     }
73
74     /**
75      * check every second if server is ready and return when it's OK. don't wait
76      * more than 100 sec.
77      */

78      private static void waitServer() {
79         for (int i = 0; i < 200; i++) {
80             try {
81                 // wait 0.5 second
82
Thread.sleep(500);
83             } catch (InterruptedException JavaDoc e) {
84                 return;
85             }
86             // test if server is ready
87
if (reachable) {
88                 return;
89             }
90             checkAdm();
91             if (state == Adm.STOPPED) {
92                 return;
93             }
94         }
95         System.out.println(SERVERNAME + jonasName + " unreachable");
96     }
97
98     /**
99      * This method can add beans, war file ear or rar file depending on the
100      * extension of the file if it's a .jar file : -> Create a new JOnAS
101      * container for Beans relative to the file FileName if it's a .war file : ->
102      * deploy the war with the webcontainer service if it's a .ear file : ->
103      * Deploy the ear if it's a .rar file : -> Deploy the rar
104      * @param fileName name of the .jar file (Case of ejb-jar file) name of the
105      * .war fle (Case of WAR file) name of the .ear file (Case of EAR
106      * file) name of the .rar file (Case of RAR file)
107      */

108     private static void addFile(String JavaDoc fileName) {
109
110         if (!reachable) {
111             System.err.println(SERVERNAME + jonasName + " unreachable");
112             isError = true;
113             return;
114         }
115         try {
116             if (fileName.toLowerCase().endsWith(".jar") || fileName.toLowerCase().endsWith(".xml")) {
117                 //jar file
118
if (isNotEJB) {
119                     System.err.println("no beans on TMServer");
120                     isError = true;
121                     return;
122                 }
123                 admI.addBeans(fileName);
124             } else if (fileName.toLowerCase().endsWith(".war")) {
125                 //War file
126
admI.addWar(fileName);
127             } else if (fileName.toLowerCase().endsWith(".ear")) {
128                 //ear file
129
admI.addEar(fileName);
130             } else if (fileName.toLowerCase().endsWith(".rar")) {
131                 //rar file
132
admI.addRar(fileName);
133             } else {
134                 //bad format
135
System.err.println("Valid file extensions are : .jar, .xml, .war, .ear, .rar");
136                 return;
137             }
138         } catch (JWebContainerServiceException e) {
139             System.err.println("admI.addWar: " + e);
140             isError = true;
141             return;
142         } catch (EarServiceException e) {
143             System.err.println("admI.addEar: " + e);
144             isError = true;
145             return;
146         } catch (ResourceServiceException e) {
147             System.err.println("admI.addRar: " + e);
148             isError = true;
149             return;
150         } catch (RemoteException JavaDoc e) {
151             System.err.println("RemoteException : " + e);
152             e.printStackTrace();
153             isError = true;
154             return;
155         }
156     }
157
158     /**
159      * This method can remove beans, war file or ear file depending on the
160      * extension of the file if it's a .jar file : -> Remove a JOnAS container
161      * for Beans relative to the file FileName if it's a .war file : -> undeploy
162      * the war with the webcontainer service if it's a .ear file : -> uneploy
163      * the ear if it's a .rar file : -> uneploy the rar
164      * @param fileName name of the .jar file (Case of ejb-jar file) name of the
165      * .war fle (Case of WAR file) name of the .ear file (Case of EAR
166      * file) name of the .rar file (Case of RAR file)
167      */

168     private static void removeFile(String JavaDoc fileName) {
169         if (!reachable) {
170             System.err.println(SERVERNAME + jonasName + " unreachable");
171             isError = true;
172             return;
173         }
174         //Remove a file (based upon the extension file
175
try {
176             if (fileName.toLowerCase().endsWith(".jar") || fileName.toLowerCase().endsWith(".xml")) {
177                 //jar file
178
if (isNotEJB) {
179                     System.err.println("no beans on TMServer");
180                     isError = true;
181                     return;
182                 }
183                 admI.removeBeans(fileName);
184             } else if (fileName.toLowerCase().endsWith(".war")) {
185                 //War file
186
admI.removeWar(fileName);
187             } else if (fileName.toLowerCase().endsWith(".ear")) {
188                 //ear file
189
admI.removeEar(fileName);
190             } else if (fileName.toLowerCase().endsWith(".rar")) {
191                 //rar file
192
admI.removeRar(fileName);
193             } else {
194                 //bad format
195
System.err.println("Valid file extensions are : .jar, xml, .war, .ear, *.rar");
196                 return;
197             }
198         } catch (JWebContainerServiceException e) {
199             System.err.println("admI.removeWar: " + e.getMessage());
200             isError = true;
201             return;
202         } catch (EarServiceException e) {
203             System.err.println("admI.removeEar: " + e.getMessage());
204             isError = true;
205             return;
206         } catch (ResourceServiceException e) {
207             System.err.println("admI.removeRar: " + e);
208             isError = true;
209             return;
210         } catch (RemoteException JavaDoc e) {
211             System.err.println("RemoteException : " + e.getMessage());
212             isError = true;
213             return;
214         }
215     }
216
217     /**
218      * This method tells if the given file is deployed or not.
219      * @param fileName name of the .jar file (Case of ejb-jar file) name of the
220      * .war file (Case of WAR file) name of the .ear file (Case of EAR
221      * file) name of the .rar file (Case of RAR file)
222      */

223     private static void isDeployedFile(String JavaDoc fileName) {
224         if (!reachable) {
225             System.err.println(SERVERNAME + jonasName + " unreachable");
226             isError = true;
227             return;
228         }
229         //Remove a file (based upon the extension file
230
try {
231             boolean isDeployed = false;
232             if (fileName.toLowerCase().endsWith(".jar") || fileName.toLowerCase().endsWith(".xml")) {
233                 //jar file
234
if (isNotEJB) {
235                     System.err.println("no beans on TMServer");
236                     isError = true;
237                     return;
238                 }
239                 isDeployed = admI.isLoaded(fileName);
240             } else if (fileName.toLowerCase().endsWith(".war")) {
241                 //War file
242
isDeployed = admI.isWarLoaded(fileName);
243             } else if (fileName.toLowerCase().endsWith(".ear")) {
244                 //ear file
245
isDeployed = admI.isEarLoaded(fileName);
246             } else if (fileName.toLowerCase().endsWith(".rar")) {
247                 //rar file
248
isDeployed = admI.isRarLoaded(fileName);
249             } else {
250                 //bad format
251
System.err.println("Valid file extensions are : .jar, xml, .war, .ear, .rar");
252                 return;
253             }
254             if (isDeployed) {
255                 System.out.println(fileName + " deployed in " + jonasName);
256             } else {
257                 System.out.println(fileName + " NOT deployed in " + jonasName);
258             }
259         } catch (JWebContainerServiceException e) {
260             System.err.println("admI.removeWar: " + e.getMessage());
261             isError = true;
262             return;
263         } catch (EarServiceException e) {
264             System.err.println("admI.removeEar: " + e.getMessage());
265             isError = true;
266             return;
267         } catch (ResourceServiceException e) {
268             System.err.println("admI.removeRar: " + e);
269             isError = true;
270             return;
271         } catch (RemoteException JavaDoc e) {
272             System.err.println("RemoteException : " + e.getMessage());
273             isError = true;
274             return;
275         }
276     }
277
278     private static void custom() {
279         if (isNotEJB) {
280             System.err.println("no beans on TMServer");
281             isError = true;
282             return;
283         }
284         if (!reachable) {
285             System.err.println(SERVERNAME + jonasName + " unreachable");
286             isError = true;
287             return;
288         }
289         try {
290             System.out.println(admI.dumpCustom());
291         } catch (RemoteException JavaDoc e) {
292             System.err.println("admI.dumpCustom() : " + e);
293             isError = true;
294             return;
295         }
296     }
297
298     private static void listbeans() {
299         if (isNotEJB) {
300             System.err.println("no beans on TMServer");
301             isError = true;
302             return;
303         }
304         if (!reachable) {
305             System.err.println(SERVERNAME + jonasName + " unreachable");
306             isError = true;
307             return;
308         }
309         try {
310             String JavaDoc[] result = admI.listBeans();
311             if (result.length == 0) {
312                 System.out.println("No bean in " + jonasName);
313             }
314             for (int i = 0; i < result.length; i++) {
315                 System.out.println(result[i]);
316             }
317         } catch (RemoteException JavaDoc e) {
318             System.err.println("admI.listBeans() : " + e);
319             isError = true;
320             return;
321         }
322     }
323
324     private static void listnames() {
325         if (!reachable) {
326             System.err.println(SERVERNAME + jonasName + " unreachable");
327             isError = true;
328             return;
329         }
330         Vector JavaDoc result = new Vector JavaDoc();
331         try {
332             result = admI.listContext();
333         } catch (RemoteException JavaDoc e) {
334             System.err.println("admI.listContext() : " + e);
335             isError = true;
336             return;
337         }
338
339         if (result.size() == 0) {
340             System.out.println("No name in JNDI context.");
341         }
342         for (int i = 0; i < result.size(); i++) {
343             System.out.println(result.elementAt(i));
344         }
345     }
346
347     private static void listproperties() {
348         if (!reachable) {
349             System.err.println(SERVERNAME + jonasName + " unreachable");
350             isError = true;
351             return;
352         }
353         Properties JavaDoc p = new Properties JavaDoc();
354         try {
355             p = admI.listEnv();
356         } catch (RemoteException JavaDoc e) {
357             System.err.println("admI.listEnv() : " + e);
358             isError = true;
359             return;
360         }
361         for (Enumeration JavaDoc e = p.keys(); e.hasMoreElements();) {
362             Object JavaDoc key = e.nextElement();
363             Object JavaDoc value = p.get(key);
364             System.out.println(key.toString() + "=" + value.toString());
365         }
366     }
367
368     private static void sync(boolean passivate) {
369         if (isNotEJB) {
370             System.err.println("no beans on TMServer");
371             isError = true;
372             return;
373         }
374         if (!reachable) {
375             System.err.println(SERVERNAME + jonasName + " unreachable");
376             isError = true;
377             return;
378         }
379         try {
380             admI.syncAllEntities(passivate);
381         } catch (RemoteException JavaDoc e) {
382             System.err.println("admI.syncAllEntities : " + e);
383             isError = true;
384             return;
385         }
386     }
387
388     private static void runGC() {
389         if (!reachable) {
390             System.err.println(SERVERNAME + jonasName + " unreachable");
391             isError = true;
392             return;
393         }
394         try {
395             admI.runGC();
396         } catch (RemoteException JavaDoc e) {
397             System.err.println("admI.runGC : " + e);
398             isError = true;
399             return;
400         }
401     }
402
403     private static void setTTimeout(String JavaDoc tstr) {
404         if (!reachable) {
405             System.err.println(SERVERNAME + jonasName + " unreachable");
406             isError = true;
407             return;
408         }
409         Integer JavaDoc i = new Integer JavaDoc(tstr);
410         try {
411             admI.setTransactionTimeout(i.intValue());
412         } catch (RemoteException JavaDoc e) {
413             System.err.println("admI.setTransactionTimeout : " + e);
414             isError = true;
415             return;
416         }
417     }
418
419     private static void listTopics() {
420         if (!reachable) {
421             System.err.println(SERVERNAME + jonasName + " unreachable");
422             isError = true;
423             return;
424         }
425         try {
426             String JavaDoc[] result = admI.getTopics();
427             if (result.length == 0) {
428                 System.out.println("No topics in " + jonasName);
429             }
430             for (int i = 0; i < result.length; i++) {
431                 String JavaDoc level = admI.getTopicLevel(result[i]);
432                 System.out.println(level + "\t" + result[i]);
433             }
434         } catch (RemoteException JavaDoc e) {
435             System.err.println("admI.getTopics : " + e);
436             isError = true;
437             return;
438         }
439     }
440
441     private static void setTopic(String JavaDoc t, String JavaDoc l) {
442         try {
443             admI.setTopicLevel(t, l.toUpperCase());
444         } catch (RemoteException JavaDoc e) {
445             System.err.println("admI.setTopics : " + e);
446             isError = true;
447             return;
448         }
449     }
450
451     private static void stopserver() {
452         if (!reachable) {
453             System.err.println(SERVERNAME + jonasName + " unreachable");
454             isError = true;
455             return;
456         }
457         try {
458             admI.killServer();
459         } catch (RemoteException JavaDoc e) {
460             // go here usually: java.io.EOFException
461
}
462         System.out.println(SERVERNAME + jonasName + " stopped");
463         reachable = false;
464     }
465
466     private static void help() {
467         System.out.println("addbeans adds beans in a new JOnAS container");
468         System.out.println("addfile adds beans/servlets/j2ee app/rars based upon the file extension");
469         System.out.println("custom dump jonas customization");
470         System.out.println("env JOnAS properties used by the server");
471         System.out.println("gc run the garbage collector");
472         System.out.println("help help");
473         System.out.println("jndinames lists registered JNDI names");
474         System.out.println("listbeans lists beans");
475         System.out.println("name to identify a current JOnAS server");
476         System.out.println("quit quit JonasAdmin");
477         System.out.println("removebeans remove beans in a new JOnAS container");
478         System.out.println("removefile remove beans/servlets/j2ee app/rars (based upon the file extension)");
479         System.out.println("stop stop current JOnAS");
480         System.out.println("sync synchronize all entities");
481         System.out.println("passivate passivate all entities");
482         System.out.println("trace get/set monolog topics");
483         System.out.println("ttimeout set default transaction timeout");
484     }
485
486     private static void usage() {
487         System.out.println("usage : jonas admin <options>");
488         System.out.println("if no option(except -n), mode is interactive.");
489         System.out.println("list of available options:");
490         System.out.println(" -n JonasName : to identify an JOnAS Server");
491         System.out.println(" -s : stops the EJB server.");
492         System.out.println(" -l : lists beans currently in the JOnAS Server.");
493         System.out.println(" -j : lists registered JNDI names.");
494         System.out.println(" -e : lists JOnAS properties currently used by the JOnAS Server.");
495         System.out.println(" -a fileName : dynamically adds : - beans from fileName in a new container");
496         System.out.println(" : - servlets from a WAR file");
497         System.out.println(" : - j2ee application from an EAR file");
498         System.out.println(" : - resource adapter from a RAR file");
499         System.out.println(" -r fileName : dynamically remove : - beans from container fileName");
500         System.out.println(" : - servlets of a WAR file");
501         System.out.println(" : - j2ee application of an EAR file");
502         System.out.println(" : - resource adapter from a RAR file");
503         System.out.println(" -isdeployed fileName : tells if the file is deployed or not");
504         System.out.println(" -sync: synchronize all entities");
505         System.out.println(" -passivate: passivate all entities");
506         System.out.println(" -gc: run the garbage collector");
507         System.out.println(" -tt timeout: set default transaction timeout");
508         System.out.println(" -t list monolog topics");
509         System.out.println(" -debug topic : set DEBUG for a monolog topic");
510         System.out.println(" -h : help message.");
511         System.out.println(" -? : help message.");
512     }
513
514     /*
515      * interactive mode
516      */

517     public static void menu() throws IOException JavaDoc {
518         // First name the jonas server
519
if (!reachable) {
520             System.out.println("You must first choose a jonas server. (command `name`)");
521             System.out.println("Type `help` to get the list of available commands");
522         }
523
524         // User interface
525
BufferedReader JavaDoc inbuf = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(System.in));
526         while (true) {
527             System.out.print("Admin (" + jonasName + ") > ");
528             String JavaDoc command = inbuf.readLine();
529             if (command.length() == 0) {
530                 continue;
531             }
532             if ("addbeans".startsWith(command) || "addfile".startsWith(command)) {
533                 String JavaDoc fName = null;
534                 System.out.print("file name ? > ");
535                 if ((fName = inbuf.readLine()).length() != 0) {
536                     addFile(fName);
537                 }
538                 continue;
539             }
540             if ("env".startsWith(command)) {
541                 listproperties();
542                 continue;
543             }
544             if ("gc".startsWith(command)) {
545                 runGC();
546                 continue;
547             }
548             if ("help".startsWith(command) || command.equals("?")) {
549                 help();
550                 continue;
551             }
552             if ("jndinames".startsWith(command)) {
553                 listnames();
554                 continue;
555             }
556             if ("listbeans".startsWith(command)) {
557                 listbeans();
558                 continue;
559             }
560             if ("custom".startsWith(command)) {
561                 custom();
562                 continue;
563             }
564             if ("name".startsWith(command)) {
565                 System.out.print("Enter the " + SERVERNAME + "'s name (jonas.name property) : ");
566                 jonasName = new String JavaDoc(inbuf.readLine());
567                 checkAdm();
568                 continue;
569             }
570             if ("quit".startsWith(command) || "exit".startsWith(command)) {
571                 return;
572             }
573             if ("removebeans".startsWith(command) || "removefile".startsWith(command)) {
574                 String JavaDoc fName = null;
575                 System.out.print("file name ? > ");
576                 if ((fName = inbuf.readLine()).length() != 0) {
577                     removeFile(fName);
578                 }
579                 continue;
580             }
581             if ("trace".startsWith(command)) {
582                 while (true) {
583                     listTopics();
584                     System.out.print("topic name ? > ");
585                     String JavaDoc tname = inbuf.readLine().trim();
586                     if (tname.length() == 0) {
587                         break;
588                     }
589                     System.out.print("topic level ? (DEBUG | WARN | INFO | ERROR | INHERIT) > ");
590                     String JavaDoc levstr = inbuf.readLine().trim();
591                     setTopic(tname, levstr);
592                 }
593                 continue;
594             }
595             if ("stop".startsWith(command)) {
596                 stopserver();
597                 continue;
598             }
599             if ("sync".startsWith(command)) {
600                 sync(false);
601                 continue;
602             }
603             if ("passivate".startsWith(command)) {
604                 sync(true);
605                 continue;
606             }
607             if ("ttimeout".startsWith(command)) {
608                 String JavaDoc tstr = null;
609                 System.out.print("transaction timeout in seconds ? > ");
610                 if ((tstr = inbuf.readLine()).length() != 0) {
611                     setTTimeout(tstr);
612                 }
613                 continue;
614             }
615             System.out.println("Unknown command. Type help to get for the list of commands.");
616         }
617     }
618
619     public static void main(String JavaDoc[] args) throws IOException JavaDoc {
620
621         String JavaDoc fileName = null;
622         String JavaDoc timeout = null;
623         String JavaDoc topic = null;
624
625         boolean lOption = false;
626         boolean pingOption = false;
627         boolean jOption = false;
628         boolean eOption = false;
629         boolean aOption = false;
630         boolean tOption = false;
631         boolean sOption = false;
632         boolean rOption = false;
633         boolean syncOpt = false;
634         boolean customOpt = false;
635         boolean passivateOpt = false;
636         boolean debugOption = false;
637         boolean ttOpt = false;
638         boolean gcOpt = false;
639         boolean isDeployedOpt = false;
640
641         boolean interactive = true;
642         boolean namedServer = false;
643         // Get command args
644
for (int argn = 0; argn < args.length; argn++) {
645             String JavaDoc arg = args[argn];
646             boolean nextArgument = argn < args.length - 1;
647
648             if (arg.equals("-a") && nextArgument) {
649                 fileName = args[++argn];
650                 aOption = true;
651                 interactive = false;
652                 continue;
653             }
654             if (arg.equals("-ping")) {
655                 pingOption = true;
656                 continue;
657             }
658             if (arg.equals("-custom")) {
659                 customOpt = true;
660                 interactive = false;
661                 continue;
662             }
663             if (arg.equals("-e")) {
664                 eOption = true;
665                 interactive = false;
666                 continue;
667             }
668             if (arg.equals("-h") || arg.equals("-?")) {
669                 usage();
670                 System.exit(0);
671             }
672             if (arg.equals("-gc")) {
673                 gcOpt = true;
674                 interactive = false;
675                 continue;
676             }
677             if (arg.equals("-j")) {
678                 jOption = true;
679                 interactive = false;
680                 continue;
681             }
682             if (arg.equals("-l")) {
683                 lOption = true;
684                 interactive = false;
685                 continue;
686             }
687             if (arg.equals("-n") && nextArgument) {
688                 jonasName = args[++argn];
689                 namedServer = true;
690                 continue;
691             }
692             if (arg.equals("-r") && nextArgument) {
693                 fileName = args[++argn];
694                 rOption = true;
695                 interactive = false;
696                 continue;
697             }
698             if (arg.equals("-s")) {
699                 sOption = true;
700                 interactive = false;
701                 continue;
702             }
703             if (arg.equals("-sync")) {
704                 syncOpt = true;
705                 interactive = false;
706                 continue;
707             }
708             if (arg.equals("-passivate")) {
709                 passivateOpt = true;
710                 interactive = false;
711                 continue;
712             }
713             if (arg.equals("-debug") && nextArgument) {
714                 topic = args[++argn];
715                 debugOption = true;
716                 interactive = false;
717                 continue;
718             }
719             if (arg.equals("-t")) {
720                 tOption = true;
721                 interactive = false;
722                 continue;
723             }
724             if (arg.equals("-tt") && nextArgument) {
725                 timeout = args[++argn];
726                 ttOpt = true;
727                 interactive = false;
728                 continue;
729             }
730             if (arg.equals("-isdeployed") && nextArgument) {
731                 fileName = args[++argn];
732                 isDeployedOpt = true;
733                 interactive = false;
734                 continue;
735             }
736             System.out.println("Bad option: " + arg);
737             usage();
738             System.exit(2);
739         }
740
741         if (!namedServer) {
742             jonasName = "jonas"; // default value
743
}
744
745         if (pingOption) {
746             // Wait EJB server is ready
747
waitServer();
748             return;
749         }
750
751         // for all other options, first check server is reachable
752
checkAdm();
753
754         if (aOption) {
755             // Adds beans in new JOnAS container
756
addFile(fileName);
757         }
758         if (rOption) {
759             // Remove beans in JOnAS container
760
removeFile(fileName);
761         }
762         if (lOption) {
763             // Lists beans
764
listbeans();
765         }
766         if (jOption) {
767             // jndi names
768
listnames();
769         }
770         if (eOption) {
771             // Lists JOnAS properties
772
listproperties();
773         }
774         if (tOption) {
775             // get monolog topics
776
listTopics();
777         }
778         if (debugOption) {
779             // set debug for a topic
780
setTopic(topic, "DEBUG");
781         }
782         if (sOption) {
783             // Stops Server
784
stopserver();
785         }
786         if (ttOpt) {
787             // set the default value for transaction timeout
788
setTTimeout(timeout);
789         }
790         if (syncOpt) {
791             // sync all entity instances outside transactions
792
sync(false);
793         }
794         if (customOpt) {
795             custom();
796         }
797         if (passivateOpt) {
798             // sync all entity instances outside transactions
799
sync(true);
800         }
801         if (gcOpt) {
802             // run the garbage collector
803
runGC();
804         }
805         if (isDeployedOpt) {
806             // is the file deployed ?
807
isDeployedFile(fileName);
808         }
809
810         // No option => interactive mode.
811
if (interactive) {
812             menu();
813         }
814
815         // Return status
816
if (!interactive) {
817             if (isError) {
818                 System.exit(2);
819             }
820         }
821     }
822 }
Popular Tags