TIL 1
Today I Learned a.k.a TIL
FactoryBean
An amazing way to instantiate your beans based on different situations or conditions.
Example use case: I want a specific implementation of an interface based on some launch date. I can define that in the factory.
public class MessageFactoryBean implements FactoryBean<MessageInterface> {
private MessageInterface postcard;
private MessageInterface letter;
public MessageInterface getObject() {
if (your condition here) {
return letter;
}
return postcard;
}
// other methods omitted
}
Where MessageInterface
is implemented by PostCard
and FormalLetter
.
References:
Caffeinate
Keep your mac from falling asleep
- Open terminal
- Run the command
caffeinate -d
FYI it could stay awake without even blinking for centuries. At least in theory.