KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ungoverned > oscar > Main


1 /*
2  * Oscar - An implementation of the OSGi framework.
3  * Copyright (c) 2004, Richard S. Hall
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of the ungoverned.org nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * Contact: Richard S. Hall (heavy@ungoverned.org)
33  * Contributor(s):
34  *
35 **/

36 package org.ungoverned.oscar;
37
38 import java.io.BufferedReader JavaDoc;
39 import java.io.IOException JavaDoc;
40 import java.io.InputStreamReader JavaDoc;
41
42 import org.ungoverned.oscar.util.DefaultBundleCache;
43
44 public class Main
45 {
46     private static Oscar m_oscar = null;
47
48     public static void main(String JavaDoc[] argv) throws Exception JavaDoc
49     {
50         // Initialize the system properties.
51
Oscar.initializeSystemProperties();
52
53         // See if the profile name property was specified.
54
String JavaDoc profileName = System.getProperty(DefaultBundleCache.CACHE_PROFILE_PROP);
55
56         // See if the profile directory property was specified.
57
String JavaDoc profileDirName = System.getProperty(DefaultBundleCache.CACHE_PROFILE_DIR_PROP);
58
59         // Print welcome banner.
60
System.out.println("\nWelcome to Oscar.");
61         System.out.println("=================\n");
62
63         // If no profile or profile directory is specified in the
64
// properties, then ask for a profile name.
65
if ((profileName == null) && (profileDirName == null))
66         {
67             System.out.print("Enter profile name: ");
68             BufferedReader JavaDoc in = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(System.in));
69             try
70             {
71                 profileName = in.readLine();
72             }
73             catch (IOException JavaDoc ex)
74             {
75                 System.err.println("Could not read input.");
76                 System.exit(-1);
77             }
78             System.out.println("");
79             if (profileName.length() != 0)
80             {
81                 System.setProperty(DefaultBundleCache.CACHE_PROFILE_PROP, profileName);
82             }
83         }
84
85         // A profile directory or name must be specified.
86
if ((profileDirName == null) && (profileName.length() == 0))
87         {
88             System.err.println("You must specify a profile name or directory.");
89             System.exit(-1);
90         }
91
92         try
93         {
94             // Now create an instance of Oscar.
95
m_oscar = new Oscar();
96         }
97         catch (Exception JavaDoc ex)
98         {
99             System.err.println("Could not create Oscar: " + ex);
100             ex.printStackTrace();
101             System.exit(-1);
102         }
103     }
104 }
Popular Tags