ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry V. Streepy, Jr." <stre...@healthlanguage.com>
Subject PATCH to Rmic.java
Date Wed, 13 Jun 2001 17:41:11 GMT
In case anyone wants the rmic task to properly handle the IIOP
stub naming conventions, I'm posting this patch to the released
version 1.3 Rmic.java file.

Now the task will properly generate the IIOP class name (with the
prepended "_").

Here is the patch:

Index: cplusle/thirdparty/jakarta-ant-1.3/src/main/org/apache/tools/ant/taskdefs/Rmic.java
diff -c cplusle/thirdparty/jakarta-ant-1.3/src/main/org/apache/tools/ant/taskdefs/Rmic.java:1.1
cplusle/thirdparty/jakarta-ant-1.3/src/main/org/apache/tools/ant/taskdefs/Rmic.java:1.2
*** cplusle/thirdparty/jakarta-ant-1.3/src/main/org/apache/tools/ant/taskdefs/Rmic.java:1.1
Mon May 28 09:15:41 2001
--- cplusle/thirdparty/jakarta-ant-1.3/src/main/org/apache/tools/ant/taskdefs/Rmic.java	Wed
Jun 13 11:33:18 2001
***************
*** 388,407 ****
       */
      private class RmicFileNameMapper implements FileNameMapper {
  
!         private GlobPatternMapper stubMapper;
!         private GlobPatternMapper skelMapper;
  
          RmicFileNameMapper() {
-             stubMapper = new GlobPatternMapper();
-             stubMapper.setFrom("*.class");
-             stubMapper.setTo("*_Stub.class");
- 
-             // no _Skel file in stub version 1.2
-             if (!"1.2".equals(stubVersion)) {
-                 skelMapper = new GlobPatternMapper();
-                 skelMapper.setFrom("*.class");
-                 skelMapper.setTo("*_Skel.class");
-             }
          }
  
          /**
--- 388,396 ----
       */
      private class RmicFileNameMapper implements FileNameMapper {
  
!         private boolean makeSkel = "1.2".equals(stubVersion);
  
          RmicFileNameMapper() {
          }
  
          /**
***************
*** 414,428 ****
          public void setTo(String s) {}
  
          public String[] mapFileName(String name) {
!             String[] stubName = stubMapper.mapFileName(name);
  
!             if (stubName == null || name.endsWith("_Stub.class") 
                  || name.endsWith("_Skel.class")) {
                  // Not a .class file
                  return null;
              }
  
!             String classname = name.replace(File.separatorChar, '.');
              classname = classname.substring(0, classname.indexOf(".class"));
              if (verify) {
                  try {
--- 403,422 ----
          public void setTo(String s) {}
  
          public String[] mapFileName(String name) {
! 
!             // Ensure it's a class file and not a stub/skel class
  
!             if( ! name.endsWith(".class") || name.endsWith("_Stub.class") 
                  || name.endsWith("_Skel.class")) {
                  // Not a .class file
                  return null;
              }
+ 
+             // Now generate the proper stub file name
+             String stubName = iiop ? makeIIOPName( name, "_Stub" )
+                                    : makeRMIName( name, "_Stub" );
  
!             String classname = stubName.replace(File.separatorChar, '.');
              classname = classname.substring(0, classname.indexOf(".class"));
              if (verify) {
                  try {
***************
*** 441,454 ****
                  }
              }
  
!             if (skelMapper != null) {
                  return new String[] {
!                     stubName[0], 
!                     skelMapper.mapFileName(name)[0]
                  };
              } else {
!                 return stubName;
              }
          }
  
          /**
--- 435,504 ----
                  }
              }
  
!             if( makeSkel ) {
!                 String skelName = iiop ? makeIIOPName( name, "_Skel" )
!                                        : makeRMIName( name, "_Skel" );
                  return new String[] {
!                     stubName,
!                     skelName
                  };
+             } else {
+                 return new String[] { stubName };
+             }
+         }
+ 
+         /**
+          * Deal with IIOP stub naming convention, which is to prepend an
+          * underscore to the file name.  It is assumed that the input name
+          * ends in ".class".
+          *
+          * @param name The file name to process
+          * @param stubOrSkel The file name suffix to use
+          * @return String Generated IIOP class name
+          */
+         private String makeIIOPName( String name, String stubOrSkel ) {
+ 
+             // Just cut off the trailing ".class"
+             name = name.substring( 0, name.length() - 6 );
+ 
+             StringBuffer iiopName = new StringBuffer();
+ 
+             // Locate the trailing dir sep character
+             int index = name.lastIndexOf( File.separatorChar );
+             if( index >= 0 ) {
+                 iiopName.append( name.substring(0,index+1) );
+                 index += 1;
              } else {
!                 index = 0;
              }
+ 
+             iiopName.append( '_' );             // Leading '_' for IIOP name
+             iiopName.append( name.substring(index) );   // Add base class name
+ 
+             iiopName.append( stubOrSkel ).append( ".class" );
+ 
+             return iiopName.toString();
+         }
+ 
+         /**
+          * Deal with RMI stub naming convention.  This is a simple mapping to add
+          * _Stub or _Skel after the base class name. It is assumed that the input
+          * name ends in ".class".
+          *
+          * @param name The file name to process
+          * @param stubOrSkel The file name suffix to use
+          * @return String Generated RMI class name
+          */
+         private String makeRMIName( String name, String stubOrSkel ) {
+ 
+             // Cut off trailing ".class"
+ 
+             StringBuffer rmiName =
+                 new StringBuffer( name.substring( 0, name.length() - 6 ) );
+ 
+             rmiName.append( stubOrSkel ).append( ".class" );
+ 
+             return rmiName.toString();
          }
  
          /**


-- 
Larry V. Streepy, Jr.
Chief Technical Officer and VP of Engineering

Health Language, Inc.  -- "We speak the language of healthcare"

970/626-5028 (office)           mailto:streepy@healthlanguage.com
970/626-4425 (fax)              http://www.healthlanguage.com

Mime
View raw message