jQuery in Action, 3rd edition
The moose likes Spring and the fly likes Implemention of spring features without using spring. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Implemention of spring features without using spring." Watch "Implemention of spring features without using spring." New topic

Implemention of spring features without using spring.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

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?

Pawan Chopra
John Pradeep.v
Ranch Hand

Joined: Jul 21, 2008
Posts: 59
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

    Joined: Jul 05, 2005
    Posts: 1936
    You can take a look at Spring framework's source code.

    SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
    pawan chopra
    Ranch Hand

    Joined: Jan 23, 2008
    Posts: 415

    Thanks a lot for the information but is there any online article or tutorial which can help me in this?
    Nathan Pruett

    Joined: Oct 18, 2000
    Posts: 4121

    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.

    Write once, run anywhere, because there's nowhere to hide! - /. A.C.
    Hong Anderson
    Ranch Hand

    Joined: Jul 05, 2005
    Posts: 1936
    You can go to Spring website, download source code and read it.
    I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
    subject: Implemention of spring features without using spring.
    It's not a secret anymore!