KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > corba > Application


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.corba;
28
29 /**
30  * This class provides the main structure of a CORBA client application.
31  *
32  * Subclasses must defined the run() method.
33  *
34  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
35  *
36  * @version 0.3
37  */

38
39 public abstract class Application
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     // ==================================================================
48
//
49
// Constructor.
50
//
51
// ==================================================================
52

53     /**
54      ** The default constructor.
55      **/

56     public
57     Application()
58     {
59     }
60
61     // ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66

67     /**
68      ** Report an exception stack.
69      **
70      ** @param exception The exception.
71      **/

72     protected void
73     report_exception(Exception JavaDoc exception)
74     {
75         System.err.print("Please report the following exception trace");
76         System.err.println(" to openccm@objectweb.org");
77
78         // added for a better bug report
79
System.err.println(", including your ORB name and version\n");
80         System.err.println("Operating System = "
81             + System.getProperty("os.name")
82             + System.getProperty("os.version")
83             +"\n");
84         System.err.println("JDK version = "
85             + System.getProperty("java.version")
86             +"\n");
87
88         exception.printStackTrace();
89     }
90
91     // ==================================================================
92
//
93
// Public methods.
94
//
95
// ==================================================================
96

97     /**
98      ** Start the application, i.e.
99      ** initialize the CORBA::ORB,
100      ** run the application,
101      ** destroy the CORBA::ORB.
102      **
103      ** @param args The command line arguments.
104      **/

105     public int
106     start(String JavaDoc[] args)
107     {
108         try
109         {
110             // Initialize the CORBA::ORB.
111
args = TheORB.initialize(args);
112
113             // Run the application.
114
int status = run(args);
115
116             // Destroy the CORBA::ORB.
117
TheORB.destroy();
118
119             return status;
120         }
121         catch(UserExceptionWrapper exc)
122         {
123             report_exception(exc.getUserException());
124         }
125         catch(Exception JavaDoc exc)
126         {
127             report_exception(exc);
128         }
129         return -1;
130     }
131
132     /**
133      ** Run the application.
134      **
135      ** @param args The command line arguments.
136      **
137      ** @return The status.
138      **/

139     public abstract int
140     run(String JavaDoc[] args);
141 }
142
Popular Tags