Springs

How is a typical spring implementation look like ?

For a typical Spring Application we need the following files: • An interface that defines the functions. • An Implementation that contains properties, its setter and getter methods, functions etc., • Spring AOP (Aspect Oriented Programming) • A XML file called Spring configuration file. • Client program that uses the function.

What are the common implementations of the Application Context ?

The three commonly used implementation of ‘Application Context’ are • ClassPathXmlApplicationContext : It Loads context definition from an XML file located in the classpath, treating context definitions as classpath resources. The application context is loaded from the application’s classpath by using the code .

ApplicationContext context = new ClassPathXmlApplicationContext(“bean.xml”); • FileSystemXmlApplicationContext : It loads context definition from an XML file in the filesystem. The application context is loaded from the file system by using the code .

ApplicationContext context = new FileSystemXmlApplicationContext(“bean.xml”); • XmlWebApplicationContext : It loads context definition from an XML file contained within a web application.

More >

What are features of Spring ?

• Lightweight: spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 1MB. And the processing overhead is also very negligible. • Inversion of control (IOC): Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects. • Aspect oriented (AOP): Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services. • Container: Spring contains and manages the life cycle and configuration of application objects. • MVC Framework: Spring comes with More >

How many modules are there in Spring? What are they?

Spring comprises of seven modules. They are.. • The core container: The core container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application’s configuration and dependency specification from the actual application code. • Spring context: The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality. • Spring AOP: The Spring AOP More >

What are the types of Dependency Injection Spring supports?>

• Setter Injection: Setter-based DI is realized by calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean.

• Constructor Injection: Constructor-based DI is realized by invoking a constructor with a number of arguments, each representing a collaborator. Are you a Spring Certified developer ? Spring Certification

What is Application Context?

A bean factory is fine to simple applications, but to take advantage of the full power of the Spring framework, you may want to move up to Springs more advanced container, the application context. On the surface, an application context is same as a bean factory.Both load bean definitions, wire beans together, and dispense beans upon request. But it also provides: • A means for resolving text messages, including support for internationalization. • A generic way to load file resources. • Events to beans that are registered as listeners.

What are the benefits of IOC (Dependency Injection)?

Benefits of IOC (Dependency Injection) are as follows • Minimizes the amount of code in your application. With IOC containers you do not care about how services are created and how you get references to the ones you need. You can also easily add additional services by adding a new constructor or a setter method with little or no extra configuration. • Make your application more testable by not requiring any singletons or JNDI lookup mechanisms in your unit test cases. IOC containers make unit testing and switching implementations very easy by manually allowing you to inject your own objects More >

What are the advantages of Spring framework?

The advantages of Spring are as follows: • Spring has layered architecture. Use what you need and leave you don’t need now. • Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming enables continuous integration and testability. • Dependency Injection and Inversion of Control Simplifies JDBC • Open source and no vendor lock-in.

What are the different types of IOC (dependency injection) ?

There are three types of dependency injection: • Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters. • Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods). • Interface Injection (e.g. Avalon): Injection is done through an interface. Note: Spring supports only Constructor and Setter Injection