| 1 |
779 |
jeremybenn |
/* Main.java -- RMI stub generator.
|
| 2 |
|
|
Copyright (C) 2006 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 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)
|
| 9 |
|
|
any later version.
|
| 10 |
|
|
|
| 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.
|
| 15 |
|
|
|
| 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
|
| 19 |
|
|
02110-1301 USA.
|
| 20 |
|
|
|
| 21 |
|
|
Linking this library statically or dynamically with other modules is
|
| 22 |
|
|
making a combined work based on this library. Thus, the terms and
|
| 23 |
|
|
conditions of the GNU General Public License cover the whole
|
| 24 |
|
|
combination.
|
| 25 |
|
|
|
| 26 |
|
|
As a special exception, the copyright holders of this library give you
|
| 27 |
|
|
permission to link this library with independent modules to produce an
|
| 28 |
|
|
executable, regardless of the license terms of these independent
|
| 29 |
|
|
modules, and to copy and distribute the resulting executable under
|
| 30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
| 31 |
|
|
independent module, the terms and conditions of the license of that
|
| 32 |
|
|
module. An independent module is a module which is not derived from
|
| 33 |
|
|
or based on this library. If you modify this library, you may extend
|
| 34 |
|
|
this exception to your version of the library, but you are not
|
| 35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
| 36 |
|
|
exception statement from your version. */
|
| 37 |
|
|
|
| 38 |
|
|
|
| 39 |
|
|
package gnu.classpath.tools.rmic;
|
| 40 |
|
|
|
| 41 |
|
|
import gnu.classpath.tools.common.ClasspathToolParser;
|
| 42 |
|
|
import gnu.classpath.tools.getopt.Option;
|
| 43 |
|
|
import gnu.classpath.tools.getopt.OptionException;
|
| 44 |
|
|
import gnu.classpath.tools.getopt.Parser;
|
| 45 |
|
|
|
| 46 |
|
|
import java.util.ArrayList;
|
| 47 |
|
|
|
| 48 |
|
|
/**
|
| 49 |
|
|
* Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
|
| 50 |
|
|
*
|
| 51 |
|
|
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
|
| 52 |
|
|
*/
|
| 53 |
|
|
public class Main
|
| 54 |
|
|
{
|
| 55 |
|
|
private boolean noWrite;
|
| 56 |
|
|
private boolean warnings = true;
|
| 57 |
|
|
private boolean verbose;
|
| 58 |
|
|
private boolean force;
|
| 59 |
|
|
private String classpath = ".";
|
| 60 |
|
|
private String outputDirectory = ".";
|
| 61 |
|
|
private boolean poa;
|
| 62 |
|
|
private boolean need11Stubs = false;
|
| 63 |
|
|
private boolean need12Stubs = true;
|
| 64 |
|
|
private boolean keep;
|
| 65 |
|
|
private boolean iiop;
|
| 66 |
|
|
/**
|
| 67 |
|
|
* Specifies whether or not JRMP mode was explicitly requested.
|
| 68 |
|
|
*/
|
| 69 |
|
|
private boolean jrmp;
|
| 70 |
|
|
|
| 71 |
|
|
private Parser initializeParser()
|
| 72 |
|
|
{
|
| 73 |
|
|
Parser parser = new ClasspathToolParser("rmic", true); //$NON-NLS-1$
|
| 74 |
|
|
parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
|
| 75 |
|
|
|
| 76 |
|
|
parser.add(new Option("nowarn", //$NON-NLS-1$
|
| 77 |
|
|
Messages.getString("Main.NoWarn")) //$NON-NLS-1$
|
| 78 |
|
|
{
|
| 79 |
|
|
public void parsed(String argument) throws OptionException
|
| 80 |
|
|
{
|
| 81 |
|
|
warnings = false;
|
| 82 |
|
|
}
|
| 83 |
|
|
});
|
| 84 |
|
|
parser.add(new Option("nowrite", //$NON-NLS-1$
|
| 85 |
|
|
Messages.getString("Main.NoWrite")) //$NON-NLS-1$
|
| 86 |
|
|
{
|
| 87 |
|
|
public void parsed(String argument) throws OptionException
|
| 88 |
|
|
{
|
| 89 |
|
|
noWrite = true;
|
| 90 |
|
|
}
|
| 91 |
|
|
});
|
| 92 |
|
|
parser.add(new Option("verbose", //$NON-NLS-1$
|
| 93 |
|
|
Messages.getString("Main.Verbose")) //$NON-NLS-1$
|
| 94 |
|
|
{
|
| 95 |
|
|
public void parsed(String argument) throws OptionException
|
| 96 |
|
|
{
|
| 97 |
|
|
verbose = true;
|
| 98 |
|
|
}
|
| 99 |
|
|
});
|
| 100 |
|
|
parser.add(new Option("d", //$NON-NLS-1$
|
| 101 |
|
|
Messages.getString("Main.DirOpt"), //$NON-NLS-1$
|
| 102 |
|
|
Messages.getString("Main.DirArg")) //$NON-NLS-1$
|
| 103 |
|
|
{
|
| 104 |
|
|
public void parsed(String argument) throws OptionException
|
| 105 |
|
|
{
|
| 106 |
|
|
outputDirectory = argument;
|
| 107 |
|
|
}
|
| 108 |
|
|
});
|
| 109 |
|
|
parser.add(new Option("classpath", //$NON-NLS-1$
|
| 110 |
|
|
Messages.getString("Main.ClasspathOpt"), //$NON-NLS-1$
|
| 111 |
|
|
Messages.getString("Main.ClasspathArg")) //$NON-NLS-1$
|
| 112 |
|
|
{
|
| 113 |
|
|
public void parsed(String argument) throws OptionException
|
| 114 |
|
|
{
|
| 115 |
|
|
classpath = argument;
|
| 116 |
|
|
}
|
| 117 |
|
|
});
|
| 118 |
|
|
parser.add(new Option("bootclasspath", //$NON-NLS-1$
|
| 119 |
|
|
Messages.getString("Main.BootclasspathOpt"), //$NON-NLS-1$
|
| 120 |
|
|
Messages.getString("Main.BootclasspathArg")) //$NON-NLS-1$
|
| 121 |
|
|
{
|
| 122 |
|
|
public void parsed(String argument) throws OptionException
|
| 123 |
|
|
{
|
| 124 |
|
|
}
|
| 125 |
|
|
});
|
| 126 |
|
|
parser.add(new Option("extdirs", //$NON-NLS-1$
|
| 127 |
|
|
Messages.getString("Main.ExtdirsOpt"), //$NON-NLS-1$
|
| 128 |
|
|
Messages.getString("Main.ExtdirsArg")) //$NON-NLS-1$
|
| 129 |
|
|
{
|
| 130 |
|
|
public void parsed(String argument) throws OptionException
|
| 131 |
|
|
{
|
| 132 |
|
|
}
|
| 133 |
|
|
});
|
| 134 |
|
|
parser.add(new Option("iiop", //$NON-NLS-1$
|
| 135 |
|
|
Messages.getString("Main.IIOP")) //$NON-NLS-1$
|
| 136 |
|
|
{
|
| 137 |
|
|
public void parsed(String argument) throws OptionException
|
| 138 |
|
|
{
|
| 139 |
|
|
iiop = true;
|
| 140 |
|
|
}
|
| 141 |
|
|
});
|
| 142 |
|
|
parser.add(new Option("always", //$NON-NLS-1$
|
| 143 |
|
|
Messages.getString("Main.Always")) //$NON-NLS-1$
|
| 144 |
|
|
{
|
| 145 |
|
|
public void parsed(String argument) throws OptionException
|
| 146 |
|
|
{
|
| 147 |
|
|
force = true;
|
| 148 |
|
|
}
|
| 149 |
|
|
});
|
| 150 |
|
|
parser.add(new Option("alwaysgenerate", //$NON-NLS-1$
|
| 151 |
|
|
Messages.getString("Main.AlwaysGenerate")) //$NON-NLS-1$
|
| 152 |
|
|
{
|
| 153 |
|
|
public void parsed(String argument) throws OptionException
|
| 154 |
|
|
{
|
| 155 |
|
|
force = true;
|
| 156 |
|
|
}
|
| 157 |
|
|
});
|
| 158 |
|
|
parser.add(new Option("nolocalstubs", //$NON-NLS-1$
|
| 159 |
|
|
Messages.getString("Main.NoLocalStubs")) //$NON-NLS-1$
|
| 160 |
|
|
{
|
| 161 |
|
|
public void parsed(String argument) throws OptionException
|
| 162 |
|
|
{
|
| 163 |
|
|
}
|
| 164 |
|
|
});
|
| 165 |
|
|
parser.add(new Option("poa", //$NON-NLS-1$
|
| 166 |
|
|
Messages.getString("Main.POA")) //$NON-NLS-1$
|
| 167 |
|
|
{
|
| 168 |
|
|
public void parsed(String argument) throws OptionException
|
| 169 |
|
|
{
|
| 170 |
|
|
poa = true;
|
| 171 |
|
|
}
|
| 172 |
|
|
});
|
| 173 |
|
|
parser.add(new Option("keep", //$NON-NLS-1$
|
| 174 |
|
|
Messages.getString("Main.Keep")) //$NON-NLS-1$
|
| 175 |
|
|
{
|
| 176 |
|
|
public void parsed(String argument) throws OptionException
|
| 177 |
|
|
{
|
| 178 |
|
|
keep = true;
|
| 179 |
|
|
}
|
| 180 |
|
|
});
|
| 181 |
|
|
parser.add(new Option("keepgenerated", //$NON-NLS-1$
|
| 182 |
|
|
Messages.getString("Main.KeepGenerated")) //$NON-NLS-1$
|
| 183 |
|
|
{
|
| 184 |
|
|
public void parsed(String argument) throws OptionException
|
| 185 |
|
|
{
|
| 186 |
|
|
keep = true;
|
| 187 |
|
|
}
|
| 188 |
|
|
});
|
| 189 |
|
|
parser.add(new Option("v1.1", //$NON-NLS-1$
|
| 190 |
|
|
Messages.getString("Main.v11")) //$NON-NLS-1$
|
| 191 |
|
|
{
|
| 192 |
|
|
public void parsed(String argument) throws OptionException
|
| 193 |
|
|
{
|
| 194 |
|
|
need11Stubs = true;
|
| 195 |
|
|
need12Stubs = false;
|
| 196 |
|
|
jrmp = true;
|
| 197 |
|
|
}
|
| 198 |
|
|
});
|
| 199 |
|
|
parser.add(new Option("v1.2", //$NON-NLS-1$
|
| 200 |
|
|
Messages.getString("Main.v12")) //$NON-NLS-1$
|
| 201 |
|
|
{
|
| 202 |
|
|
public void parsed(String argument) throws OptionException
|
| 203 |
|
|
{
|
| 204 |
|
|
jrmp = true;
|
| 205 |
|
|
}
|
| 206 |
|
|
});
|
| 207 |
|
|
parser.add(new Option("vcompat", //$NON-NLS-1$
|
| 208 |
|
|
Messages.getString("Main.vcompat")) //$NON-NLS-1$
|
| 209 |
|
|
{
|
| 210 |
|
|
public void parsed(String argument) throws OptionException
|
| 211 |
|
|
{
|
| 212 |
|
|
need11Stubs = true;
|
| 213 |
|
|
need12Stubs = true;
|
| 214 |
|
|
jrmp = true;
|
| 215 |
|
|
}
|
| 216 |
|
|
});
|
| 217 |
|
|
parser.add(new Option("g", //$NON-NLS-1$
|
| 218 |
|
|
Messages.getString("Main.DebugInfo")) //$NON-NLS-1$
|
| 219 |
|
|
{
|
| 220 |
|
|
public void parsed(String argument) throws OptionException
|
| 221 |
|
|
{
|
| 222 |
|
|
}
|
| 223 |
|
|
});
|
| 224 |
|
|
|
| 225 |
|
|
return parser;
|
| 226 |
|
|
}
|
| 227 |
|
|
|
| 228 |
|
|
private void run(String[] args)
|
| 229 |
|
|
{
|
| 230 |
|
|
Parser p = initializeParser();
|
| 231 |
|
|
String[] files = p.parse(args);
|
| 232 |
|
|
|
| 233 |
|
|
if (files.length == 0)
|
| 234 |
|
|
{
|
| 235 |
|
|
p.printHelp();
|
| 236 |
|
|
System.exit(1);
|
| 237 |
|
|
}
|
| 238 |
|
|
|
| 239 |
|
|
ArrayList backends = new ArrayList();
|
| 240 |
|
|
|
| 241 |
|
|
// FIXME: need an IDL RmicBackend
|
| 242 |
|
|
// FIXME: need a ClassGiopRmicCompiler RmicBackend
|
| 243 |
|
|
if (iiop)
|
| 244 |
|
|
{
|
| 245 |
|
|
backends.add(new SourceGiopRmicCompiler());
|
| 246 |
|
|
|
| 247 |
|
|
if (jrmp)
|
| 248 |
|
|
{
|
| 249 |
|
|
// Both IIOP and JRMP stubs were requested.
|
| 250 |
|
|
backends.add(new ClassRmicCompiler());
|
| 251 |
|
|
// FIXME: SourceRmicCompiler should support v1.1
|
| 252 |
|
|
if (keep)
|
| 253 |
|
|
backends.add(new SourceRmicCompiler());
|
| 254 |
|
|
}
|
| 255 |
|
|
}
|
| 256 |
|
|
else
|
| 257 |
|
|
{
|
| 258 |
|
|
backends.add(new ClassRmicCompiler());
|
| 259 |
|
|
if (keep)
|
| 260 |
|
|
backends.add(new SourceRmicCompiler());
|
| 261 |
|
|
}
|
| 262 |
|
|
|
| 263 |
|
|
for (int i = 0; i < backends.size(); i++)
|
| 264 |
|
|
{
|
| 265 |
|
|
RmicBackend b = (RmicBackend) backends.get(i);
|
| 266 |
|
|
b.setup(keep, need11Stubs, need12Stubs,
|
| 267 |
|
|
iiop, poa, false, warnings,
|
| 268 |
|
|
noWrite, verbose, force, classpath,
|
| 269 |
|
|
null, null, outputDirectory);
|
| 270 |
|
|
if (!b.run(files))
|
| 271 |
|
|
System.exit(1);
|
| 272 |
|
|
}
|
| 273 |
|
|
}
|
| 274 |
|
|
|
| 275 |
|
|
/**
|
| 276 |
|
|
* The RMI compiler entry point.
|
| 277 |
|
|
*/
|
| 278 |
|
|
public static void main(String[] args)
|
| 279 |
|
|
{
|
| 280 |
|
|
Main rmicprogram = new Main();
|
| 281 |
|
|
try
|
| 282 |
|
|
{
|
| 283 |
|
|
rmicprogram.run(args);
|
| 284 |
|
|
}
|
| 285 |
|
|
catch (Exception e)
|
| 286 |
|
|
{
|
| 287 |
|
|
System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
|
| 288 |
|
|
e.printStackTrace(System.err);
|
| 289 |
|
|
System.exit(1);
|
| 290 |
|
|
}
|
| 291 |
|
|
}
|
| 292 |
|
|
|
| 293 |
|
|
}
|