User: user57  
  Date: 02/04/03 17:39:44

  Modified:    src/main/org/jboss/test/idgen/ejb IdCounterBean.java
                        IdCounterBeanCMP.java IdGeneratorBean.java
  Log:
   o Changed next & current to nextValue & currentValue to avoid problems
     with SQL reserved words.
  
  Revision  Changes    Path
  1.2       +33 -41    jbosstest/src/main/org/jboss/test/idgen/ejb/IdCounterBean.java
  
  Index: IdCounterBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/idgen/ejb/IdCounterBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IdCounterBean.java        25 Aug 2000 13:43:39 -0000      1.1
  +++ IdCounterBean.java        4 Apr 2002 01:39:43 -0000       1.2
  @@ -13,58 +13,50 @@
   /**
    *      
    *   @see <related>
  - *   @author $Author: oberg $
  - *   @version $Revision: 1.1 $
  + *   @author $Author: user57 $
  + *   @version $Revision: 1.2 $
    */
   public abstract class IdCounterBean
      extends EntitySupport
   {
  -   // Constants -----------------------------------------------------
  -    
  -   // Attributes ----------------------------------------------------
  -     long nextId;
  -     long size;
  +   long nextId;
  +   long size;
      
  -   // Static --------------------------------------------------------
  -
  -   // Constructors --------------------------------------------------
  -   
  -   // Public --------------------------------------------------------
  -   public long getNext()
  +   public long getNextValue()
      {
  -             // Is sequence finished?
  -             // If so start a new one
  -             if (nextId == (getCurrent() + size))
  -             {
  -                     setCurrent(nextId);
  -             }
  -             
  -             return nextId++;
  +      // Is sequence finished?
  +      // If so start a new one
  +
  +      if (nextId == (getCurrentValue() + size))
  +      {
  +         setCurrentValue(nextId);
  +      }
  +      
  +      return nextId++;
      }
      
  -   public abstract long getCurrent();
  -   public abstract void setCurrent(long current);
  +   public abstract long getCurrentValue();
  +   public abstract void setCurrentValue(long current);
        
      public abstract String getName();
      public abstract void setName(String beanName);
        
  -     public void ejbLoad()
  -             throws RemoteException
  -     {
  -             nextId = getCurrent();
  -     }
  +   public void ejbLoad()
  +      throws RemoteException
  +   {
  +      nextId = getCurrentValue();
  +   }
        
  -     public void setEntityContext(EntityContext ctx)
  -             throws RemoteException
  -     {
  -             super.setEntityContext(ctx);
  -             
  -             try
  -             {
  -                size = ((Long)new 
InitialContext().lookup("java:comp/env/size")).longValue();
  -             } catch (Exception e)
  -             {
  -                throw new EJBException(e);
  -             }
  -     }
  +   public void setEntityContext(EntityContext ctx)
  +      throws RemoteException
  +   {
  +      super.setEntityContext(ctx);
  +      
  +      try {
  +         size = ((Long)new 
InitialContext().lookup("java:comp/env/size")).longValue();
  +      } 
  +      catch (Exception e) {
  +         throw new EJBException(e);
  +      }
  +   }
   }
  
  
  
  1.2       +8 -17     
