Changes between Initial Version and Version 1 of uka.transport/Generator


Ignore:
Timestamp:
08/22/05 09:05:02 (8 years ago)
Author:
hauma
Comment:

From legacy page.

Legend:

Unmodified
Added
Removed
Modified
  • uka.transport/Generator

    v1 v1  
     1= Automatic generation of marshaling methods =  
     2 
     3[[TracNav]] 
     4Since it is an extremely boring task to write marshal and unmarshal methods, there is a tool that enables automatic generation of this code. 
     5 
     6Assume you would like to enhance class Param from the beginning with fast marshaling. After you have compiled it to a class file, you can invoke the marshaling code generator with the following command: 
     7 
     8{{{ 
     9javaparty retro TParam 
     10}}} 
     11 
     12 
     13This produces a file called TParam.h in the current directory. This file contains all necessary declarations to make the class transportable. 
     14 
     15 * Insert all declarations from file TParam.h into the original source code of class TParam. 
     16 * Declare class TParam public. 
     17 * Replace java.io.Serializable by uka.transport.Transportable in the implements clause. Since Transportable extends Serializable you do not need both declarations for use of either the regular serialization or the fast marshaling. 
     18 
     19For a quick start on SuSE Linux 8.0 with tcsh, you can copy and paste the following commands to your shell to see the transport generator at work: 
     20 
     21{{{ 
     22mkdir transport 
     23cd transport 
     24cat > Param.java <<EOF 
     25public class Param implements java.io.Serializable { 
     26   int    intValue; 
     27   float  floatValue; 
     28   Object objectReference; 
     29} 
     30EOF 
     31mkdir classes 
     32javac -d classes Param.java 
     33javaparty -cp classes retro Param 
     34ls -las 
     35}}} 
     36 
     37On other unix systems, the above should work as well. On Windows, there is no convenient wrapper invocation script 'javaparty', so you have to invoke the generator by hand and care about the location of the JavaParty related jar files: 
     38 
     39{{{ 
     40java -classpath jpc.jar;jp.jar;karmi.jar;%CLASSPATH% 
     41      gjc.v6.RetroTransport TParam 
     42}}} 
     43 
     44Anyway, you should get output similar to the following: 
     45 
     46{{{ 
     47drwxr-xr-x    3 user    group          107 May  6 15:28 ./ 
     48drwxr-xr-x    3 user    group           60 May  6 15:28 ../ 
     49-rw-r--r--    1 user    group         2381 May  6 15:28 Param.h 
     50-rw-r--r--    1 user    group          124 May  6 15:28 Param.java 
     51drwxr-xr-x    2 user    group           62 May  6 15:28 classes/ 
     52}}} 
     53 
     54The file Param.java contains the original class, and the Param.h contains the additional methods, that must be inserted into Param.java to get the fast marshaling functionality. Do not forget to also change the implements declaration and the visibility modifier of the class as denoted above.  
     55