Class TellerEJB
- java.lang.Object
-
- ejava.examples.ejbsessionbank.ejb.TellerEJB
-
- All Implemented Interfaces:
Teller,TellerLocal,TellerRemote
public class TellerEJB extends Object implements TellerLocal, TellerRemote
This class implements a Stateless Session Bean wrapper around the Teller business logic. With the light-weight EJB3 design for session beans, there is no reason why the TellerImpl couldn't be the session bean and we could possibly do so through the deployment descriptor. However, adding this specific class permits a clear separation between implementing the business logic and handling RMI, transactions, and security (coming) issues that are part of being a session bean.
-
-
Field Summary
Fields Modifier and Type Field Description protected SessionContextctxprotected StringdaoClassNameprotected EntityManageremThe peristence context will be defined as a property to allow a derived class to override this value and assist in unit testing.private static org.slf4j.Loggerlogprivate StatsLocalstatsprotected Tellerteller
-
Constructor Summary
Constructors Constructor Description TellerEJB()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OwneraddOwner(long ownerId, String accountNumber)voidclose()This method will perform one-time cleanup for the object.AccountcloseAccount(String acctNum)AccountcreateAccount(String accountNumber)OwnercreateOwner(String firstName, String lastName, String ssn)private voiddebug()AccountgetAccount(String acctNum)List<Account>getAccounts(int index, int count)LedgergetLedger()LedgergetLedger2()This method takes advantage of the DAO/Business logic knowledge of how to create a DTO.doublegetLedgerAveBalance()This method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.longgetLedgerCount()This method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.doublegetLedgerSum()This method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.List<Account>getOverdrawnAccounts(int index, int count)List<Owner>getOwners(int index, int count)List<OwnerDTO>getOwnersDTO(int index, int count)List<Owner>getOwnersLoaded(int index, int count)List<Owner>getOwnersPOJO(int index, int count)voidinit()This method performs one-time initialization for the session bean.OwneropenAccount(long ownerId, String accountNumber)voidremoveOwner(long ownerId)voidupdateAccount(Account account)StringwhoAmI()
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
ctx
protected SessionContext ctx
-
em
protected EntityManager em
The peristence context will be defined as a property to allow a derived class to override this value and assist in unit testing.
-
daoClassName
protected String daoClassName
-
stats
private StatsLocal stats
-
teller
protected Teller teller
-
-
Method Detail
-
init
@PostConstruct public void init()
This method performs one-time initialization for the session bean. The name of the DAO class is provided through a JNDI ENC property value.
-
close
@PreDestroy public void close()
This method will perform one-time cleanup for the object. There is really nothing that needs to be done at this time. The operations supplied demo some types of cleanup that could be done.
-
createAccount
public Account createAccount(String accountNumber) throws BankException
- Specified by:
createAccountin interfaceTeller- Throws:
BankException
-
closeAccount
public Account closeAccount(String acctNum) throws BankException
- Specified by:
closeAccountin interfaceTeller- Throws:
BankException
-
getAccount
public Account getAccount(String acctNum) throws BankException
- Specified by:
getAccountin interfaceTeller- Throws:
BankException
-
getOverdrawnAccounts
public List<Account> getOverdrawnAccounts(int index, int count) throws BankException
- Specified by:
getOverdrawnAccountsin interfaceTeller- Throws:
BankException
-
getAccounts
public List<Account> getAccounts(int index, int count) throws BankException
- Specified by:
getAccountsin interfaceTeller- Throws:
BankException
-
updateAccount
public void updateAccount(Account account) throws BankException
- Specified by:
updateAccountin interfaceTeller- Throws:
BankException
-
getLedger
public Ledger getLedger() throws BankException
- Specified by:
getLedgerin interfaceTeller- Throws:
BankException
-
getLedger2
public Ledger getLedger2() throws BankException
This method takes advantage of the DAO/Business logic knowledge of how to create a DTO. Note that the query is not actually known to the business logic or DAO. It is expressed in an ORM.xml file.- Specified by:
getLedger2in interfaceTellerRemote- Throws:
BankException
-
getLedgerAveBalance
public double getLedgerAveBalance() throws BankExceptionThis method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.- Specified by:
getLedgerAveBalancein interfaceTeller- Throws:
BankException
-
getLedgerCount
public long getLedgerCount() throws BankExceptionThis method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.- Specified by:
getLedgerCountin interfaceTeller- Throws:
BankException
-
getLedgerSum
public double getLedgerSum() throws BankExceptionThis method is and example of a method that may be too fine for a remote method and should be encapsulated in a remote facade call.- Specified by:
getLedgerSumin interfaceTeller- Throws:
BankException
-
debug
private void debug()
-
addOwner
public Owner addOwner(long ownerId, String accountNumber) throws BankException
- Specified by:
addOwnerin interfaceTeller- Throws:
BankException
-
createOwner
public Owner createOwner(String firstName, String lastName, String ssn) throws BankException
- Specified by:
createOwnerin interfaceTeller- Throws:
BankException
-
openAccount
public Owner openAccount(long ownerId, String accountNumber) throws BankException
- Specified by:
openAccountin interfaceTeller- Throws:
BankException
-
removeOwner
public void removeOwner(long ownerId) throws BankException- Specified by:
removeOwnerin interfaceTeller- Throws:
BankException
-
getOwners
public List<Owner> getOwners(int index, int count) throws BankException
- Specified by:
getOwnersin interfaceTeller- Throws:
BankException
-
getOwnersLoaded
public List<Owner> getOwnersLoaded(int index, int count) throws BankException
- Specified by:
getOwnersLoadedin interfaceTellerRemote- Throws:
BankException
-
getOwnersPOJO
public List<Owner> getOwnersPOJO(int index, int count) throws BankException
- Specified by:
getOwnersPOJOin interfaceTellerRemote- Throws:
BankException
-
getOwnersDTO
public List<OwnerDTO> getOwnersDTO(int index, int count) throws BankException
- Specified by:
getOwnersDTOin interfaceTellerRemote- Throws:
BankException
-
whoAmI
public String whoAmI()
- Specified by:
whoAmIin interfaceTellerRemote
-
-