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 SessionContext
ctx
protected String
daoClassName
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.private static org.slf4j.Logger
log
private StatsLocal
stats
protected Teller
teller
-
Constructor Summary
Constructors Constructor Description TellerEJB()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Owner
addOwner(long ownerId, String accountNumber)
void
close()
This method will perform one-time cleanup for the object.Account
closeAccount(String acctNum)
Account
createAccount(String accountNumber)
Owner
createOwner(String firstName, String lastName, String ssn)
private void
debug()
Account
getAccount(String acctNum)
List<Account>
getAccounts(int index, int count)
Ledger
getLedger()
Ledger
getLedger2()
This method takes advantage of the DAO/Business logic knowledge of how to create a DTO.double
getLedgerAveBalance()
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.long
getLedgerCount()
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.double
getLedgerSum()
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)
void
init()
This method performs one-time initialization for the session bean.Owner
openAccount(long ownerId, String accountNumber)
void
removeOwner(long ownerId)
void
updateAccount(Account account)
String
whoAmI()
-
-
-
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:
createAccount
in interfaceTeller
- Throws:
BankException
-
closeAccount
public Account closeAccount(String acctNum) throws BankException
- Specified by:
closeAccount
in interfaceTeller
- Throws:
BankException
-
getAccount
public Account getAccount(String acctNum) throws BankException
- Specified by:
getAccount
in interfaceTeller
- Throws:
BankException
-
getOverdrawnAccounts
public List<Account> getOverdrawnAccounts(int index, int count) throws BankException
- Specified by:
getOverdrawnAccounts
in interfaceTeller
- Throws:
BankException
-
getAccounts
public List<Account> getAccounts(int index, int count) throws BankException
- Specified by:
getAccounts
in interfaceTeller
- Throws:
BankException
-
updateAccount
public void updateAccount(Account account) throws BankException
- Specified by:
updateAccount
in interfaceTeller
- Throws:
BankException
-
getLedger
public Ledger getLedger() throws BankException
- Specified by:
getLedger
in 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:
getLedger2
in interfaceTellerRemote
- Throws:
BankException
-
getLedgerAveBalance
public double getLedgerAveBalance() throws BankException
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.- Specified by:
getLedgerAveBalance
in interfaceTeller
- Throws:
BankException
-
getLedgerCount
public long getLedgerCount() throws BankException
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.- Specified by:
getLedgerCount
in interfaceTeller
- Throws:
BankException
-
getLedgerSum
public double getLedgerSum() throws BankException
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.- Specified by:
getLedgerSum
in interfaceTeller
- Throws:
BankException
-
debug
private void debug()
-
addOwner
public Owner addOwner(long ownerId, String accountNumber) throws BankException
- Specified by:
addOwner
in interfaceTeller
- Throws:
BankException
-
createOwner
public Owner createOwner(String firstName, String lastName, String ssn) throws BankException
- Specified by:
createOwner
in interfaceTeller
- Throws:
BankException
-
openAccount
public Owner openAccount(long ownerId, String accountNumber) throws BankException
- Specified by:
openAccount
in interfaceTeller
- Throws:
BankException
-
removeOwner
public void removeOwner(long ownerId) throws BankException
- Specified by:
removeOwner
in interfaceTeller
- Throws:
BankException
-
getOwners
public List<Owner> getOwners(int index, int count) throws BankException
- Specified by:
getOwners
in interfaceTeller
- Throws:
BankException
-
getOwnersLoaded
public List<Owner> getOwnersLoaded(int index, int count) throws BankException
- Specified by:
getOwnersLoaded
in interfaceTellerRemote
- Throws:
BankException
-
getOwnersPOJO
public List<Owner> getOwnersPOJO(int index, int count) throws BankException
- Specified by:
getOwnersPOJO
in interfaceTellerRemote
- Throws:
BankException
-
getOwnersDTO
public List<OwnerDTO> getOwnersDTO(int index, int count) throws BankException
- Specified by:
getOwnersDTO
in interfaceTellerRemote
- Throws:
BankException
-
whoAmI
public String whoAmI()
- Specified by:
whoAmI
in interfaceTellerRemote
-
-