db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata MetadataManager.java
Date Mon, 04 Aug 2003 11:19:32 GMT
arminw      2003/08/04 04:19:32

  Modified:    src/java/org/apache/ojb/broker/metadata MetadataManager.java
  Log:
  patch by Ilkka:
  do not make deep copy of descriptors
  when using
  mergeConnectionRepository(ConnectionRepository repository)
  mergeDescriptorRepository(DescriptorRepository repository)
  Ilkka wrote:
  
  In RC4, mergeDescriptorRepository(repository) calls internally a new
  mergeDescriptorRepository(target, source, deep) method with the deep
  option set to true. The deep option invokes serialization through
  Commmons' SerializationUtils using the ObjectInputStream class, which in
  turn calls Class.forName(name) with the default class loader to resolve
  classes. However, the ClassHelper, which has parsed the original XML of
  the source repository, resolves classes with the context class loader
  returned by Thread.getContextClassLoader(), which can be different from
  the default class loader. If the class is only defined by the context
  class loader, the attempt to serialize it will throw ClassNotFoundException.
  
  This can be avoided by calling the new method explicitly with the deep
  option set to false, but maybe a note in javadoc should be added.
  
  Revision  Changes    Path
  1.11      +29 -19    db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
  
  Index: MetadataManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MetadataManager.java	24 May 2003 00:56:38 -0000	1.10
  +++ MetadataManager.java	4 Aug 2003 11:19:32 -0000	1.11
  @@ -93,8 +93,8 @@
    * <li>{@link #removeProfile removeProfile} remove a persistent object metadata profiles</li>
    * <li>{@link #loadProfile loadProfile} load a profile for the current thread</li>
    * </ul>
  - * Note: This only works if the <a href="#enablePerThreadMode">per thread mode</a>
is
  - * enabled.
  + * Note: method {@link #loadProfile loadProfile} only works if
  + * the <a href="#enablePerThreadMode">per thread mode</a> is enabled.
    * </p>
    *
    *
  @@ -131,7 +131,7 @@
           catch (Exception e)
           {
               throw new MetadataException(
  -                    "Could not read repository class descriptor data, using repository:
" + repository, e);
  +                    "Can not read repository class descriptor data, using repository: "
+ repository, e);
           }
           try
           {
  @@ -140,7 +140,7 @@
           catch (Exception e)
           {
               throw new MetadataException(
  -                    "Could not read jdbc-connection-descriptor data, using repository:
" + repository, e);
  +                    "Can not read jdbc-connection-descriptor data, using repository: "
+ repository, e);
           }
       }
   
  @@ -203,18 +203,23 @@
       }
   
       /**
  -     * Merge the given {@link ConnectionRepository} (make deep copy of containing objects)
  -     * with the existing one.
  +     * Merge the given {@link ConnectionRepository} with the existing one (without making
  +     * a deep copy of the containing connection descriptors).
  +     * @see #mergeConnectionRepository(ConnectionRepository targetRepository, ConnectionRepository
sourceRepository, boolean deep)
        */
       public void mergeConnectionRepository(ConnectionRepository repository)
       {
  -        mergeConnectionRepository(connectionRepository(), repository, true);
  +        mergeConnectionRepository(connectionRepository(), repository, false);
       }
   
       /**
        * Merge the given source {@link ConnectionRepository} with the
        * existing target. If parameter
        * <tt>deep</tt> is set <code>true</code> deep copies of source
objects were made.
  +     * <br/>
  +     * Note: Using <tt>deep copy mode</tt> all descriptors will be serialized
  +     * by using the default class loader to resolve classes. This could be problematic
  +     * when classes load by a context class loader.
        */
       public void mergeConnectionRepository(
               ConnectionRepository targetRepository, ConnectionRepository sourceRepository,
boolean deep)
  @@ -234,23 +239,28 @@
   
       /**
        * Merge the given {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  -     * (make deep copy of containing objects) with the global one, returned
  -     * by method {@link #getRepository()} - keep
  +     * (without making a deep copy of containing class-descriptor objects) with the
  +     * global one, returned by method {@link #getRepository()} - keep
        * in mind if running in <a href="#perThread">per thread mode</a>
        * merge maybe only takes effect on current thread.
        *
  +     * @see mergeDescriptorRepository(DescriptorRepository targetRepository, DescriptorRepository
sourceRepository, boolean deep)
        * @see #isEnablePerThreadChanges
        * @see #setEnablePerThreadChanges
        */
       public void mergeDescriptorRepository(DescriptorRepository repository)
       {
  -        mergeDescriptorRepository(getRepository(), repository, true);
  +        mergeDescriptorRepository(getRepository(), repository, false);
       }
   
       /**
        * Merge the given {@link org.apache.ojb.broker.metadata.DescriptorRepository}
        * files, the source objects will be pushed to the target repository. If parameter
        * <tt>deep</tt> is set <code>true</code> deep copies of source
objects were made.
  +     * <br/>
  +     * Note: Using <tt>deep copy mode</tt> all descriptors will be serialized
  +     * by using the default class loader to resolve classes. This could be problematic
  +     * when classes load by a context class loader.
        */
       public void mergeDescriptorRepository(
               DescriptorRepository targetRepository, DescriptorRepository sourceRepository,
boolean deep)
  @@ -282,7 +292,7 @@
           }
           catch (Exception e)
           {
  -            throw new MetadataException("Could not read repository " + fileName, e);
  +            throw new MetadataException("Can not read repository " + fileName, e);
           }
       }
   
  @@ -299,7 +309,7 @@
           }
           catch (Exception e)
           {
  -            throw new MetadataException("Could not read repository " + inst, e);
  +            throw new MetadataException("Can not read repository " + inst, e);
           }
       }
   
  @@ -317,7 +327,7 @@
           }
           catch (Exception e)
           {
  -            throw new MetadataException("Could not read repository " + fileName, e);
  +            throw new MetadataException("Can not read repository " + fileName, e);
           }
       }
   
  @@ -335,7 +345,7 @@
           }
           catch (Exception e)
           {
  -            throw new MetadataException("Could not read repository from " + inst, e);
  +            throw new MetadataException("Can not read repository from " + inst, e);
           }
       }
   
  @@ -426,9 +436,9 @@
        */
       public void addProfile(Object key, DescriptorRepository repository)
       {
  -        if(metadataProfiles.contains(key))
  +        if (metadataProfiles.contains(key))
           {
  -            throw new MetadataException("Duplicate profile key. Key '"+key+"' already exists.");
  +            throw new MetadataException("Duplicate profile key. Key '" + key + "' already
exists.");
           }
           metadataProfiles.put(key, repository);
       }
  @@ -441,12 +451,12 @@
       {
           if (!isEnablePerThreadChanges())
           {
  -            throw new MetadataException("Could not load profile with disabled per thread
mode");
  +            throw new MetadataException("Can not load profile with disabled per thread
mode");
           }
           DescriptorRepository rep = (DescriptorRepository) metadataProfiles.get(key);
           if (rep == null)
           {
  -            throw new MetadataException("Could not find profile for key '" + key+"'");
  +            throw new MetadataException("Can not find profile for key '" + key + "'");
           }
           setDescriptor(rep);
       }
  
  
  

---------------------------------------------------------------------
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