Posts

Showing posts from August 9, 2018

Pizza-making combining two builder patterns (Bloch's and Go4)

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 3 down vote favorite I think I just made a very simple way to implement both builder patterns: Bloch builder (for solving telescoping problem). introduction@Medium, Telescoping problem@SO Go4 builder pattern (The most difficult one among those 23) Characters in Go4 builder: Director: Pizza.Maker ConcreteBuilder: Pizza.Recipe I'm also thinking about how to make Builder an abstract interface so one can have more type of recipes (Hot/Sweet/Sour...). The advantages: The client doesn't have to know the ingredient types used by Pizza , just tune the parameters of a pizza using Bloch builder. (In my example it just coincident that they're both int .) The client doesn't have to be an expert in making a pizza, i.e. he/she doesn't have know the actual order of steps of making a pizza, because these steps are handled by the director

Maintaining session timeout globally in java spring configuration

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 2 down vote favorite Below is my code to maintain a session timeout globally in Java spring configuration and to load the session timeout value from a properties file. Do you have any suggestions to improve my code? public class MySessionListener implements HttpSessionListener @Override public void sessionCreated(HttpSessionEvent event) try ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream stream = classLoader.getResourceAsStream("bimspring.properties"); Properties properties = new Properties(); properties.load(stream); String sessionTimeout = properties.getProperty("cookieName", "No Value Found"); event.getSession().setMaxInactiveInterval(Integer.parseInt(sessionTimeout)); catch (IOException e) e.printStackTrace(); @Override public void sessionDestroyed(HttpSessi