Last active
December 19, 2017 21:55
-
-
Save mdelano/2fcbde2b8f09d89d860f5ade934e2778 to your computer and use it in GitHub Desktop.
Example singleton pattern with super fake rabbit client
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
/** | |
* My super fake rabbit client wrapper | |
*/ | |
public class MySuperFakeRabbitClientWrapper { | |
private static Logger logger = LoggerFactory.getLogger(MySuperFakeRabbitClientWrapper.class); | |
private static ActualRabbitClient actualRabbitClient; | |
private MySuperFakeRabbitClientWrapper() { | |
// Pseudotastic | |
this.actualRabbitClient = new ActualRabbitClient(); | |
//totally fake | |
this.actualRabbitClient.createNewConnectionPool(); | |
} | |
public static synchronized MySuperFakeRabbitClientWrapper getInstance() { | |
return SingletonHolder.INSTANCE; | |
} | |
private static class SingletonHolder { | |
public static final MySuperFakeRabbitClientWrapper INSTANCE = new MySuperFakeRabbitClientWrapper(); | |
} | |
private static synchronized ActualRabbitClient getRabbitClient() { | |
return this.actualRabbitClient(); | |
} | |
private static synchronized killRabbit() { | |
this.actualRabbitClient.killRabbit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment