Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implemention of spring features without using spring.

 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Somebody asked me this question in interview. How will I implement spring features without using Spring framework. Means suppose if I need to create a simple application for login/logout which will have all the features of spring framework without using Spring framework. What are the design patterns I will have to use and where I will use what? Any help on this , any tutorial which can answer this question?


 
John Pradeep.v
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pawan,
Spring provides lot of features the most significat and very much used features are
  • spring DI
  • spring AOP
  • spring JMX
  • spring JDBC



  • in order to use your own Dependency injection, you will have to build the bean manager and provide all the benefits it has which will be huge task if you have to provide all the features of spring DI
    but ofcourse you can make a simple one though

    AOP - spring is the best! there are other AOP tools like AspjectJ but those tools will modify your class files either during compile time or load time of the class
    springs speciality in AOP is that it creates a new class called proxy which will intercept the actual calls and advices the bean.
    again, this feature could be created either by building a tool on top of cglib and dynamic proxies or the next option would be to use AspectJ

    Spring JMX - spring just abstracts the boiler plate code of finding the mbeanserver and registering the mbean with it.
    you can easily build a smiple module to hide the JMX related code and provide a simple API to register MBeans

    spring JDBC - very much like spring JMX where it just hides or abstracts the boilerplate code of opening connection, closing connection etc which you can do it easily

    overall, the last 2 features are just a layer of indirection to the actual technologies! but the first two features are the real features(tools) provided by spring which could be replaced with another tool.
     
    Hong Anderson
    Ranch Hand
    Posts: 1936
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You can take a look at Spring framework's source code.
     
    pawan chopra
    Ranch Hand
    Posts: 417
    jQuery Mac Objective C
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks a lot for the information but is there any online article or tutorial which can help me in this?
     
    Nathan Pruett
    Bartender
    Posts: 4121
    IntelliJ IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No, there's not going to be a single article or tutorial on this. You're actually going to have to learn about design patterns, and use Spring and get familiar with what it does.

    Which makes this a good interview question - it actually requires knowledge and experience - not just memorizing stock answers or APIs.
     
    Hong Anderson
    Ranch Hand
    Posts: 1936
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You can go to Spring website, download source code and read it.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic