diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java | 9 | ||||
-rw-r--r-- | examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java | 7 | ||||
-rw-r--r-- | gnu/CORBA/IOR.java | 54 | ||||
-rwxr-xr-x | tools/Makefile.am | 4 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/HelpPrinter.java | 99 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/GRMIC.java | 55 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/IorParser.java | 125 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/IorParser.txt | 10 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/NameService.java | 75 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/NamingService.txt | 21 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/giop/README | 10 |
13 files changed, 435 insertions, 56 deletions
@@ -1,3 +1,21 @@ +2006-02-08 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java, + examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java: + Documenting the code generator. + * gnu/CORBA/IOR.java (toStringFormatted, + CodeSet_component.toStringFormatted): New methods. + * tools/Makefile.am (TOOLS_JAVA_FILES, READMES): Rewritten. + * tools/gnu/classpath/tools/giop/README: Rewritten. + * tools/gnu/classpath/tools/giop/GRMIC.java (main): Rewritten. + (printHelpAndExit): Removed. + *tools/gnu/classpath/tools/giop/IorParser.java, + tools/gnu/classpath/tools/giop/IorParser.txt, + tools/gnu/classpath/tools/giop/NameService.java, + tools/gnu/classpath/tools/giop/NamingService.txt, + tools/gnu/classpath/tools/HelpPrinter.java: New files. + NEWS: Added note about GIOP tools. + 2006-02-07 Audrius Meskauskas <AudriusA@Bioinformatics.org> * .classpath: New source patch (tools). @@ -6,6 +6,10 @@ New in release 0.21 (to be released) 3 and TLS version 1. These roughly complement the public `java.security.' `javax.crypto,' and `javax.net.ssl' packages, and are service providers implementing the underlying algorithms. + + * The new folder tools now contains GIOP tools, providing necessary support + for development using org.omg.* and javax.rmi.CORBA.* packages: GIOP + stub and tie code generator, IOR parser and naming service. New in release 0.20 (Jan 13, 2006) diff --git a/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java b/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java index 17a62600c..a0c33df34 100644 --- a/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java +++ b/examples/gnu/classpath/examples/CORBA/swing/x5/_GameManagerImpl_Tie.java @@ -57,13 +57,8 @@ import org.omg.PortableServer.Servant; * Tie on the client side. The Game Manager methods contain the code for remote * invocation. * - * This class is normally generated with rmic from the {@link GameManagerImpl}: - * - * <pre> - * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.GameManagerImpl - * </pre> - * - * (the compiled package must be present in the current folder). + * This class is normally generated with rmic or grmic from the + * {@link GameManagerImpl}. See tools/gnu/classpath/tools/giop/README. * * In this example the class was manually edited and commented for better * understanding of functionality. diff --git a/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java b/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java index 730c6f469..f6c5f4765 100644 --- a/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java +++ b/examples/gnu/classpath/examples/CORBA/swing/x5/_PlayerImpl_Tie.java @@ -58,11 +58,8 @@ import org.omg.PortableServer.Servant; * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl * (the compiled package must be present in the current folder). * - * This class is normally generated with rmic from the {@link PlayerImpl}: - * <pre> - * rmic -iiop -poa -keep gnu.classpath.examples.CORBA.swing.x5.PlayerImpl - * </pre> - * (the compiled package must be present in the current folder). + * This class is normally generated with rmic or grmic from the + * {@link PlayerImpl}. See tools/gnu/classpath/tools/giop/README. * * In this example the class was manually edited and commented for better * understanding of functionality. diff --git a/gnu/CORBA/IOR.java b/gnu/CORBA/IOR.java index 5d6d3152f..917e19832 100644 --- a/gnu/CORBA/IOR.java +++ b/gnu/CORBA/IOR.java @@ -140,6 +140,27 @@ public class IOR b.append(' '); return b.toString(); } + + /** + * Get a better formatted multiline string representation. + */ + public String toStringFormatted() + { + StringBuffer b = new StringBuffer(); + b.append("\n Native set " + name(native_set)); + if (conversion != null && conversion.length > 0) + { + b.append("\n Other supported sets:\n "); + for (int i = 0; i < conversion.length; i++) + { + b.append(name(conversion[i])); + b.append(' '); + } + } + b.append("\n"); + return b.toString(); + } + /** * Write into CDR stream. @@ -590,6 +611,39 @@ public class IOR return b.toString(); } + + /** + * Returns a multiline formatted human readable string representation of + * this IOR object. + */ + public String toStringFormatted() + { + StringBuffer b = new StringBuffer(); + b.append("\nObject Id:\n "); + b.append(Id); + b.append("\nObject is accessible at:\n "); + b.append(Internet); + + if (Big_Endian) + b.append("\n Big endian encoding"); + else + b.append("\n Little endian encoding."); + + b.append("\nObject Key\n "); + + for (int i = 0; i < key.length; i++) + { + b.append(Integer.toHexString(key[i] & 0xFF)); + } + + b.append("\nSupported code sets:"); + b.append("\n Wide:"); + b.append(Internet.CodeSets.wide.toStringFormatted()); + b.append(" Narrow:"); + b.append(Internet.CodeSets.wide.toStringFormatted()); + + return b.toString(); + } /** * Returs a stringified reference. diff --git a/tools/Makefile.am b/tools/Makefile.am index d1e40b8e9..038fed282 100755 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -20,7 +20,7 @@ endif endif # All our example java source files -TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java +TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java # The zip files with classes we want to produce. @@ -34,7 +34,7 @@ TOOLS_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav TOOLS_HELPS = $(srcdir)/gnu/classpath/tools/giop/*.txt # The tool specific README files. -READMES = $(srcdir)/gnu/classpath/tools/giop/README.txt +READMES = $(srcdir)/gnu/classpath/tools/giop/README # All the files we find "interesting" ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(TOOLS_TEMPLATES) $(READMES) diff --git a/tools/gnu/classpath/tools/HelpPrinter.java b/tools/gnu/classpath/tools/HelpPrinter.java new file mode 100644 index 000000000..61a3e683b --- /dev/null +++ b/tools/gnu/classpath/tools/HelpPrinter.java @@ -0,0 +1,99 @@ +/* HelpPrinter -- help message printer + Copyright (C) 2006 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.tools; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * The shared class to print the help message and exit, when applicable. + * Support the --help key. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class HelpPrinter +{ + /** + * Check for the --help, -help and -? keys. If one is found, print help and + * exit the program. + * + * @param args the program arguments. + * @param helpResourcePath the path to the help resource, related to the + * HelpPrinter class. + */ + public static void checkHelpKey(String[] args, String helpResourcePath) + { + for (int i = 0; i < args.length; i++) + { + String a = args[i]; + if (a.equals("-?") || a.equalsIgnoreCase("-help") + || a.equalsIgnoreCase("--help")) + printHelpAndExit(helpResourcePath); + } + } + + /** + * Prints the help message and terminates. + * + * @param helpResourcePath the path to the help resource, related to the + * HelpPrinter class. + */ + public static void printHelpAndExit(String helpResourcePath) + { + InputStream in = HelpPrinter.class.getResourceAsStream(helpResourcePath); + BufferedReader r = new BufferedReader(new InputStreamReader(in)); + + try + { + String s; + while ((s = r.readLine()) != null) + { + System.out.println(s); + } + r.close(); + } + catch (IOException e) + { + System.err.print("Resource loading is broken:"); + e.printStackTrace(); + } + System.exit(0); + } +} diff --git a/tools/gnu/classpath/tools/giop/GRMIC.java b/tools/gnu/classpath/tools/giop/GRMIC.java index 89bc46a62..16ff96f56 100644 --- a/tools/gnu/classpath/tools/giop/GRMIC.java +++ b/tools/gnu/classpath/tools/giop/GRMIC.java @@ -37,14 +37,12 @@ exception statement from your version. */ package gnu.classpath.tools.giop; +import gnu.classpath.tools.HelpPrinter; import gnu.classpath.tools.giop.grmic.GiopRmicCompiler; -import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; /** @@ -63,25 +61,28 @@ public class GRMIC /** * The GRMIC compiler methods * - * @param args - * the compiler parameters. + * @param args the compiler parameters. */ public static void main(String[] args) { boolean noWrite = false; boolean verbose = false; + String HelpPath = "giop/GRMIC.txt"; + + HelpPrinter.checkHelpKey(args, HelpPath); + File output = new File("."); if (args.length == 0) { - printHelpAndExit(); + HelpPrinter.printHelpAndExit(HelpPath); } else { GiopRmicCompiler compiler = new GiopRmicCompiler(); - int cl = -1; + int cl = - 1; Options: for (int i = 0; i < args.length; i++) { @@ -95,8 +96,6 @@ public class GRMIC printVersion(); System.exit(0); } - else if (c.equals("-help")) - printHelpAndExit(); else if (c.equals("-nowrite")) noWrite = true; else if (c.equals("-nowarn")) @@ -115,7 +114,7 @@ public class GRMIC i++; } else - printHelpAndExit(); + HelpPrinter.printHelpAndExit(HelpPath); } else if (c.charAt(0) != '-') // No more options - start of class list. @@ -126,7 +125,7 @@ public class GRMIC } if (cl < 0) - printHelpAndExit(); + HelpPrinter.printHelpAndExit(HelpPath); if (verbose) System.out.println("Compiling to " + output.getAbsolutePath()); @@ -156,10 +155,10 @@ public class GRMIC // Generate stub. String stub = compiler.generateStub(); String subName = "_" + compiler.getStubName() + "_Stub.java"; - + compiler.reset(); compiler.compile(c); - + // Generate tie String tie = compiler.generateTie(); String tieName = "_" + compiler.name(c) + "_Tie.java"; @@ -170,10 +169,11 @@ public class GRMIC try { fw.mkdirs(); - OutputStream out = new FileOutputStream(new File(fw, subName)); + OutputStream out = new FileOutputStream(new File(fw, + subName)); out.write(stub.getBytes()); out.close(); - + out = new FileOutputStream(new File(fw, tieName)); out.write(tie.getBytes()); out.close(); @@ -190,31 +190,6 @@ public class GRMIC } /** - * Prints the help message and terminates. - */ - public static void printHelpAndExit() - { - printVersion(); - InputStream in = GRMIC.class.getResourceAsStream("GRMIC.txt"); - BufferedReader r = new BufferedReader(new InputStreamReader(in)); - - try - { - String s; - while ((s = r.readLine()) != null) - { - System.out.println(s); - } - r.close(); - } - catch (IOException e) - { - System.err.print("Resource loading is broken:"); - e.printStackTrace(); - } - } - - /** * Print the version information. */ public static void printVersion() diff --git a/tools/gnu/classpath/tools/giop/IorParser.java b/tools/gnu/classpath/tools/giop/IorParser.java new file mode 100644 index 000000000..7d70c8aca --- /dev/null +++ b/tools/gnu/classpath/tools/giop/IorParser.java @@ -0,0 +1,125 @@ +/* IorParser.java -- IOR parser. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.classpath.tools.giop; + +import gnu.CORBA.IOR; +import gnu.classpath.tools.HelpPrinter; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.omg.CORBA.BAD_PARAM; + +/** + * Parses the information, encoded in the Interoperable Object References + * (IORs). + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class IorParser +{ + /** + * Parse and print IOR reference. The system exit code is 0 if the parsed + * IOR was correct, 1 if it was invalid or missing. + * + * @param args supports -f file to read IOR from the file. + */ + public static void main(String[] args) + { + boolean ok = false; + String HelpResource = "giop/IorParser.txt"; + HelpPrinter.checkHelpKey(args, HelpResource); + if (args.length == 0) + HelpPrinter.printHelpAndExit(HelpResource); + else if (args[0].equals("-f") && args.length==2) + { + File file = new File(args[1]); + if (!file.exists()) + System.err.println("The file "+file.getAbsolutePath()+" is missing."); + // Read IOR reference from file. + String ior = null; + try + { + FileReader fr = new FileReader(file); + BufferedReader br = new BufferedReader(fr); + ior = br.readLine(); + br.close(); + ok = parseAndPrint(ior); + } + catch (IOException e) + { + System.err.print("Unable to read the file "+file); + e.printStackTrace(); + } + + } + else if (args.length == 1) + ok = parseAndPrint(args[0]); + else + HelpPrinter.printHelpAndExit(HelpResource); + + if (ok) + System.exit(0); + else + System.exit(1); + } + + /** + * Parse and print IOR. + * + * @param ior the IOR string to anlyse. + * @return true if the passed value is a valid IOR, false otherwise. + */ + public static boolean parseAndPrint(String ior) + { + try + { + IOR gior = IOR.parse(ior); + System.out.println(gior.toStringFormatted()); + return true; + } + catch (BAD_PARAM e) + { + System.out.println("Invalid ior: "+e.getMessage()); + return false; + } + } +} diff --git a/tools/gnu/classpath/tools/giop/IorParser.txt b/tools/gnu/classpath/tools/giop/IorParser.txt new file mode 100644 index 000000000..3b04224f1 --- /dev/null +++ b/tools/gnu/classpath/tools/giop/IorParser.txt @@ -0,0 +1,10 @@ +Copyright 2006 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +Please report bugs at http://www.gnu.org/software/classpath/bugs.html + +IOR (interoperable GIOP object reference) parser, + usage: IorParser -f ior_file + or: IorParser -f ior_string + diff --git a/tools/gnu/classpath/tools/giop/NameService.java b/tools/gnu/classpath/tools/giop/NameService.java new file mode 100644 index 000000000..7e13185f2 --- /dev/null +++ b/tools/gnu/classpath/tools/giop/NameService.java @@ -0,0 +1,75 @@ +/* NameService.java -- Transient GIOP naming service. + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package gnu.classpath.tools.giop; + +import gnu.CORBA.NamingService.NamingServiceTransient; +import gnu.classpath.tools.HelpPrinter; + +/** + * The implementation of the transient naming service. The naming service + * is a kind of the network server that registers local and remote objects + * by name, and later can provide the object reference in response to the + * given name. + * + * GNU Classpath currently works with this naming service and is also + * interoperable with the Sun Microsystems naming services from releases 1.3 and + * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class NameService +{ + /** + * Start the naming service on the current host at the given port. The + * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if + * present, specifies the port, on that the service must be started. If this + * key is not specified, the service starts at the port 900. + * + * The parameter -ior FILE_NAME, if present, forces to store the ior string of + * this naming service to the specified file. + * + * @param args the parameter string. + */ + public static void main(String[] args) + { + HelpPrinter.checkHelpKey(args, "giop/NamingService.txt"); + System.out.println("Please use --help for options."); + NamingServiceTransient.main(args); + } + +} diff --git a/tools/gnu/classpath/tools/giop/NamingService.txt b/tools/gnu/classpath/tools/giop/NamingService.txt new file mode 100644 index 000000000..f57e4ac66 --- /dev/null +++ b/tools/gnu/classpath/tools/giop/NamingService.txt @@ -0,0 +1,21 @@ +Copyright 2006 Free Software Foundation, Inc. +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +Please report bugs at http://www.gnu.org/software/classpath/bugs.html + +GNU Classpath GIOP naming service, usage: NameService <options> + + where <options> includes: +* -org.omg.CORBA.ORBInitialPort NNN or +* -ORBInitialPort NNN - specifies the port, on that the + service must be started. If this key + is not specified, the service starts + at the port 900. + +* -ior FILE_NAME - store the IOR reference to this naming + service to the specified file. The + IOR reference contains enough + information to locate the service + on the web. + diff --git a/tools/gnu/classpath/tools/giop/README b/tools/gnu/classpath/tools/giop/README index d02d46c34..9e3df4e21 100644 --- a/tools/gnu/classpath/tools/giop/README +++ b/tools/gnu/classpath/tools/giop/README @@ -2,6 +2,12 @@ This package defines GIOP tools for creating the applications that use this protocol. It provides necessary support for org.omg.* and javax.rmi.* packages. -The list of tools: +All GIOP tools support the --help option. -* GRMIC - RMI-IIOP stub and tie generator.
\ No newline at end of file +The list of the currently available tools: + +* GRMIC - RMI-IIOP stub and tie generator. +* NameService - GIOP naming service (currently transient, but the + persistent fuctionality may be added in the future). +* IorParser - Parses the stringified form of the interoperable + object references (IOR's).
\ No newline at end of file |