costin      02/05/06 15:53:18

  Modified:    jk/java/org/apache/jk/apr AprImpl.java
  Log:
  Added a flag to indicate if we are loaded from jni.
  
  Use mod_jk.so ( which includes all the functions we need, including the jni
  stuff ) if in-process. ( XXX need to make this configurable or try to
  detect IIS - when Nacho gets IIS working with JNI we can fix it ).
  
  JNI code is used for in-process worker and also for unix socket and
  to register tomcat.
  
  I also removed the load() for apr, there is no way to make this work
  in JDK1.4 unless we compile jkjni with -lapr -lcrypt.
  
  Tested jkjni with all VMs I have ( except 1.1 - this is not supported with 1.1),
  seesm to work fine with all.
  
  Revision  Changes    Path
  1.13      +46 -20    jakarta-tomcat-connectors/jk/java/org/apache/jk/apr/AprImpl.java
  
  Index: AprImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/apr/AprImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AprImpl.java      25 Apr 2002 18:17:24 -0000      1.12
  +++ AprImpl.java      6 May 2002 22:53:18 -0000       1.13
  @@ -17,7 +17,7 @@
       String aprHome;
       String soExt="so";
   
  -    boolean ok=true;
  +    static boolean ok=true;
       // Handlers for native callbacks
       Hashtable jkHandlers=new Hashtable();
   
  @@ -209,6 +209,12 @@
       public boolean isLoaded() {
           return ok;
       }
  +
  +    static boolean jniMode=false;
  +    
  +    public static void jniMode() {
  +        jniMode=true;
  +    }
       
       /** This method of loading the libs doesn't require setting
        *   LD_LIBRARY_PATH. Assuming a 'right' binary distribution,
  @@ -224,29 +230,49 @@
       public void loadNative() throws Throwable {
           if( aprHome==null )
               aprHome=baseDir;
  -        if( aprHome==null ) {
  -            // Use load()
  +
  +        // XXX Update for windows
  +        if( jniMode ) {
  +            /* In JNI mode we use mod_jk for the native functions.
  +               This seems the cleanest solution that works with multiple
  +               VMs.
  +            */
               try {
  -                System.loadLibrary( "apr" );
  -                System.loadLibrary( "jkjni" );
  +                System.out.println("Loading mod_jk.so");
  +                System.load( "/opt/apache2/modules/mod_jk2.so" );
               } catch( Throwable ex ) {
  -                ok=false;
  -                throw ex;
  +                // ignore
  +                ex.printStackTrace();
  +                return;
               }
  -        } else {
  -            File dir=new File(aprHome);
  -            // XXX platform independent, etc...
  -            File apr=new File( dir, "libapr." + soExt );
  -            
  -            loadNative( apr.getAbsolutePath() );
  -            
  -            dir=new File(baseDir);
  -            File jniConnect=new File( dir, "jni_connect." + soExt );
  -            
  -            loadNative( jniConnect.getAbsolutePath() );
  +            ok=true;
  +            return;
           }
  -    }
  -    
  +        
  +            /*
  +              jkjni _must_ be linked with apr and crypt -
  +              this seem the only ( decent ) way to support JDK1.4 and
  +              JDK1.3 at the same time
  +              try {
  +                  System.loadLibrary( "crypt" );
  +              } catch( Throwable ex ) {
  +                  // ignore
  +                  ex.printStackTrace();
  +              }
  +              try {
  +                  System.loadLibrary( "apr" );
  +              } catch( Throwable ex ) {
  +                  System.out.println("can't load apr, that's fine");
  +                  ex.printStackTrace();
  +              }
  +            */
  +        try {
  +            System.loadLibrary( "jkjni" );
  +        } catch( Throwable ex ) {
  +            ok=false;
  +            throw ex;
  +        }
  +    } 
       
       public void loadNative(String libPath) {
           try {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to