• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to intoduce Spring into my sample application for practice?

 
Monica Shiralkar
Ranch Hand
Posts: 842
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have built a small application just for Practice. The user logs in using username and password and if he is a valid user, he can enter a keyword and it fetches records for that keyword. This I have done using Struts1.Now for practice I want to introduce Spring here. What can be a way to include spring here just for practice.Spring IOC or any other component of Spring but I am not able to think of an example of how to include spring here for practice.Please suggest.

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See web integration and the section on Struts 1. This gets your actions to be in a Spring container.

As far as how to use Spring for practice - look for the keyword "new" in your code. Those are opportunities to inject a bean. Look for duplication. Those are opportunities for AOP. Look for JDBC code. These are opportunities for JdbcTemplate.
 
Monica Shiralkar
Ranch Hand
Posts: 842
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.new operator is used immensely in the application.E.g even for creation of Array list. List temp=new ArrayList(). Should even such objects be created from IOC?If no then which one to create
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. ArrayLists make sense to create using "new". I was thinking of your objects (which could be other Spring beans.) For example, your action calls some other object to do business processing or access the database or ...
 
Monica Shiralkar
Ranch Hand
Posts: 842
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I think anything which holds state should be avoided.

For example, your action calls some other object to do business processing ...


I think you mean Business Delegate design pattern.?

 
Monica Shiralkar
Ranch Hand
Posts: 842
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add spring IOC to my Practice web application I could think of the below use case. Please tell whether it is a proper use of Spring IOC:

- I am displaying a message on my web application "This is version 1 of application" or "This is version 2 of application". Instead of hard coding the message I am using Spring IOC and setting it using the Setter message and it can be changed dynamically by changing in the beans Xml.

Is is a proper use of IOC (for practice) ? My aim is just to add sample IOC functionality to my application just for practice.

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic