1 /* Main.java -- RMI stub generator.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath 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, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 package gnu
.classpath
.tools
.rmic
;
24 import gnu
.classpath
.tools
.common
.ClasspathToolParser
;
25 import gnu
.classpath
.tools
.getopt
.Option
;
26 import gnu
.classpath
.tools
.getopt
.OptionException
;
27 import gnu
.classpath
.tools
.getopt
.Parser
;
29 import java
.util
.ArrayList
;
32 * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
34 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
38 private boolean noWrite
;
39 private boolean warnings
= true;
40 private boolean verbose
;
41 private boolean force
;
42 private String classpath
= ".";
43 private String outputDirectory
= ".";
45 private boolean need11Stubs
= false;
46 private boolean need12Stubs
= true;
50 * Specifies whether or not JRMP mode was explicitly requested.
54 private Parser
initializeParser()
56 Parser parser
= new ClasspathToolParser("rmic", true); //$NON-NLS-1$
57 parser
.setHeader(Messages
.getString("Main.Usage")); //$NON-NLS-1$
59 parser
.add(new Option("nowarn", //$NON-NLS-1$
60 Messages
.getString("Main.NoWarn")) //$NON-NLS-1$
62 public void parsed(String argument
) throws OptionException
67 parser
.add(new Option("nowrite", //$NON-NLS-1$
68 Messages
.getString("Main.NoWrite")) //$NON-NLS-1$
70 public void parsed(String argument
) throws OptionException
75 parser
.add(new Option("verbose", //$NON-NLS-1$
76 Messages
.getString("Main.Verbose")) //$NON-NLS-1$
78 public void parsed(String argument
) throws OptionException
83 parser
.add(new Option("d", //$NON-NLS-1$
84 Messages
.getString("Main.DirOpt"), //$NON-NLS-1$
85 Messages
.getString("Main.DirArg")) //$NON-NLS-1$
87 public void parsed(String argument
) throws OptionException
89 outputDirectory
= argument
;
92 parser
.add(new Option("classpath", //$NON-NLS-1$
93 Messages
.getString("Main.ClasspathOpt"), //$NON-NLS-1$
94 Messages
.getString("Main.ClasspathArg")) //$NON-NLS-1$
96 public void parsed(String argument
) throws OptionException
101 parser
.add(new Option("bootclasspath", //$NON-NLS-1$
102 Messages
.getString("Main.BootclasspathOpt"), //$NON-NLS-1$
103 Messages
.getString("Main.BootclasspathArg")) //$NON-NLS-1$
105 public void parsed(String argument
) throws OptionException
109 parser
.add(new Option("extdirs", //$NON-NLS-1$
110 Messages
.getString("Main.ExtdirsOpt"), //$NON-NLS-1$
111 Messages
.getString("Main.ExtdirsArg")) //$NON-NLS-1$
113 public void parsed(String argument
) throws OptionException
117 parser
.add(new Option("iiop", //$NON-NLS-1$
118 Messages
.getString("Main.IIOP")) //$NON-NLS-1$
120 public void parsed(String argument
) throws OptionException
125 parser
.add(new Option("always", //$NON-NLS-1$
126 Messages
.getString("Main.Always")) //$NON-NLS-1$
128 public void parsed(String argument
) throws OptionException
133 parser
.add(new Option("alwaysgenerate", //$NON-NLS-1$
134 Messages
.getString("Main.AlwaysGenerate")) //$NON-NLS-1$
136 public void parsed(String argument
) throws OptionException
141 parser
.add(new Option("nolocalstubs", //$NON-NLS-1$
142 Messages
.getString("Main.NoLocalStubs")) //$NON-NLS-1$
144 public void parsed(String argument
) throws OptionException
148 parser
.add(new Option("poa", //$NON-NLS-1$
149 Messages
.getString("Main.POA")) //$NON-NLS-1$
151 public void parsed(String argument
) throws OptionException
156 parser
.add(new Option("keep", //$NON-NLS-1$
157 Messages
.getString("Main.Keep")) //$NON-NLS-1$
159 public void parsed(String argument
) throws OptionException
164 parser
.add(new Option("keepgenerated", //$NON-NLS-1$
165 Messages
.getString("Main.KeepGenerated")) //$NON-NLS-1$
167 public void parsed(String argument
) throws OptionException
172 parser
.add(new Option("v1.1", //$NON-NLS-1$
173 Messages
.getString("Main.v11")) //$NON-NLS-1$
175 public void parsed(String argument
) throws OptionException
182 parser
.add(new Option("v1.2", //$NON-NLS-1$
183 Messages
.getString("Main.v12")) //$NON-NLS-1$
185 public void parsed(String argument
) throws OptionException
190 parser
.add(new Option("vcompat", //$NON-NLS-1$
191 Messages
.getString("Main.vcompat")) //$NON-NLS-1$
193 public void parsed(String argument
) throws OptionException
200 parser
.add(new Option("g", //$NON-NLS-1$
201 Messages
.getString("Main.DebugInfo")) //$NON-NLS-1$
203 public void parsed(String argument
) throws OptionException
211 private void run(String
[] args
)
213 Parser p
= initializeParser();
214 String
[] files
= p
.parse(args
);
216 if (files
.length
== 0)
222 ArrayList backends
= new ArrayList();
224 // FIXME: need an IDL RmicBackend
225 // FIXME: need a ClassGiopRmicCompiler RmicBackend
228 backends
.add(new SourceGiopRmicCompiler());
232 // Both IIOP and JRMP stubs were requested.
233 backends
.add(new ClassRmicCompiler());
234 // FIXME: SourceRmicCompiler should support v1.1
236 backends
.add(new SourceRmicCompiler());
241 backends
.add(new ClassRmicCompiler());
243 backends
.add(new SourceRmicCompiler());
246 for (int i
= 0; i
< backends
.size(); i
++)
248 RmicBackend b
= (RmicBackend
) backends
.get(i
);
249 b
.setup(keep
, need11Stubs
, need12Stubs
,
250 iiop
, poa
, false, warnings
,
251 noWrite
, verbose
, force
, classpath
,
252 null, null, outputDirectory
);
259 * The RMI compiler entry point.
261 public static void main(String
[] args
)
263 Main rmicprogram
= new Main();
266 rmicprogram
.run(args
);
270 System
.err
.println(Messages
.getString("Main.InternalError")); //$NON-NLS-1$
271 e
.printStackTrace(System
.err
);