portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/impl DefaultPersistenceStoreContainer.java
Date Thu, 04 Mar 2004 21:20:07 GMT
weaver      2004/03/04 13:20:07

  Modified:    components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb
                        CriteriaFilter.java
               components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/otm
                        OTMTransactionImpl.java OTMStoreImpl.java
               components/persistence/src/java/org/apache/jetspeed/components/persistence/store
                        PersistenceStore.java
               components/persistence/src/java/org/apache/jetspeed/containers
                        persistence.container.groovy
               components/persistence/src/java/org/apache/jetspeed/components/persistence/store/impl
                        DefaultPersistenceStoreContainer.java
  Added:       components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/pb
                        PBTransaction.java PBStore.java
  Log:
  reverting to ojb-Rc4 and PB
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/CriteriaFilter.java
  
  Index: CriteriaFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/CriteriaFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CriteriaFilter.java	22 Feb 2004 22:40:01 -0000	1.1
  +++ CriteriaFilter.java	4 Mar 2004 21:20:07 -0000	1.2
  @@ -127,7 +127,7 @@
        */
       public void addLike(Object arg0, Object arg1)
       {
  -        ojbCriteria.addLike(arg0, arg1);
  +        ojbCriteria.addLike((String)arg0, arg1);
       }
   
       /**
  
  
  
  1.1                  jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/pb/PBTransaction.java
  
  Index: PBTransaction.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.components.persistence.store.ojb.pb;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import org.apache.jetspeed.components.persistence.store.Transaction;
  import org.apache.jetspeed.components.persistence.store.TransactionEventListener;
  import org.apache.jetspeed.components.persistence.store.impl.TransactionEventInvoker;
  import org.apache.ojb.broker.PersistenceBroker;
  public class PBTransaction implements Transaction
  {
  
      private List eventListeners;
      private TransactionEventInvoker invoker;
      private PersistenceBroker pb;
      private PBStore store;
  
      public PBTransaction(PersistenceBroker pb, PBStore store)
      {
          this.pb = pb;
          this.store = store;
          eventListeners = new ArrayList();
          invoker = new TransactionEventInvoker(eventListeners, store);
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#begin()
       */
      public void begin()
      {
          if (!pb.isClosed() && !pb.isInTransaction())
          {
              invoker.beforeBegin();
              pb.beginTransaction();
              invoker.afterBegin();
          }
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#commit()
       */
      public void commit()
      {
          invoker.beforeCommit();
          Iterator itr = store.toBeStored.iterator();
          while(itr.hasNext())
          {
              store.store(itr.next());
          }
          pb.commitTransaction();
          invoker.afterCommit();
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#rollback()
       */
      public void rollback()
      {
          invoker.beforeRollback();
          pb.abortTransaction();
          invoker.afterRollback();
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#checkpoint()
       */
      public void checkpoint()
      {
          Iterator itr = store.toBeStored.iterator();
          while(itr.hasNext())
          {
              store.store(itr.next());
          }
         
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#isOpen()
       */
      public boolean isOpen()
      {
          return pb.isInTransaction();
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#getWrappedTransaction()
       */
      public Object getWrappedTransaction()
      {
          return pb;
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see org.apache.jetspeed.components.persistence.store.Transaction#addEventListener(org.apache.jetspeed.components.persistence.store.TransactionEventListener)
       */
      public void addEventListener(TransactionEventListener listener)
      {
          eventListeners.add(listener);
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/pb/PBStore.java
  
  Index: PBStore.java
  ===================================================================
  /*
   * Copyright 2000-2001,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.components.persistence.store.ojb.pb;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Set;
  
  import org.apache.jetspeed.components.persistence.store.Filter;
  import org.apache.jetspeed.components.persistence.store.PersistenceStore;
  import org.apache.jetspeed.components.persistence.store.PersistenceStoreEventListener;
  import org.apache.jetspeed.components.persistence.store.Transaction;
  import org.apache.jetspeed.components.persistence.store.impl.LockFailedException;
  import org.apache.jetspeed.components.persistence.store.impl.StoreEventInvoker;
  import org.apache.jetspeed.components.persistence.store.ojb.CriteriaFilter;
  import org.apache.ojb.broker.Identity;
  import org.apache.ojb.broker.PBFactoryException;
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.broker.PersistenceBroker;
  import org.apache.ojb.broker.PersistenceBrokerFactory;
  import org.apache.ojb.broker.query.Criteria;
  import org.apache.ojb.broker.query.Query;
  import org.apache.ojb.broker.query.QueryFactory;
  
  
  /**
   * <p>
   * PBStore
   * </p>
   *
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $ $
   *
   */
  public class PBStore implements PersistenceStore
  {
      private PBKey pbKey;
      private List listeners;
      private StoreEventInvoker invoker;
      private PersistenceBroker pb;
     
      protected Set toBeStored;
      
      
      public PBStore(String jcd)
      {
          try
          {
              pbKey = new PBKey(jcd);
     
              if (jcd != null)
              {
                  pbKey = new PBKey(jcd);
              }
              else
              {
                  pbKey = PersistenceBrokerFactory.getDefaultKey();
              }
              this.listeners = new ArrayList();        
              invoker = new StoreEventInvoker(listeners, this);
              pb = PersistenceBrokerFactory.createPersistenceBroker(pbKey);        
              toBeStored = new HashSet();
          }
          catch (Throwable e)
          {
              // TODO Auto-generated catch block
              System.out.println("==========================>"+e.getCause());
              if(e.getCause() != null)
              {
             e.getCause().printStackTrace();
              }
          }        
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#addEventListener(org.apache.jetspeed.components.persistence.store.PersistenceStoreEventListener)
       */
      public void addEventListener(PersistenceStoreEventListener listener)
      {
          listeners.add(listener);
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#close()
       */
      public void close()
      {
          if (!pb.isClosed())
          {
              pb.close();
          }
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#deletePersistent(java.lang.Object)
       */
      public void deletePersistent(Object obj) throws LockFailedException
      {
          invoker.beforeDeletePersistent();        
          pb.delete(obj);
          invoker.afterDeletePersistent();
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#deleteAll(java.lang.Object)
       */
      public void deleteAll(Object query) throws LockFailedException
      {
          Collection deletes = pb.getCollectionByQuery((Query) query);
          Iterator itr = deletes.iterator();
          while(itr.hasNext())
          {
              invoker.beforeDeletePersistent();  
              pb.delete(itr.next());
              invoker.afterDeletePersistent();
          }
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getCollectionByQuery(java.lang.Object)
       */
      public Collection getCollectionByQuery(Object query)
      {
          invoker.beforeLookup();
          try
          {
              return pb.getCollectionByQuery((Query) query);
          }
          finally
          {
              invoker.afterLookup();
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getCollectionByQuery(java.lang.Object,
int)
       */
      public Collection getCollectionByQuery(Object query, int lockLevel)
      {
          
          return getCollectionByQuery(query);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getObjectByQuery(java.lang.Object)
       */
      public Object getObjectByQuery(Object query)
      {        
          invoker.beforeLookup();
          try
          {
              return pb.getObjectByQuery((Query) query);
          }
          finally
          {
              invoker.afterLookup();
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getObjectByQuery(java.lang.Object,
int)
       */
      public Object getObjectByQuery(Object query, int lockLevel)
      {
          return getObjectByQuery(query);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getObjectByIdentity(java.lang.Object)
       */
      public Object getObjectByIdentity(Object object) throws LockFailedException
      {
          invoker.beforeLookup();
          try
          {
              return pb.getObjectByIdentity(new Identity(object, pb));
          }
          finally
          {
              invoker.afterLookup();
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getObjectByIdentity(java.lang.Object,
int)
       */
      public Object getObjectByIdentity(Object object, int lockLevel) throws LockFailedException
      {
  
          return getObjectByIdentity(object);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getCount(java.lang.Object)
       */
      public int getCount(Object query)
      {
         
              return pb.getCount((Query) query);
         
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getIteratorByQuery(java.lang.Object)
       */
      public Iterator getIteratorByQuery(Object query)
      {
          invoker.beforeLookup();
          try
          {
              return pb.getIteratorByQuery((Query) query);
          }
          finally
          {
              invoker.afterLookup();
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getIteratorByQuery(java.lang.Object,
int)
       */
      public Iterator getIteratorByQuery(Object query, int lockLevel)
      {
          return getIteratorByQuery(query);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#isClosed()
       */
      public boolean isClosed()
      {
          return pb.isClosed();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getTransaction()
       */
      public Transaction getTransaction()
      {
          return new PBTransaction(pb, this);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#invalidate(java.lang.Object)
       */
      public void invalidate(Object obj) throws LockFailedException
      {
          pb.removeFromCache(obj);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#invalidateExtent(java.lang.Class)
       */
      public void invalidateExtent(Class clazz) throws LockFailedException
      {
          Iterator itr = pb.getCollectionByQuery(QueryFactory.newQuery(clazz, new Criteria())).iterator();
          while(itr.hasNext())
          {
              invalidate(itr.next());
          }
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#invalidateByQuery(java.lang.Object)
       */
      public void invalidateByQuery(Object query) throws LockFailedException
      {
          Iterator itr = pb.getCollectionByQuery((Query)query).iterator();
          while(itr.hasNext())
          {
              invalidate(itr.next());
          }
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#lockForWrite(java.lang.Object)
       */
      public void lockForWrite(Object obj) throws LockFailedException
      {
          toBeStored.add(obj);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#makePersistent(java.lang.Object)
       */
      public void makePersistent(Object obj) throws LockFailedException
      {
          store(obj);
      }
  
      /**
       * <p>
       *  store
       * </p>
       * 
       * @param obj
       */
      protected void store(Object obj)
      {
          try
          {
              invoker.beforeMakePersistent();
              pb.store(obj);
              invoker.afterMakePersistent();
          }
          finally
          {
              toBeStored.remove(obj);
          }
          
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#newFilter()
       */
      public Filter newFilter()
      {
          return new CriteriaFilter();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#newQuery(java.lang.Class,
org.apache.jetspeed.components.persistence.store.Filter)
       */
      public Object newQuery(Class clazz, Filter filter)
      {
          return QueryFactory.newQuery(clazz, ((CriteriaFilter)filter).getOjbCriteria());
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getExtent(java.lang.Class)
       */
      public Collection getExtent(Class clazz)
      {
          invoker.beforeLookup();
          try
          {
              return pb.getCollectionByQuery(QueryFactory.newQuery(clazz, new Criteria()));
          }
          finally
          {
              invoker.afterLookup();
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#getExtent(java.lang.Class,
int)
       */
      public Collection getExtent(Class clazz, int lockLevel)
      {
          return getExtent(clazz);
      }
      /* (non-Javadoc)
       * @see org.apache.jetspeed.components.persistence.store.PersistenceStore#invalidateAll()
       */
      public void invalidateAll() throws LockFailedException
      {
          pb.clearCache();
      }
      
     
  
  }
  
  
  
  1.4       +26 -7     jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/otm/OTMTransactionImpl.java
  
  Index: OTMTransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/otm/OTMTransactionImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OTMTransactionImpl.java	25 Feb 2004 16:06:40 -0000	1.3
  +++ OTMTransactionImpl.java	4 Mar 2004 21:20:07 -0000	1.4
  @@ -22,6 +22,8 @@
   import org.apache.jetspeed.components.persistence.store.Transaction;
   import org.apache.jetspeed.components.persistence.store.TransactionEventListener;
   import org.apache.jetspeed.components.persistence.store.impl.TransactionEventInvoker;
  +import org.apache.ojb.otm.OTMConnection;
  +import org.apache.ojb.otm.OTMKit;
   
   /**
    * <p>
  @@ -35,23 +37,33 @@
    */
   public class OTMTransactionImpl implements Transaction
   {
  -    private org.apache.ojb.otm.core.Transaction OTMTx;
  +    private OTMConnection conn;
  +    private OTMKit kit;
       private List eventListeners;
       private TransactionEventInvoker invoker;
       private OTMStoreImpl store;
       private static final Log log = LogFactory.getLog(OTMTransactionImpl.class);
  -    public OTMTransactionImpl(org.apache.ojb.otm.core.Transaction OTMTx, PersistenceStore
store)
  +    public OTMTransactionImpl(OTMConnection conn, OTMKit kit, PersistenceStore store)
       {
  -        if (OTMTx == null)
  +        if (conn == null)
           {
  -            throw new IllegalArgumentException("The OTM Transaction cannot be null.");
  +            throw new IllegalArgumentException("The OTM Connection cannot be null.");
           }
  +        
  +        if (kit == null)
  +        {
  +            throw new IllegalArgumentException("The OTM kit cannot be null.");
  +        }
  +        
           if (store == null)
           {
               throw new IllegalArgumentException("The PersistenceStore cannot be null.");
           }
  -        this.OTMTx = OTMTx;
  +        
           eventListeners = new ArrayList();
  +        this.store = (OTMStoreImpl)store;
  +        this.kit = kit;
  +        this.conn = conn;
           invoker = new TransactionEventInvoker(eventListeners, store);
       }
   
  @@ -65,6 +77,7 @@
        */
       public void begin()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           if (!OTMTx.isInProgress())
           {
               invoker.beforeBegin();
  @@ -83,10 +96,12 @@
        */
       public void commit()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           invoker.beforeCommit();
  +        
           OTMTx.commit();
  -        // store.setTransaction(null);
  -        //  OTMTx = null;
  +        store.setTransaction(null);
  +        OTMTx = null;
           invoker.afterCommit();
       }
   
  @@ -100,6 +115,7 @@
        */
       public void rollback()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           if (OTMTx != null && OTMTx.isInProgress())
           {
               invoker.beforeRollback();
  @@ -122,6 +138,7 @@
        */
       public boolean isOpen()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           return OTMTx.isInProgress();
       }
   
  @@ -135,6 +152,7 @@
        */
       public Object getWrappedTransaction()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           return OTMTx;
       }
   
  @@ -161,6 +179,7 @@
        */
       public void checkpoint()
       {
  +        org.apache.ojb.otm.core.Transaction OTMTx = kit.getTransaction(conn);
           OTMTx.checkpoint();
       }
   }
  
  
  
  1.6       +28 -5     jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/otm/OTMStoreImpl.java
  
  Index: OTMStoreImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/ojb/otm/OTMStoreImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OTMStoreImpl.java	2 Mar 2004 01:40:42 -0000	1.5
  +++ OTMStoreImpl.java	4 Mar 2004 21:20:07 -0000	1.6
  @@ -20,6 +20,8 @@
   import java.util.Iterator;
   import java.util.List;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.components.persistence.store.Filter;
   import org.apache.jetspeed.components.persistence.store.PersistenceStore;
   import org.apache.jetspeed.components.persistence.store.PersistenceStoreEventListener;
  @@ -61,6 +63,7 @@
       private PBKey pbKey;
       private StoreEventInvoker invoker;
       private String jcd;
  +    private static final Log log = LogFactory.getLog(OTMStoreImpl.class);
   
   	/**
   	 * Name of the JavaConnectionDescriptor this store will use to access
  @@ -174,10 +177,17 @@
        */
       public void deleteAll(Object query) throws LockFailedException
       {
  -        Iterator itr = getCollectionByQuery(query).iterator();
  -        while (itr.hasNext())
  +        try
           {
  -            deletePersistent(itr.next());
  +            Iterator itr = getCollectionByQuery(query).iterator();
  +            while (itr.hasNext())
  +            {
  +                OTMConn.deletePersistent(itr.next());
  +            }
  +        }
  +        catch (Exception e)
  +        {
  +            log.warn("Problem encountered deleting objects", e);
           }
   
       }
  @@ -414,9 +424,9 @@
        */
       public Transaction getTransaction()
       {
  -        if (tx == null || OTMConn.getTransaction() == null)
  +        if (tx == null)
           {
  -            tx = new OTMTransactionImpl(kit.getTransaction(OTMConn), this);
  +            tx = new OTMTransactionImpl(OTMConn, kit, this);
               for (int i = 0; i < listeners.size(); i++)
               {
                   tx.addEventListener((TransactionEventListener) listeners.get(i));
  @@ -448,6 +458,19 @@
               throw new LockFailedException(e.toString(), e);
           }
   
  +    }
  +    
  +    public void invalidateAll() throws LockFailedException
  +    {
  +        try
  +        {
  +            
  +            OTMConn.invalidateAll();
  +        }
  +        catch (LockingException e)
  +        {
  +            throw new LockFailedException(e.toString(), e);
  +        }
       }
   
       /** 
  
  
  
  1.2       +2 -0      jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/PersistenceStore.java
  
  Index: PersistenceStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/PersistenceStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PersistenceStore.java	22 Feb 2004 22:40:01 -0000	1.1
  +++ PersistenceStore.java	4 Mar 2004 21:20:07 -0000	1.2
  @@ -161,6 +161,8 @@
       
       void invalidate(Object obj) throws LockFailedException;
       
  +    void invalidateAll() throws LockFailedException;
  +    
       void invalidateExtent(Class clazz) throws LockFailedException;
       
   	void invalidateByQuery(Object query) throws LockFailedException;
  
  
  
  1.3       +5 -4      jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/containers/persistence.container.groovy
  
  Index: persistence.container.groovy
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/containers/persistence.container.groovy,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- persistence.container.groovy	24 Feb 2004 00:33:58 -0000	1.2
  +++ persistence.container.groovy	4 Mar 2004 21:20:07 -0000	1.3
  @@ -1,8 +1,9 @@
   import org.picocontainer.defaults.DefaultPicoContainer
   import org.picocontainer.Parameter
   import org.picocontainer.defaults.ConstantParameter
  -import org.apache.jetspeed.components.persistence.store.ojb.OJBTypeIntializer
  -import org.apache.jetspeed.components.persistence.store.ojb.otm.OTMStoreImpl
  +//import org.apache.jetspeed.components.persistence.store.ojb.OJBTypeIntializer
  +//import org.apache.jetspeed.components.persistence.store.ojb.otm.OTMStoreImpl
  +import org.apache.jetspeed.components.persistence.store.ojb.pb.PBStore
   import org.apache.jetspeed.components.persistence.store.impl.DefaultPersistenceStoreContainer
   import org.apache.jetspeed.components.persistence.store.PersistenceStoreContainer
   import org.apache.jetspeed.components.util.system.FSSystemResourceUtilImpl
  @@ -11,8 +12,8 @@
   
   container = new DefaultPersistenceStoreContainer(15000, 10000)
   
  -Class OTMStoreClass = Class.forName("org.apache.jetspeed.components.persistence.store.ojb.otm.OTMStoreImpl")
  -ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", OTMStoreClass, new Parameter[]
{new ConstantParameter("jetspeed")})
  +// Class OTMStoreClass = Class.forName("org.apache.jetspeed.components.persistence.store.ojb.otm.OTMStoreImpl")
  +ComponentAdapter ca = new ConstructorComponentAdapter("jetspeed", PBStore, new Parameter[]
{new ConstantParameter("jetspeed")})
   
   container.registerComponent(ca)
   
  
  
  
  1.4       +21 -21    jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/impl/DefaultPersistenceStoreContainer.java
  
  Index: DefaultPersistenceStoreContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/persistence/src/java/org/apache/jetspeed/components/persistence/store/impl/DefaultPersistenceStoreContainer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultPersistenceStoreContainer.java	2 Mar 2004 01:57:31 -0000	1.3
  +++ DefaultPersistenceStoreContainer.java	4 Mar 2004 21:20:07 -0000	1.4
  @@ -387,35 +387,35 @@
           {
               while (started)
               {
  -                Iterator keys = storeLastUsed.keySet().iterator();
  -                while (keys.hasNext())
  +                
  +                try
                   {
  -                    PersistenceStore store = (PersistenceStore) keys.next();
  -                    Date last = (Date) storeLastUsed.get(store);
  -                    Date now = new Date();
  -                    if ((now.getTime() - last.getTime()) > ttl)
  +                    Iterator keys = storeLastUsed.keySet().iterator();
  +                    while (keys.hasNext())
                       {
  -                        log.debug("PersistenceStore " + store + " has exceeded its TTL,
attemting to close.");
  -                        // broker should now be considered available
  -                        try
  -                        {
  -                            store.close();
  -                            log.debug("PersistenceStore successfully closed.");
  -                        }
  -                        catch (Throwable e1)
  +                        PersistenceStore store = (PersistenceStore) keys.next();
  +                        Date last = (Date) storeLastUsed.get(store);
  +                        Date now = new Date();
  +                        if ((now.getTime() - last.getTime()) > ttl)
                           {
  -                            log.error("Unable to close PersistenceStore " + store, e1);
  +                            log.debug("PersistenceStore " + store + " has exceeded its
TTL, attemting to close.");
  +                            // broker should now be considered available
  +                            try
  +                            {
  +                                store.close();
  +                                storeLastUsed.remove(store);
  +                                log.debug("PersistenceStore successfully closed.");
  +                            }
  +                            catch (Throwable e1)
  +                            {
  +                                log.error("Unable to close PersistenceStore " + store,
e1);
  +                            }
                           }
                       }
  -                }
  -
  -                try
  -                {
                       sleep(checkInterval);
                   }
  -                catch (InterruptedException e)
  +                catch (Exception e)
                   {
  -
                   }
               }
           }
  
  
  

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


Mime
View raw message