KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > mdrshell > Main


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.mdrshell;
20
21 import java.io.FileInputStream JavaDoc;
22 import java.io.FileNotFoundException JavaDoc;
23 import java.io.InputStream JavaDoc;
24
25 import java.util.Collection JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import org.netbeans.api.mdr.*;
30 import org.openide.util.*;
31
32 import org.netbeans.mdr.NBMDRepositoryImpl;
33 import org.netbeans.mdr.util.*;
34
35 import javax.jmi.model.ModelPackage;
36 import javax.jmi.model.Import;
37 import javax.jmi.model.ImportClass;
38 import javax.jmi.model.ModelElement;
39 import javax.jmi.reflect.*;
40 import org.netbeans.mdr.persistence.memoryimpl.StorageFactoryImpl;
41 import org.openide.ErrorManager;
42
43 public class Main extends Object JavaDoc {
44     
45     /**
46      * Resources names of the standard library files
47      */

48     public static String JavaDoc[] STANDARD_LIBS = new String JavaDoc[] { "resources/start.ms", "resources/ext.ms" };
49     
50     /**
51      * Command line interface of the MDRShell. The MDRShell is a
52      * <em>Dynamic Java</em> shell with preprocessor. Before user input
53      * is processed the files <code>start.ms</code> and <code>ext.ms</code>
54      * in the package <code>org.netbeans.mdr.shell.resources</code> and the
55      * files given as command line arguments are processed.
56      *
57      * @param args a list of file names read into the shell
58      * @throws FileNotFoundException if one of the arguments does not denote a
59      * valid file name
60      * @throws SecurityException if there is no read access to a file given as
61      * argument
62      */

63     public static void main( String JavaDoc[] args ) throws FileNotFoundException JavaDoc {
64         try {
65             /* the input streams */
66             InputStream JavaDoc[] iss = new InputStream JavaDoc[STANDARD_LIBS.length+args.length+1];
67
68             /* standard library files */
69             for ( int i=0; i<STANDARD_LIBS.length; i++ ) {
70                 iss[i] = Main.class.getResourceAsStream(STANDARD_LIBS[i]);
71             }
72             /* files given as arguments */
73             for ( int i=0; i<args.length; i++ ) {
74                 iss[STANDARD_LIBS.length+i] = new FileInputStream JavaDoc(args[i]);
75             }
76             /* System.in for user input */
77             iss[STANDARD_LIBS.length+args.length] = System.in;
78
79             // Create and run the shell
80

81             new Shell().run( iss );
82             MDRManager.getDefault().shutdownAll();
83         } catch (RuntimeException JavaDoc e) {
84             ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
85             //throw e;
86
}
87     }
88 }
89
Popular Tags