Guest User

Untitled

a guest
Jun 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @EJB(jndi="java:global/moduleName/ConcreteClassName:fullyQualifiedInterfaceName")
  2. ServiceI service;
  3.  
  4. public abstract class Employee{
  5. String name;
  6. SalaryCalcService salaryService;
  7. }
  8.  
  9. public interface SalaryCalcService {
  10. public double abstract calculateSalary();
  11. }
  12.  
  13. public class PerMonthCalc implements SalaryCalcService {
  14. public double calculateSalary(Employee emp){
  15. //return something relevant....
  16. }
  17. }
  18.  
  19. public class PerHourCalc implements SalaryCalcService {
  20. public double calculateSalary(Employee emp){
  21. //return something relevant....
  22. }
  23. }
  24.  
  25. SalaryCalcService perMonth = new PerMonthCalc();
  26. SalaryCalcService perHour = new PerHourCalc();
  27.  
  28. Employee emp1 = new Employee();
  29. emp1.serSalaryService(perMonth);
  30. //...
  31.  
  32. for(Employee emp : employees){
  33. double salary = emp.getSalaryService().calculateSalary();
  34. }
Add Comment
Please, Sign In to add comment