krysalis-sandbox/workflow/src/java/org/krysalis/workflow/store MemoryStore.java,1.2,1.3

[email protected]
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-sandbox/workflow/src/java/org/krysalis/workflow/store
In directory sc8-pr-cvs1:/tmp/cvs-serv11380/src/java/org/krysalis/workflow/store

Modified Files:
	MemoryStore.java 
Log Message:
Managed the first running test case.
Add all avalon libs, which will be needed(incredible many!).


Index: MemoryStore.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-sandbox/workflow/src/java/org/krysalis/workflow/store/MemoryStore.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MemoryStore.java	14 Mar 2003 09:17:28 -0000	1.2
--- MemoryStore.java	14 Mar 2003 15:06:09 -0000	1.3
***************
*** 6,10 ****
   * at the bottom of this file.                                               *
   *****************************************************************************/
!  
  package org.krysalis.workflow.store;
  
--- 6,10 ----
   * at the bottom of this file.                                               *
   *****************************************************************************/
! 
  package org.krysalis.workflow.store;
  
***************
*** 13,16 ****
--- 13,18 ----
  import org.apache.avalon.excalibur.concurrent.Mutex;
  
+ import org.apache.avalon.framework.logger.AbstractLogEnabled;
+ 
  import org.krysalis.workflow.*;
  
***************
*** 22,65 ****
   * @version CVS $Id$
   */
! public class MemoryStore implements WorkFlowStore {
  
!     private Hashtable states = new Hashtable();
!     private Hashtable locks = new Hashtable(); 
  
!     public WorkFlowState lookup(String resource) 
      {
!       synchronized (locks)
!       {
!         if (locks.get(resource)!=null)
!           locks.put(resource, new Mutex());
!       }
  
!       Mutex lock = (Mutex)locks.get(resource);
!       try
!       {
!         lock.acquire();
!       } 
!       catch (InterruptedException ie)
!       {
!         //getLogger().error("Could not acquire lock for '"+resource+"'",ie);
!         return null;
!       }
  
!       WorkFlowState state = (WorkFlowState)states.get(resource);
!       if (state==null)
!       {
!         state = new DefaultWorkFlowState(resource);
!         states.put(state.getResource(), state);
!       }
!       return state;
      }
  
!     public void release(WorkFlowState state) 
      {
!       Mutex lock = (Mutex)locks.get(state.getResource());
!       lock.release();
      }
! }
  
  
  /*
--- 24,82 ----
   * @version CVS $Id$
   */
! public class MemoryStore extends AbstractLogEnabled implements WorkFlowStore
! {
  
!   private Hashtable states = new Hashtable();
!   private Hashtable locks = new Hashtable();
  
!   /**
!    *
!    *
!    * @param resource   
!    *
!    * @return
!    */
!   public WorkFlowState lookup(String resource)
!   {
!     synchronized (locks)
      {
!       if (locks.get(resource)==null)
!         locks.put(resource, new Mutex());
!     }
  
!     Mutex lock = (Mutex) locks.get(resource);
  
!     try
!     {
!       lock.acquire();
!     }
!     catch (InterruptedException ie)
!     {
!       getLogger().error("Could not acquire lock for '"+resource+"'", ie);
!       return null;
      }
  
!     WorkFlowState state = (WorkFlowState) states.get(resource);
! 
!     if (state==null)
      {
!       state = new DefaultWorkFlowState(resource);
!       states.put(state.getResource(), state);
      }
!     return state;
!   }
  
+   /**
+    *
+    *
+    * @param state      
+    */
+   public void release(WorkFlowState state)
+   {
+     Mutex lock = (Mutex) locks.get(state.getResource());
+ 
+     lock.release();
+   }
+ }
  
  /*
***************
*** 67,71 ****
  Copyright (c) 2002 Nicola Ken Barozzi.  All rights reserved.
  
! This Licence is compatible with the BSD licence as described and 
  approved by http://www.opensource.org/, and is based on the
  Apache Software Licence Version 1.1.
--- 84,88 ----
  Copyright (c) 2002 Nicola Ken Barozzi.  All rights reserved.
  
! This Licence is compatible with the BSD licence as described and
  approved by http://www.opensource.org/, and is based on the
  Apache Software Licence Version 1.1.
***************
*** 85,89 ****
  3. The end-user documentation included with the redistribution,
     if any, must include the following acknowledgment:
!       "This product includes software developed for project 
         Krysalis (http://www.krysalis.org/)."
     Alternately, this acknowledgment may appear in the software itself,
--- 102,106 ----
  3. The end-user documentation included with the redistribution,
     if any, must include the following acknowledgment:
!       "This product includes software developed for project
         Krysalis (http://www.krysalis.org/)."
     Alternately, this acknowledgment may appear in the software itself,
***************
*** 94,103 ****
     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 "Krysalis",
     "Krysalis Metamorphosis", nor may "Krysalis" appear in their name,
     without prior written permission of Nicola Ken Barozzi.
  
! 6. This software may contain voluntary contributions made by many 
     individuals, who decided to donate the code to this project in
     respect of this licence.
--- 111,120 ----
     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 "Krysalis",
     "Krysalis Metamorphosis", nor may "Krysalis" appear in their name,
     without prior written permission of Nicola Ken Barozzi.
  
! 6. This software may contain voluntary contributions made by many
     individuals, who decided to donate the code to this project in
     respect of this licence.




-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.