db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: jakarta-ojb/src/jdori/org/apache/ojb/jdori/sql OjbStoreManager.java OjbStoreConnector.java
Date Fri, 29 Nov 2002 17:40:14 GMT
thma        2002/11/29 09:40:14

  Modified:    src/jdori/org/apache/ojb/tutorial5 UCEditProduct.java
                        Application.java
               src/jdori/org/apache/ojb/jdori/sql OjbStoreManager.java
                        OjbStoreConnector.java
  Log:
  now all use case work with the JDO RI implementation !
  
  Revision  Changes    Path
  1.2       +5 -1      jakarta-ojb/src/jdori/org/apache/ojb/tutorial5/UCEditProduct.java
  
  Index: UCEditProduct.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/jdori/org/apache/ojb/tutorial5/UCEditProduct.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UCEditProduct.java	28 Nov 2002 07:24:02 -0000	1.1
  +++ UCEditProduct.java	29 Nov 2002 17:40:14 -0000	1.2
  @@ -75,7 +75,7 @@
   
               
   
  -            manager.makePersistent(toBeEdited);
  +            //manager.makePersistent(toBeEdited);
   
               manager.currentTransaction().commit();
           }
  @@ -85,6 +85,10 @@
               //broker.abortTransaction();
               manager.currentTransaction().rollback();
               t.printStackTrace();
  +        }
  +        finally 
  +        {
  +        	manager.close();	
           }
       }
   
  
  
  
  1.2       +3 -2      jakarta-ojb/src/jdori/org/apache/ojb/tutorial5/Application.java
  
  Index: Application.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/jdori/org/apache/ojb/tutorial5/Application.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Application.java	28 Nov 2002 07:24:02 -0000	1.1
  +++ Application.java	29 Nov 2002 17:40:14 -0000	1.2
  @@ -7,6 +7,7 @@
   import javax.jdo.PersistenceManager;
   import javax.jdo.PersistenceManagerFactory;
   
  +import org.apache.ojb.broker.util.ui.AsciiSplash;
   import org.apache.ojb.jdori.sql.OjbStorePMF;
   
   /**
  @@ -88,8 +89,8 @@
        */
       public void run()
       {
  -    	//System.out.println(AsciiSplash.getSplashArt());
  -        System.out.println("Welcome to the OJB JDO tutorial application");
  +    	System.out.println(AsciiSplash.getSplashArt());
  +        System.out.println("Welcome to the OJB JDO RI tutorial application");
           System.out.println();
           // never stop (there is a special use case to quit the application)
           while (true)
  
  
  
  1.2       +38 -26    jakarta-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java
  
  Index: OjbStoreManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbStoreManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OjbStoreManager.java	28 Nov 2002 07:24:01 -0000	1.1
  +++ OjbStoreManager.java	29 Nov 2002 17:40:14 -0000	1.2
  @@ -53,6 +53,7 @@
    * <http://www.apache.org/>.
    */
   
  +import java.lang.reflect.Field;
   import java.util.BitSet;
   import java.util.Iterator;
   
  @@ -107,6 +108,8 @@
   
       /** the logger used for debugging*/
       private Logger logger = LoggerFactory.getLogger("JDO");
  +    
  +    
   
       OjbStoreManager(OjbStorePMF pmf)
       {
  @@ -146,7 +149,7 @@
   
           try
           {
  -            logger.debug("OjbSRM.insert");
  +            logger.debug("OjbStoreManager.insert");
               PersistenceBroker broker = connector.getBroker();
               Object instance = sm.getObject();
               broker.store(instance, ObjectModificationDefaultImpl.INSERT);
  @@ -170,7 +173,9 @@
   
           try
           {
  +        	logger.debug("OjbStoreManager.update");
               PersistenceBroker broker = connector.getBroker();
  +            fetch(sm, null);
               Object instance = sm.getObject();
               broker.store(instance, ObjectModificationDefaultImpl.UPDATE);
           }
  @@ -200,13 +205,6 @@
           return StateManagerInternal.FLUSHED_COMPLETE;
       }
   
  -    // RESOLVE: Marina, do we need this?  @see com.sun.jdori.StoreManager#verifyExistence.
  -    /**
  -     * @see com.sun.jdori.StoreManager#verifyExistence
  -     */
  -    //    public boolean verifyExistence(StateManagerInternal sm) {
  -    //        return verify(sm, false, null, null);
  -    //    }
   
       /**
        * @see com.sun.jdori.StoreManager#delete(BitSet, BitSet, StateManagerInternal)
  @@ -216,8 +214,11 @@
           BitSet dirtyFields,
           StateManagerInternal sm)
       {
  +    	Identity oid = (Identity)sm.getInternalObjectId();
  +    	logger.debug("OjbStoreManager.delete(" + oid + ")");
           try
           {
  +        	fetch(sm,null);
               connector.getBroker().delete(sm.getObject());
           }
           catch (Exception ex)
  @@ -398,19 +399,13 @@
       {
           this.optimistic = pm.currentTransaction().getOptimistic();
   
  -        logger.debug("OjbSRM.flush: begin, optimistic=" + optimistic);
  -
  -        preFlush();
  -
  -        logger.debug("OjbSRM.flush: completed flush commit");
  -
           boolean err = false;
   
           while (it.hasNext())
           {
               StateManagerInternal sm = (StateManagerInternal) it.next();
  +            logger.debug("OjbStoreManager.flush: " + sm.getInternalObjectId() + ", " +
getLCState(sm));
               sm.preStore();
  -
               sm.replaceSCOFields();
               sm.flush(this);
               if (!sm.isFlushed())
  @@ -420,7 +415,7 @@
               }
           }
   
  -        logger.debug("OjbSRM.flush: end, err=" + err);
  +        logger.debug("OjbStoreManager.flush: end, err=" + err);
   
           if (err)
           {
  @@ -428,6 +423,31 @@
           }
       }
   
  +	/**
  +	 * @return the LifeCycleState of a StateManager instance
  +	 */
  +	protected Object getLCState(StateManagerInternal sm)
  +	{
  +		// unfortunately the LifeCycleState classes ar package private.
  +		// so we have to do some dirty reflection hack to access them
  +        try
  +        {
  +            Field myLC = sm.getClass().getDeclaredField("myLC");
  +            myLC.setAccessible(true);
  +            return myLC.get(sm);
  +        }
  +        catch (NoSuchFieldException e)
  +        {
  +        	return e;
  +        }
  +        catch (IllegalAccessException e)
  +        {
  +        	return e;
  +        }	
  +	}
  +
  +
  +
       /**
        * Returns a QueryResult instance which is then returned as the result of 
        * Query.execute(...). This method allows support for datastore specific 
  @@ -469,19 +489,11 @@
        */
       private boolean verify(StateManagerInternal sm, boolean verifyFields, BitSet fieldsToVerify)
       {
  -
  +		logger.debug("OjbStoreManager.verify");
           boolean rc = false;
           // thma: implement here!
           return rc;
       }
   
  -    /**
  -     * Write a CommitRequest and flush the connector, to cause all
  -     * CreateOid and ActivateClass requests to be committed in the
  -     * database *before* any inserts, updates, or deletes.
  -     */
  -    private void preFlush()
  -    {
  -        //thma : don't know what to do here?
  -    }
  +
   }
  
  
  
  1.2       +3 -3      jakarta-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java
  
  Index: OjbStoreConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/jdori/org/apache/ojb/jdori/sql/OjbStoreConnector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OjbStoreConnector.java	28 Nov 2002 07:24:01 -0000	1.1
  +++ OjbStoreConnector.java	29 Nov 2002 17:40:14 -0000	1.2
  @@ -113,7 +113,7 @@
           //this.okToReleaseConnection = optimistic;
   
           this.okToReleaseConnection = false;
  -        logger.debug("FOConnector.begin: okToReleaseConnection=" + okToReleaseConnection);
  +        logger.debug("OjbStoreConnector.begin: okToReleaseConnection=" + okToReleaseConnection);
   
           // obtain a fresh broker and open a tx on it 
           broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  @@ -141,7 +141,7 @@
       {
           assertNotRollbackOnly();
   
  -        logger.debug("FOConnector.flush: " + // NOI18N
  +        logger.debug("OjbStoreConnector.flush: " + // NOI18N
           "okToReleaseConnection=" + okToReleaseConnection);
           // thma: noop?
       }
  @@ -183,7 +183,7 @@
        */
       public synchronized void rollback()
       {
  -        logger.debug("FOConnector.rollback, RBO=" + rollbackOnly); // NOI18N
  +        logger.debug("OjbStoreConnector.rollback, RBO=" + rollbackOnly); // NOI18N
   
           if (!rollbackOnly)
           {
  
  
  

Mime
View raw message