001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.daytrader.ejb;
018    
019    
020    import javax.ejb.*;
021    
022    import org.apache.geronimo.samples.daytrader.util.*;
023    
024    import java.util.Collection;
025    import org.apache.geronimo.samples.daytrader.*;
026    
027    
028    public abstract class KeyGenBean
029                    implements EntityBean {
030    
031        private EntityContext context;
032    
033        /* Accessor methods for persistent fields */
034    
035    
036        public abstract String              getKeyName();                           /* Unique Primary Key name */
037            public abstract void            setKeyName(String KeyName);
038        public abstract int                 getKeyVal();                            /* Value for PK */
039        public abstract void                setKeyVal(int keyVal);
040    
041        /* Accessor methods for relationship fields */
042       
043        /* Select methods */
044    
045        /* Business methods */
046        
047        public Collection allocBlockOfKeys()
048        {
049                    int min = getKeyVal();
050                            int max = min+TradeConfig.KEYBLOCKSIZE;
051                            setKeyVal(max);
052                            return new KeyBlock(min, max-1);
053        }
054    
055        /* Required javax.ejb.EntityBean interface methods */
056        public String ejbCreate (String keyName)
057        throws CreateException {
058    
059            setKeyName(keyName);
060                    setKeyVal(0);
061            return null;
062        }
063    
064    
065        public void ejbPostCreate (String keyName)          
066            throws CreateException {
067            }
068                
069        public void setEntityContext(EntityContext ctx) {
070            context = ctx;
071            }
072        
073        public void unsetEntityContext() {
074            context = null;
075        }
076        
077        public void ejbRemove() {
078        }
079        
080        public void ejbLoad() {
081        }
082        
083        public void ejbStore() {
084        }
085        
086        public void ejbPassivate() { 
087        }
088        
089        public void ejbActivate() { 
090        }
091    }