Last active
April 30, 2020 12:45
-
-
Save anirudh83/745ca9d4c2e8161e8957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EndpointA { | |
private UserService userService; | |
private AService aService; | |
/*constructor */ | |
public EndpointA(UserService userService,AService aService){ | |
this.userService = userService; | |
this.aService= aService; | |
} | |
} | |
public class EndpointB { | |
private UserService userService; | |
/*constructor */ | |
public EndpointB(UserService userService){ | |
this.userService = userService; | |
} | |
} | |
public class UserServiceImpl implements UserService { | |
private static final _INSTANCE = new UserServiceImpl(); | |
public static UserService getInstance(){ | |
return _INSTANCE; | |
} | |
private UserServiceImpl(){} | |
} | |
public class AServiceImpl implements AService { | |
private static final _INSTANCE = new AServiceImpl(); | |
public static AService getInstance(){ | |
return _INSTANCE; | |
} | |
private AServiceImpl(){} | |
} | |
public class EndpointFactory{ | |
public EndpointA createEndpointA(){ | |
return new EndpointA(UserService.getInstance(),AService.getInstance()); | |
} | |
public EndpointB createEndpointB(){ | |
return new EndpointB(UserService.getInstance()); | |
} | |
} | |
public class Test{ | |
@Test | |
public void init(){ | |
EndpointFactory endpointFactory = new EndpointFactory(); | |
EndpointA endpointA = endpointFactory.createEndpointA(); | |
EndpointB endpointb = endpointFactory.createEndpointB(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment