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 class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
MessagingService service = ServiceLocator.getService("EmailService");
|
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.
|
* Created by Gebruiker on 4/20/2018.
|
||||||
*/
|
*/
|
||||||
public class ServiceLocator {
|
public class ServiceLocator {
|
||||||
|
|
||||||
private static Cache cache;
|
private static Cache cache;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
Loading…
Reference in New Issue