Hi,

>?am interested to know which topic prompts your question ?
As you can see from the log file (below) the spring framework creates and
destroys a  singleton of a bean.
So the singleton pattern is used by the container.
I was also informed that the singleton is used to create a login screen.
That also appears to be the case from the page
http://www.blackwasp.co.uk/Singleton.aspx.

The login screen I will be using is the login.java and login.jsp in the
struts2  "blank app" in "struts-examples-master".
The struts framework also helps me with duplicate form submission.
So do I need to use the singleton pattern  ?

 2019-12-13 21:01:06,882 [main] [DEBUG]
o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@6f1d30d:
defining beans [numberGenerator]; root of factory hierarchy
2019-12-13 21:01:06,882 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Creating shared instance of singleton bean 'numberGenerator'
2019-12-13 21:01:06,882 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Creating instance of bean 'numberGenerator'
2019-12-13 21:01:06,895 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Eagerly caching bean 'numberGenerator' to allow for resolving potential
circular references
2019-12-13 21:01:06,896 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Finished creating instance of bean 'numberGenerator'
2019-12-13 21:01:06,897 [main] [DEBUG]
o.s.c.s.ClassPathXmlApplicationContext - Unable to locate
LifecycleProcessor with name 'lifecycleProcessor': using default
[org.springframework.context.support.DefaultLifecycleProcessor@d967f908]
2019-12-13 21:01:06,897 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Returning cached instance of singleton bean 'lifecycleProcessor'
2019-12-13 21:01:06,900 [main] [DEBUG]
o.s.c.e.PropertySourcesPropertyResolver - Could not find key
'spring.liveBeansView.mbeanDomain' in any property source
2019-12-13 21:01:06,910 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Returning cached instance of singleton bean 'numberGenerator'
2019-12-13 21:01:06,910 [main] [INFO ] academy.learnprogramming.Main -
number = 0
2019-12-13 21:01:06,912 [main] [INFO ]
o.s.c.s.ClassPathXmlApplicationContext - Closing
org.springframework.context.support.ClassPathXmlApplicationContext@3e92e10:
startup date [Fri Dec 13 21:01:06 GMT 2019]; root of context hierarchy
2019-12-13 21:01:06,912 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Returning cached instance of singleton bean 'lifecycleProcessor'
2019-12-13 21:01:06,912 [main] [DEBUG] o.s.b.f.s.DefaultListableBeanFactory
- Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@6f1d30d:
defining beans [numberGenerator]; root of factory hierarchy

On Fri, 13 Dec 2019 at 01:33, Martin Gainty <mgai...@hotmail.com> wrote:

> Singleton:
> i prefer thread-safe implementations and generally eschew singletons
> (unless extreme political pressure dictates otherwise)
> https://www.geeksforgeeks.org/singleton-design-pattern/
> [https://www.geeksforgeeks.org/wp-content/uploads/gfg_200X200.png]<
> https://www.geeksforgeeks.org/singleton-design-pattern/>
> Singleton Design Pattern | Implementation - GeeksforGeeks<
> https://www.geeksforgeeks.org/singleton-design-pattern/>
> The singleton pattern is one of the simplest design patterns. Sometimes we
> need to have only one instance of our class for example a single DB
> connection shared by multiple objects as creating a separate DB connection
> for every object may be costly. Similarly, there can be a single
> configuration ...
> www.geeksforgeeks.org
>
> Design Patterns:
> have a look at this discussion from stackoverflow on Visitor Pattern vs
> Command Pattern for lambda expresssions
> https://stackoverflow.com/questions/2186931/java-pass-method-as-parameter
> [
> https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-i...@2.png?v=73d79a89bded
> ]<
> https://stackoverflow.com/questions/2186931/java-pass-method-as-parameter>
> interface - Java Pass Method as Parameter - Stack Overflow<
> https://stackoverflow.com/questions/2186931/java-pass-method-as-parameter>
> In Java 8, you can now pass a method more easily using Lambda Expressions
> and Method References. First, some background: a functional interface is an
> interface that has one and only one abstract method, although it can
> contain any number of default methods (new in Java 8) and static methods. A
> lambda expression can quickly implement the abstract method, without all
> the unnecessary syntax ...
> stackoverflow.com
> although this discussion is more specific on when to implement Visitor
> Pattern vs when to use Command Pattern
>
> https://stackoverflow.com/questions/2857880/command-pattern-vs-visitor-pattern
> [
> https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-i...@2.png?v=73d79a89bded
> ]<
> https://stackoverflow.com/questions/2857880/command-pattern-vs-visitor-pattern
> >
> Command Pattern vs. Visitor Pattern - Stack Overflow<
> https://stackoverflow.com/questions/2857880/command-pattern-vs-visitor-pattern
> >
> Each pattern has it's own pros, cons and use cases. You can use Command
> pattern to . Decouple the invoker & receiver of command . Implement
> callback mechanism. Implement undo and redo functionality. Maintain a
> history of commands. Use Visitor pattern in below scenarios:. Similar
> operations have to be performed on objects of different types grouped in a
> structure ; You need to execute many ...
> stackoverflow.com
>
> ?am interested to know which topic prompts your question?
>
> /br/
> Martin
> ________________________________
> From: Lukasz Lenart <lukaszlen...@apache.org>
> Sent: Thursday, December 12, 2019 1:56 AM
> To: Struts Users Mailing List <user@struts.apache.org>
> Subject: Re: Java Singleton , Framework Design Patterns
>
> czw., 12 gru 2019 o 06:13 Zahid Rahman <zahidr1...@gmail.com> napisał(a):
> > So my point is I have not been able to find accurate information , if
> some
> > one could furnish me a Java language specification or recommend  a book
> > which accurately describes these I would be grateful.
>
> Start with Gang of Four
> http://www.blackwasp.co.uk/gofpatterns.aspx
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to