KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > service > cmdline > common > ModfactApplicationBase


1 /**
2  * copyright 2002 2003 Laboratoire d'Informatique Paris 6 (LIP6)
3  *
4  * This file is part of ModFact.
5  *
6  * ModFact is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * at your option) any later version.
10  *
11  * ModFact is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with ModFact; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20
21 package org.objectweb.modfact.corba.service.cmdline.common;
22
23 /**
24  * Class represnting a modfact base application, which can be an importer or an exporter.
25  */

26 public abstract class ModfactApplicationBase
27     extends org.objectweb.util.cmdline.lib.ApplicationBase {
28
29     /** The ORB. */
30     protected org.omg.CORBA.ORB JavaDoc orb_;
31
32     /**
33      * Constructor of a ModfactApplicationBase (call to the super class constructor).
34      * @param commandLine The command line manager.
35      */

36     protected ModfactApplicationBase(org.objectweb.util.cmdline.lib.DefaultCommandLine commandLine) {
37         super(commandLine, false);
38         getCommandLine().addOption(new OptionQuiet());
39     }
40
41     /**
42      * Obtains the mailing list associated to this development.
43      * @return The mailing list associated to this development.
44      */

45     public String JavaDoc getMailingList() {
46         return "modfact@lip6.fr";
47     }
48
49     /**
50      * Obtains the associated version information.
51      *
52      * @return The associated version information.
53      */

54     public String JavaDoc[] getVersionInformation() {
55         return new String JavaDoc[] {
56             getIdentity(),
57             "",
58             "Copyright (C) 2000-2003 Laboratoire d'Informatique Paris 6 (LIP6)",
59             "Contact: " + getMailingList(),
60             "",
61             "ModFact is free software; you can redistribute it and/or",
62             "modify it under the terms of the GNU Lesser General Public",
63             "License as published by the Free Software Foundation; either",
64             "version 2 of the License, or any later version.",
65             "",
66             "ModFact is distributed in the hope that it will be useful,",
67             "but WITHOUT ANY WARRANTY; without even the implied warranty of",
68             "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU",
69             "Lesser General Public License for more details.",
70             "",
71             "You should have received a copy of the GNU Lesser General Public",
72             "License along with this library; if not, write to the Free Software",
73             "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA" };
74     }
75
76     /**
77      * Executes the main function, i.e.
78      * 1 - Initializes the CORBA::ORB,
79      * 2 - Calls super.runMain().
80      * @param args The command line arguments.
81      */

82     public void runMain(String JavaDoc[] args) {
83         try {
84             // Initializes the CORBA::ORB singleton.
85
//args = TheORB.initialize(args);
86
orb_ = org.omg.CORBA.ORB.init(args, System.getProperties());
87         } catch (org.objectweb.util.api.ExceptionWrapper exc) {
88             report_exception(exc.getException());
89         } catch (java.lang.Exception JavaDoc exc) {
90             report_exception(exc);
91         }
92         // Calls ApplicationBase.runMain method.
93
super.runMain(removeORBArgument(args));
94     }
95
96     /**
97         * Remove the ORB arguments.
98         * @param args The command line arguments.
99         * @return The new args without ORB arguments.
100         */

101     private String JavaDoc[] removeORBArgument(String JavaDoc[] args) {
102         int nb = 0;
103         String JavaDoc[] tmp = new String JavaDoc[args.length];
104         for (int i = 0; i < args.length; i++) {
105             if (!args[i].startsWith("-ORB")) {
106                 tmp[nb] = args[i];
107                 nb++;
108             } else {
109                 if (args[i].startsWith("-ORBInitRef"))
110                     i++;
111                 i++;
112             }
113         }
114         String JavaDoc[] tmp2 = new String JavaDoc[nb];
115         for (int i = 0; i < nb; i++)
116             tmp2[i] = tmp[i];
117         return tmp2;
118     }
119
120 }
121
Popular Tags