jbosstest/src/main/org/jboss/test/idgen/ejb/IdCounterBeanCMP.java
  
  Index: IdCounterBeanCMP.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/idgen/ejb/IdCounterBeanCMP.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IdCounterBeanCMP.java     25 Aug 2000 13:43:39 -0000      1.1
  +++ IdCounterBeanCMP.java     4 Apr 2002 01:39:43 -0000       1.2
  @@ -11,31 +11,23 @@
   /**
    *      
    *   @see <related>
  - *   @author $Author: oberg $
  - *   @version $Revision: 1.1 $
  + *   @author $Author: user57 $
  + *   @version $Revision: 1.2 $
    */
   public class IdCounterBeanCMP
      extends IdCounterBean
   {
  -   // Constants -----------------------------------------------------
  -    
  -   // Attributes ----------------------------------------------------
      public String name;
  -   public long current;
  +   public long currentValue;
      
  -   // Static --------------------------------------------------------
  -
  -   // Constructors --------------------------------------------------
  -   
  -   // Public --------------------------------------------------------
  -   public long getCurrent()
  +   public long getCurrentValue()
      {
  -     return current;
  +        return currentValue;
      }
        
  -   public void setCurrent(long current)
  +   public void setCurrentValue(long current)
      {
  -     this.current = current;
  +     this.currentValue = current;
      }
      
      public String getName()
  @@ -48,12 +40,11 @@
        this.name = beanName;
      }
      
  -   // EntityBean implementation -------------------------------------
      public String ejbCreate(String name) 
         throws RemoteException, CreateException
      { 
         setName(name);
  -             current = 0;
  +      currentValue = 0;
                
         return null;
      }
  
  
  
  1.3       +23 -47    jbosstest/src/main/org/jboss/test/idgen/ejb/IdGeneratorBean.java
  
  Index: IdGeneratorBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/idgen/ejb/IdGeneratorBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IdGeneratorBean.java      7 Jan 2001 23:14:41 -0000       1.2
  +++ IdGeneratorBean.java      4 Apr 2002 01:39:43 -0000       1.3
  @@ -14,73 +14,46 @@
   /**
    *      
    *   @see <related>
  - *   @author $Author: peter $
  - *   @version $Revision: 1.2 $
  + *   @author $Author: user57 $
  + *   @version $Revision: 1.3 $
    */
   public class IdGeneratorBean
      extends SessionSupport
   {
  -   // Constants -----------------------------------------------------
  -    
  -   // Attributes ----------------------------------------------------
  -     IdCounterHome counterHome;
  +   IdCounterHome counterHome;
      
  -   // Static --------------------------------------------------------
      static final String SIZE = "java:comp/env/size";
   
  -   // Constructors --------------------------------------------------
  -   
  -   // Public --------------------------------------------------------
      public long getNewId(String beanName)
  -             throws RemoteException
  +      throws RemoteException
      {
         IdCounter counter;
  -             
  -             // Acquire counter
  -             try
  -             {
  -                     counter = counterHome.findByPrimaryKey(beanName);
  -             } catch (FinderException e)
  -             {
  -                     try
  -                     {
  -                             counter = counterHome.create(beanName);
  -                     } catch (CreateException ex)
  -                     {
  -                             throw new EJBException("Could not find or create 
counter for "+beanName);
  -                     }
  -             }
  -             
  -             // Get id
  -             return counter.getNext();
  +      
  +      // Acquire counter
  +      try {
  +         counter = counterHome.findByPrimaryKey(beanName);
  +      } 
  +      catch (FinderException e) {
  +         try {
  +            counter = counterHome.create(beanName);
  +         } catch (CreateException ex) {
  +            throw new EJBException("Could not find or create counter for 
"+beanName);
  +         }
  +      }
  +      
  +      // Get id
  +      return counter.getNextValue();
      }
  -   
  -   // SessionBean implementation ------------------------------------
  +
      public void setSessionContext(SessionContext context) 
      {
         super.setSessionContext(context);
         
  -      try
  -      {
  +      try {
            counterHome = (IdCounterHome)new 
InitialContext().lookup("java:comp/env/ejb/IdCounter");
  -      } catch (Exception e)
  -      {
  +      } 
  +      catch (Exception e) {
            throw new EJBException(e);
         }
      }
   }
  -
  -/*
  - *   $Id: IdGeneratorBean.java,v 1.2 2001/01/07 23:14:41 peter Exp $
  - *   Currently locked by:$Locker:  $
  - *   Revision:
  - *   $Log: IdGeneratorBean.java,v $
  - *   Revision 1.2  2001/01/07 23:14:41  peter
  - *   Trying to get JAAS to work within test suite.
  - *
  - *   Revision 1.1  2000/08/25 13:43:40  oberg
  - *   Added perf tests and idgen
  - *
  - *
  - *  
  - */
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to