db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/jdo/jdoql Type.java
Date Fri, 11 Mar 2005 19:05:18 GMT
mkalen      2005/03/11 11:05:18

  Modified:    src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
               src/java/org/apache/ojb/broker/platforms
                        PlatformFactory.java
               src/java/org/apache/ojb/broker/util ClassHelper.java
               src/java/org/apache/ojb/jdo/jdoql Type.java
  Log:
  Merge with OJB_1_0_RELEASE branch: As suggested by Andres Clute: to avoid problems in J2EE-environments,
always use the ClassLoader as specified by the semantics of ClassHelper. Add system default
class loader as last resort in ClassHelper (thread's loader is null in some JNI scenarios).
  
  Revision  Changes    Path
  1.101     +2 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- ClassDescriptor.java	25 Jan 2005 20:23:43 -0000	1.100
  +++ ClassDescriptor.java	11 Mar 2005 19:05:18 -0000	1.101
  @@ -1532,7 +1532,7 @@
           {
               try
               {
  -                Class clazz = Class.forName(newClass);
  +                Class clazz = ClassHelper.getClass(newClass);
                   setFactoryClass(clazz);
               }
               catch (Exception e)
  
  
  
  1.8       +2 -2      db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformFactory.java
  
  Index: PlatformFactory.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlatformFactory.java	11 Aug 2004 00:41:49 -0000	1.7
  +++ PlatformFactory.java	11 Mar 2005 19:05:18 -0000	1.8
  @@ -53,7 +53,7 @@
               try
               {
                   platformName = getClassnameFor(dbms);
  -                Class platformClass = Class.forName(platformName);
  +                Class platformClass = ClassHelper.getClass(platformName);
                   result = (Platform) platformClass.newInstance();
               }
               catch (Throwable t)
  
  
  
  1.14      +25 -4     db-ojb/src/java/org/apache/ojb/broker/util/ClassHelper.java
  
  Index: ClassHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/ClassHelper.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ClassHelper.java	15 Nov 2004 17:29:14 -0000	1.13
  +++ ClassHelper.java	11 Mar 2005 19:05:18 -0000	1.14
  @@ -73,13 +73,34 @@
       /**
        * Returns the class loader currently used by OJB. Defaults to the class loader of
        * the current thread (<code>Thread.currentThread().getContextClassLoader()</code>)
  -     * if not set differently.
  -     * 
  +     * if not set differently. If class loader is not explicitly set and the loader for
  +     * the current thread context is null, the JVM default class loader will be used.
  +     *
        * @return The classloader used by OJB
  +     * @see #setClassLoader(ClassLoader)
        */
       public static ClassLoader getClassLoader()
       {
  -        return _classLoader == null ? Thread.currentThread().getContextClassLoader() :
_classLoader;
  +        final ClassLoader ojbClassLoader;
  +        if (_classLoader != null)
  +        {
  +            ojbClassLoader = _classLoader;
  +        }
  +        else
  +        {
  +            final ClassLoader threadCtxtClassLoader;
  +            threadCtxtClassLoader = Thread.currentThread().getContextClassLoader();
  +            if (threadCtxtClassLoader == null)
  +            {
  +                // mkalen: happens only in "obscure" situations using JNI, revert to system
CL
  +                ojbClassLoader = ClassLoader.getSystemClassLoader();
  +            }
  +            else
  +            {
  +                ojbClassLoader = threadCtxtClassLoader;
  +            }
  +        }
  +        return ojbClassLoader;
       }
   
       /**
  
  
  
  1.4       +4 -1      db-ojb/src/java/org/apache/ojb/jdo/jdoql/Type.java
  
  Index: Type.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/jdoql/Type.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Type.java	23 May 2004 12:02:29 -0000	1.3
  +++ Type.java	11 Mar 2005 19:05:18 -0000	1.4
  @@ -1,5 +1,7 @@
   package org.apache.ojb.jdo.jdoql;
   
  +import org.apache.ojb.broker.util.ClassHelper;
  +
   /* Copyright 2003-2004 The Apache Software Foundation
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
  @@ -48,9 +50,10 @@
        */
       private void resolvePrimitiveType()
       {
  +        final ClassLoader loader = ClassHelper.getClassLoader();
           try
           {
  -            _type = Class.forName(_name);
  +            _type = Class.forName(_name, true, loader);
           }
           catch (ClassNotFoundException ex)
           {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message