service locator pattern
This commit is contained in:
parent
78a6c223eb
commit
81b9a8971e
|
@ -6,7 +6,13 @@ package com.baeldung.designpatterns.service.locator;
|
|||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
MessagingService service = ServiceLocator.getService("EmailService");
|
||||
service.getMessageBody();
|
||||
String email = service.getMessageBody();
|
||||
System.out.println(email);
|
||||
|
||||
service = ServiceLocator.getService("SMSService");
|
||||
String sms = service.getMessageBody();
|
||||
System.out.println(sms);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.baeldung.designpatterns.service.locator;
|
|||
* Created by Gebruiker on 4/20/2018.
|
||||
*/
|
||||
public class ServiceLocator {
|
||||
|
||||
private static Cache cache;
|
||||
|
||||
static {
|
||||
|
|
Loading…
Reference in New Issue