Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
36 Cards in this Set
- Front
- Back
What is Spring? |
Spring is a set of libraries, frameworks and APIs that support Java "best practices" for ideas like IOC, DI and AOP.
|
|
What is IOC (Inversion Of Control)?
|
This is the Hollywood principle or "Don't call us, we'll call you." This basically means that through Dependency Injection, Objects will be provided references to other Objects created by Spring at Runtime. Callbacks are then used for interaction between Objects.
|
|
What is DI (Dependency Injection)?
|
Objects are given their dependencies at creation time by some external entity that coordinates each object in the system. The advantage is that information present only at Runtime can be acted upon by the system.
|
|
What are 7 benefits of "Inversion Of Control"?
|
1. IOC minimizes the amount of code in your application.
2. With IOC containers you do not care about how services are created or 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. 3. IOC Makes your application more testable by not requiring any singletons or JNDI lookup mechanisms in your unit test cases. 4. IOC containers make unit testing and switching implementations very easy by manually allowing you to inject your own objects into the object under test. 5. Loose coupling is promoted with minimal effort and least intrusive mechanism. The factory design pattern is more intrusive because components or services need to be requested explicitly whereas in IOC the dependency is injected into the appropriate piece of code. Also some containers promote the designing to interfaces rather than to implementations design concept by encouraging managed objects to implement a well-defined service interface. 6. IOC containers support eager instantiation and lazy loading of services. 7. Containers also provide support for instantiation of managed objects, cyclical dependencies, life cycles management, and dependency resolution between managed objects etc. |
|
What is Aspect Orientated Programming (AOP)?
|
In computing, aspect-oriented programming (AOP) is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns.
|
|
Give examples of cross cutting concerns.
|
Logging or Transaction Management are examples as they are likely to be utilized in a wide variety of places throughout the various patterns in the system.
|
|
What is a Bean Factory? |
A BeanFactory is like a factory class that contains a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whenever asked for by clients. |
|
What is an Application Context?
|
A bean factory is fine for simple applications, but to take advantage of the full power of the Spring, you may want to move up to Spring's 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. It also provides: |
|
What is the difference between Bean Factory and Application Context ?
|
An application context offers much more than a Bean Factory. |
|
What are the common implementations of the Application Context ?
|
The three commonly used implementations of 'Application Context' are
1. 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"); 2. 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"); 3. XmlWebApplicationContext : It loads context definition from an XML file contained within a web application. |
|
What does a typical Spring application look like?
|
Typically we would need the following:
* 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 is the typical Bean life cycle in Spring Bean Factory Container ?
|
1. The spring container finds the bean’s definition from the XML file and instantiates the bean.
2. Using DI, spring populates all of the properties as specified in the bean definition. 3. If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID. 4. If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself. 5. If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called. 6. If an init-method is specified for the bean, it will be called. 7. Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called. |
|
What is meant by Bean wiring?
|
The act of creating associations between application components (beans) within the Spring container is reffered to as Bean wiring.
|
|
What is meant by Auto wiring?
|
The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory.
|
|
What is DelegatingVariableResolver?
|
DelegatingVariableResolver is an extension of the standard JSF managed beans mechanism which lets you use JSF and Spring together.
|
|
How does one integrate a Struts application with Spring?
|
Two options: |
|
What are examples of ORM’s Spring supports?
|
Hibernate |
|
What are the 2 ways to access Hibernate using Spring ?
|
IOC with a HibernateTemplate and Callback or an extension of HibernateDaoSupport combined with the application of an AOP Interceptor |
|
How does one integrate Spring and Hibernate using HibernateDaoSupport?
|
Use Spring’s SessionFactory called LocalSessionFactory. The integration process is of 3 steps. |
|
What are the bean scopes in the Spring Framework ?
|
1. Singleton |
|
In the context of AOP what is a Join Point?
|
A point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point always represents a method execution.
|
|
What is AOP Advice?
|
Action taken by an aspect at a particular join point. Different types of advice include "around," "before" and "after" advice. Many AOP frameworks, including Spring, model an advice as an interceptor, maintaining a chain of interceptors "around" the join point.
|
|
What are the 5 types of AOP Advice?
|
1. Before |
|
What are the types of Transaction Management Spring supports?
|
Programmatic and Declarative transaction management. |
|
What are the 4 benefits of the Spring Framework's transaction management ?
|
1. It provides a consistent programming model across different transaction APIs such as JTA, JDBC, Hibernate, JPA, and JDO. |
|
Why do most users of the Spring Framework choose declarative transaction management?
|
Most users of the Spring Framework choose declarative transaction management because it is the option with the least impact on application code, and hence is most consistent with the ideals of a non-invasive lightweight container. |
|
Explain the similarities and differences between EJB CMT and the Spring Framework's declarative transaction management ?
|
The basic approach is similar: |
|
When to use programmatic and declarative transaction management ?
|
Programmatic transaction management is usually a good idea only if you have a small number of transactional operations, Otherwise you are probably going to want declarative transaction management. It keeps transaction management out of business logic, and is not difficult to configure. |
|
Tell me about the Spring DAO support.
|
The Data Access Object (DAO) support in Spring is aimed at making it easy to work with data access technologies like JDBC, Hibernate or JDO in a consistent way. This allows one to switch between the persistence technologies fairly easily and it also allows one to code without worrying about catching exceptions that are specific to each technology. |
|
What are the exceptions thrown by the Spring DAO classes?
|
Spring DAO classes throw exceptions which are subclasses of DataAccessException(org.springframework.dao.DataAccessException).Spring provides a convenient translation from technology-specific exceptions like SQLException to its own exception class hierarchy with the DataAccessException as the root exception. These exceptions wrap the original exception. |
|
What is SQLExceptionTranslator?
|
SQLExceptionTranslator, is an interface to be implemented by classes that can translate between SQLExceptions and Spring's own data-access-strategy-agnostic org.springframework.dao.DataAccessException |
|
What is Spring's JdbcTemplate?
|
Spring's JdbcTemplate is the central class which interacts with a database through JDBC. JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling. |
|
Concerning JdbcTemplate, what is PreparedStatementCreator ?
|
It's one of the most common used interfaces for writing data to database. It has one method – createPreparedStatement(Connection) |
|
Concerning JdbcTemplate, what is SQLProvider ?
|
SQLProvider is a class with one method, getSql().
Typically this is implemented by PreparedStatementCreator implementers and is useful for debugging. |
|
Concerning JdbcTemplate, what is RowCallbackHandler ?
|
The RowCallbackHandler interface extracts values from each row of a ResultSet. |
|
What are the five modes of Spring's autowiring functionality?
|
1. no - No autowiring is performed. All references to other beans must be explicitly injected. This is the default mode. |