baliuka     02/03/14 08:45:02

  Modified:    simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        MetaClassImpl.java PersistentProxy.java
  Added:       simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        AutoCommitTransactionManager.java
  Log:
  Added Autocommit
  
  Revision  Changes    Path
  1.10      +5 -5      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java
  
  Index: MetaClassImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MetaClassImpl.java        14 Mar 2002 15:44:02 -0000      1.9
  +++ MetaClassImpl.java        14 Mar 2002 16:45:02 -0000      1.10
  @@ -65,7 +65,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *     [EMAIL PROTECTED]</a>
  - *@version    $Id: MetaClassImpl.java,v 1.9 2002/03/14 15:44:02 baliuka Exp $
  + *@version    $Id: MetaClassImpl.java,v 1.10 2002/03/14 16:45:02 baliuka Exp $
    */
   public class MetaClassImpl implements MetaClass, 
org.apache.commons.simplestore.tools.Constants  {
       
  @@ -190,7 +190,7 @@
           public void setReferenceClass( String referencedClass ) {
               try{
                  if(referencedClass != null) 
  -                this.refClass = Class.forName( referencedClass);
  +                this.refClass = Class.forName( 
referencedClass,false,getClass().getClassLoader());
               }catch(Throwable t){
                   t.printStackTrace();
                   throw new java.lang.NoClassDefFoundError(referencedClass);
  @@ -538,7 +538,8 @@
           
           public void start_validator(final Attributes meta) throws SAXException {
              try{ 
  -            currentValidator = 
(Validator)Class.forName(meta.getValue("id")).newInstance();
  +            currentValidator = (Validator)Class.forName(meta.getValue("id")
  +                            ,false,getClass().getClassLoader()).newInstance();
               currentField.setValidator(currentValidator);
              }catch(Exception e){
                rethrow(e);
  @@ -573,8 +574,7 @@
           public void start_mclass(final Attributes meta) throws SAXException {
               
               try{
  -                Class clasz  = Class.forName( meta.getValue("id"),true,
  -                Thread.currentThread().getContextClassLoader()) ;
  +                Class clasz  = Class.forName( meta.getValue("id"),false, 
getClass().getClassLoader()) ;
                   currentClass  = 
(MetaClassImpl)persitentClasses.get(clasz.getName());
                   if ( currentClass == null ){
                       currentClass = new MetaClassImpl();
  
  
  
  1.17      +2 -2      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java
  
  Index: PersistentProxy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- PersistentProxy.java      14 Mar 2002 15:44:02 -0000      1.16
  +++ PersistentProxy.java      14 Mar 2002 16:45:02 -0000      1.17
  @@ -78,7 +78,7 @@
    *      [EMAIL PROTECTED]</a>
    *@author     Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: PersistentProxy.java,v 1.16 2002/03/14 15:44:02 baliuka Exp $
  + *@version    $Id: PersistentProxy.java,v 1.17 2002/03/14 16:45:02 baliuka Exp $
    */
   public class PersistentProxy
   implements MetaObject,  org.apache.commons.simplestore.tools.Constants ,
  @@ -143,7 +143,7 @@
              interfaces = new Class[]{ Persistent.class} ;
           }
           Persistent p = (Persistent)
  -        Enhancer.enhance( persistent,interfaces,handler);
  +        Enhancer.enhance( 
persistent,null,interfaces,handler,Persistent.class.getClassLoader());
           
           handler.m_object = p;
           if ( newCreated ) {
  
  
  
  1.1                  
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/AutoCommitTransactionManager.java
  
  Index: AutoCommitTransactionManager.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache Cocoon" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.simplestore.persistence.impl;
  
  import org.apache.commons.simplestore.persistence.TransactionManager;
  import org.apache.commons.simplestore.persistence.InternalTransaction;
  import org.apache.commons.simplestore.persistence.MetaObject;
  /**
   *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
   *      [EMAIL PROTECTED]</a>
   *@version    $Id: AutoCommitTransactionManager.java,v 1.1 2002/03/14 16:45:02 
baliuka Exp $
   */
  public class AutoCommitTransactionManager implements 
TransactionManager,InternalTransaction{
      
      TransactionManager tm;
      
      /** Creates a new instance of AutoCommitTransactionManager */
      public AutoCommitTransactionManager(TransactionManager tm) {
          this.tm = tm;
      }
      
      public InternalTransaction getTransaction() {
          return this;
      }
      
      public void add(MetaObject props) {
        try{  
         tm.getTransaction().begin(); 
        }catch(java.lang.IllegalStateException ise){
         //
        }
        tm.getTransaction().add(props);
        
       try{  
         tm.getTransaction().commit(); 
        }catch(java.lang.IllegalStateException ise){
         //
        }
        
          
      }    
      
      public void begin() {
          tm.getTransaction().begin();
      }    
      
      public void begin(java.util.Set objects) {
          tm.getTransaction().begin(objects);
      }    
      
      public void commit() {
          tm.getTransaction().commit();
      }    
      
      public void commit(java.util.Set objects) {
         tm.getTransaction().commit(objects); 
      }
      
      public Object getAttribute(String name) {
         return tm.getTransaction().getAttribute(name);
      }
      
      public java.util.Collection getTransactionalObjects() {
          return tm.getTransaction().getTransactionalObjects();
      }
      
      public void removeAttribute(String name) {
          tm.getTransaction().removeAttribute(name);
      }
      
      public void rollback() {
          tm.getTransaction().rollback();
      }
      
      public void rollback(java.util.Set objects) {
          tm.getTransaction().rollback(objects);
      }
      
      public void setAttribute(String name, Object value) {
          tm.getTransaction().setAttribute(name,value);
      }
      
  }
  
  
  

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

Reply via email to