View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.utils;
9   
10  import java.io.File;
11  
12  import it.imolinfo.jbi4corba.Logger;
13  import it.imolinfo.jbi4corba.LoggerFactory;
14  
15  /**
16   * An utility  for generation of java from IDL
17   * 
18   * 
19   * @author <a href="mailto:lacquaviva@imolinfo.it">Luca Acquaviva</a>
20   */
21  public class HelperIDLJUtil {
22      
23       /**
24       * Logger.
25       */
26      private static final Logger LOG = LoggerFactory.getLogger(HelperIDLJUtil.class);
27      
28      
29      
30      /**
31       * idlj generates Java bindings from a given IDL file.
32       *
33       * Syntax: idlj [ options ] idl-file
34       *
35       * options:
36       * -fall    generate both client and server-side bindings.
37       * -td        emit files to a directory other than the current directory
38       * -i        include directory
39       *
40       * @param    targetdir    The directory where the java files will be placed.
41       * @param    includedir   The directory to find include files.
42       * @param    idlFilename The IDL file to compile.
43       *
44       * @see    http://java.sun.com/j2se/1.5.0/docs/guide/rmi-iiop/toJavaPortableUG.html
45       */
46      public static void idlj(final String targetdir,final String includedir,final String idlFilename) {
47          //Added for the creation of idl withoud Modules
48          File tdir=new File(targetdir);
49          // this is necessary for the correct generation from an idl without module
50          if(!tdir.exists()){
51          	
52          		tdir.mkdir();
53  			
54          }
55          com.sun.tools.corba.se.idl.toJavaPortable.Compile.main(
56                  new String[]{"-emitAll",
57                      "-fall",
58                      "-td",
59                      targetdir, // workdirsrc
60                      "-i",
61                      includedir,
62                      idlFilename
63                  });
64  
65          LOG.debug("<<<<< idlj - end");
66      }
67  
68      /**
69       * idlj generates Java bindings from a given IDL file.
70       *
71       * Syntax: idlj [ options ] idl-file
72       *
73       * options:
74       * -fallTIE		generate both client and server-side bindings and xxxPOATie class.
75       * -td			emit files to a directory other than the current directory
76       * -i        	include directory
77       *
78       * @param    targetdir    The directory where the java files will be placed.
79       * @param    includedir   The directory to find include files.
80       * @param    idlFilename The IDL file to compile.
81       *
82       * @see    http://java.sun.com/j2se/1.5.0/docs/guide/rmi-iiop/toJavaPortableUG.html
83       */
84      public static void idljPoaTie(final String targetdir,final String includedir,final String idlFilename) {
85          LOG.debug(">>>>> idlj - begin");
86  
87          com.sun.tools.corba.se.idl.toJavaPortable.Compile.main(
88                  new String[]{"-emitAll",
89                      "-fallTIE",
90                      "-td",
91                      targetdir, // workdirsrc
92                      "-i",
93                      includedir,
94                      idlFilename
95                  });
96  
97          LOG.debug("<<<<< idlj - end");
98      }
99      
100 
101 }