| 1 4 package com.nightlabs.ipanema.accounting; 5 6 import java.rmi.RemoteException ; 7 import java.util.ArrayList ; 8 import java.util.Collection ; 9 import java.util.Iterator ; 10 11 import javax.ejb.CreateException ; 12 import javax.ejb.EJBException ; 13 import javax.ejb.SessionBean ; 14 import javax.ejb.SessionContext ; 15 import javax.jdo.FetchPlan; 16 import javax.jdo.PersistenceManager; 17 18 import org.apache.log4j.Logger; 19 20 import com.nightlabs.ModuleException; 21 import com.nightlabs.ipanema.base.BaseSessionBeanImpl; 22 import com.nightlabs.jdo.NLJDOHelper; 23 24 32 public abstract class AccountingManagerBean 33 extends BaseSessionBeanImpl 34 implements SessionBean  35 { 36 public static final Logger LOGGER = Logger.getLogger(AccountingManagerBean.class); 37 38 41 public void setSessionContext(SessionContext sessionContext) 42 throws EJBException , RemoteException  43 { 44 LOGGER.debug(this.getClass().getName() + ".setSessionContext("+sessionContext+")"); 45 super.setSessionContext(sessionContext); 46 } 47 50 public void unsetSessionContext() { 51 super.unsetSessionContext(); 52 } 53 57 public void ejbCreate() 58 throws CreateException  59 { 60 LOGGER.debug(this.getClass().getName() + ".ejbCreate()"); 61 } 62 67 public void ejbRemove() throws EJBException , RemoteException  68 { 69 LOGGER.debug(this.getClass().getName() + ".ejbRemove()"); 70 } 71 72 75 public void ejbActivate() throws EJBException , RemoteException  76 { 77 LOGGER.debug(this.getClass().getName() + ".ejbActivate()"); 78 } 79 82 public void ejbPassivate() throws EJBException , RemoteException  83 { 84 LOGGER.debug(this.getClass().getName() + ".ejbPassivate()"); 85 } 86 87 94 public Collection getTariffs(String [] fetchGroups) 95 throws ModuleException 96 { 97 PersistenceManager pm = getPersistenceManager(); 98 try { 99 FetchPlan fetchPlan = pm.getFetchPlan(); 100 for (int i = 0; i < fetchGroups.length; ++i) 101 fetchPlan.addGroup(fetchGroups[i]); 102 103 Collection res = new ArrayList (); 104 for (Iterator it = pm.getExtent(Tariff.class, true).iterator(); it.hasNext(); ) { 105 Tariff t = (Tariff)it.next(); 106 res.add(pm.detachCopy(t)); 107 } 108 109 return res; 110 } finally { 111 pm.close(); 112 } 113 } 114 115 122 public Tariff storeTariff(Tariff tariff) 123 throws ModuleException 124 { 125 PersistenceManager pm = getPersistenceManager(); 126 try { 127 return (Tariff) NLJDOHelper.storeJDO(pm, tariff); 128 } finally { 129 pm.close(); 130 } 131 } 132 133 140 public long createPriceConfigID() 141 throws ModuleException 142 { 143 PersistenceManager pm = getPersistenceManager(); 144 try { 145 return Accounting.getAccounting(pm).createPriceConfigID(); 146 } finally { 147 pm.close(); 148 } 149 } 150 } 151 | Popular Tags |