andyshon

Factory.java

Oct 4th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. package com.andyshon;
  2.  
  3. /**
  4.  * Created by andys_000 on 02.10.2017.
  5.  */
  6. public class Factory {
  7.     private static BusDAO busDAO = null;
  8.     private static DriverDAO driverDAO = null;
  9.     private static RouteDAO routeDAO = null;
  10.     private static Factory instance = null;
  11.  
  12.     public static synchronized Factory getInstance(){
  13.         if (instance == null){
  14.             instance = new Factory();
  15.         }
  16.         return instance;
  17.     }
  18.  
  19.     public BusDAO getBusDAO(){
  20.         if (busDAO == null){
  21.             busDAO = new BusDAOImpl();
  22.         }
  23.         return busDAO;
  24.     }
  25.  
  26.     public DriverDAO getDriverDAO(){
  27.         if (driverDAO == null){
  28.             driverDAO = new DriverDAOImpl();
  29.         }
  30.         return driverDAO;
  31.     }
  32.  
  33.     public RouteDAO getRouteDAO(){
  34.         if (routeDAO == null){
  35.             routeDAO = new RouteDAOImpl();
  36.         }
  37.         return routeDAO;
  38.     }
  39. }
Add Comment
Please, Sign In to add comment