In order for .NET clients to access Java objects using J-Integra for .NET, proxies must be generated from these Java objects and packaged into a .NET assembly. This .NET assembly in turn is deployed on the .NET platform to be referenced by the clients. The GenNet development tool is a pure Java tool that invokes GenService to generate such proxies. This section describes how to generate .NET proxy files using GenNet.
When reading this section, keep in mind the following important details:
GenNet reads a settings file in order to know what proxies to generate, and where to output the .NET assembly to. By default, this file is called gennet.xml and loaded from the same directory where GenNet is launched. A different filename can be specified (see below).
Because the actual proxy generation is done by GenService, J-Integra® for .NET supports remote proxy generation. That is, the .NET assembly is output to the platform where GenService is, and not where GenNet was launched.
The proxy files generated by GenNet are C# source files (.cs files) that implement classes and class members corresponding to those found in the specified Java classes. GenNet also generates an assembly (DLL) consisting of the compiled source.
Use this section as a quick reference to start GenNet.
Launch GenNet from the Start Menu.
java -jar $USER_INSTALL_DIR$\lib\gennet.jar [arguments]
Possible arguments include:
-f | -file filename
|Read settings from filename||
-n | -nogui
|Launch GenNet in non-interactive mode (see below).||
The J-Integra® for .NET runtime (janet.jar) must also be in $USER_INSTALL_DIR$\lib. The main class that is called when launching GenNet is com.intrinsyc.janet.gennet.GenNetApp.
GenNet can be started in interactive, or non-interactive mode.
When GenNet first starts, it uses IP multicast to find existing instances of GenService:
Note: Select "GenService" instead of "GenService_2.0", only if:
For details of the two GenService versions, please refer to the section Multiple Versions: Genservice & GenService 2005 in the GenService section.
Select an instance and click Next>.
If, for whatever reason, multicasting is unavailable on your network, then GenNet will fail to find any instances that aren't running locally:
If you select Enter Host Manually and click Next>, you will be prompted to manually enter a URI where GenService can be found. You should enter the following URI and click OK:
The next screen prompts for the components (JAR files or directories) to be added to the CLASSPATH. These components will be required by the Java runtime to resolve references to Java classes.
|Add Jar...||Launches the file browser dialog to add JAR or ZIP files to the CLASSPATH.|
|Add Directory...||Launches the file browser dialog to add directories to the CLASSPATH. No files will be displayed.|
|Remove...||Removes an entry in the list of components.|
The next screen prompts for the specific Java classes that will have .NET proxies generated for them. This is where the components added to the CLASSPATH in the previous step are used to resolve references to the Java classes.
Click Browse... or Add... to add your Java classes. Once one or more classes are added, the following options will appear:
|Filter...||Launches Filter Referenced Classes.|
|Browse...||Launches Browse Classes.|
|Add...||Launches Add Java Class.|
|Removes...||Removes a selected entry.|
|Options...||Launches Java Class Options.|
If this option is checked, when generating Java proxies, GenNet will generate currently available mappings when encountering types from the java.util package. For example, for java.util.Vector, it will generate System.Collections.ArrayList. However, this implies that such types passed as parameters will always be marshalled by value.
If this option is not checked, then GenNet will generate the normal remote proxy type so that there is no mapping. This implies that such types passed as parameters will always be marshalled by reference.
This must be used in conjunction with the Map Collections/Dictionaries option in Janetor.
GenNet will not only attempt to generate proxies for the listed Java classes, but also other Java classes that are referenced. The list of classes to generate could be huge, and more likely than not, you will not need to access so many Java classes from the .NET client. To solve this, GenNet provides a way for you to manually select which classes you want to be filtered out from proxy generation. Click Filter... to show:
In the screenshot above, for example, we can see that all classes from java.util will not have a proxy generated for it except for java.util.Enumeration.
Instead of adding manually, GenNet provides the option of browsing the classes found in the CLASSPATH and selecting which of these classes to generate proxies for. Click Browse... to show:
Use the CTRL or SHIFT keys to select more than one class. You can visually select the classes and click Add Selected. For each class selected, you will see an entry in the list of Java classes to generate proxies for:
You can alternatively enter the Java class manually - the full package name must be included also. The OK button is only enabled when GenNet finds the class in the CLASSPATH, otherwise, it is disabled. Click Add... to show:
If you are not sure of the class name, it is best to browse for it instead.
For Java classes that implement java.io.Serializable, there is the option to marshal that class by value. All public/private/protected fields will be generated, along with get/set methods. For such classes, click Options... to show:
Check Pass by value and click OK. You will now see that the class is now denoted as pass by value:
The name of the assembly (without the DLL extension) must match what was entered in Assembly Name of the Activation tab under the Local Objects category in Janetor.
The Browse... button will be disabled if GenService was found to be remote rather than local to the machine that GenNet was launched from.
|Generate Strong Named Assembly||
Generate a strong named assembly. Strong named assemblies are required when installing assemblies in the GAC to be referenced by COM+ (for example). See Strong-Named Assemblies for more details.
The final screen shows the output of the generation, and if there were any errors encountered:
GenNet is normally used interactively, with a graphical user interface, but it can also be run without stepping through the GUI wizard. This can be useful when GenNet is used as part of an automated build procedure, for example. To use GenNet in this non-interactive mode, GenNet must first be run in interactive mode to create a valid settings file. It can then be run again non-interactively using the same settings.
To create the settings file, simply run through the steps above and once generation has been successful and the Exit is clicked, a settings file will be created and saved to gennet.xml. If GenNet is run from Windows, then gennet.xml will be created in $USER_INSTALL_DIR$, otherwise, it will be created from wherever GenNet was launched on the command-line.
To run in non-interactive mode, GenNet must be started from the command-line. Review Starting GenNet to see how to start GenNet in non-interactive mode.
If the settings file is read and processed correctly, GenNet creates the proxies immediately and exits. All status and error messages are displayed on the console's standard output and standard error streams.