• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/36

Click to flip

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.
BeanFactory is able to create associations between collaborating objects as they are instantiated. This removes the burden of configuration from bean itself and the beans client.
BeanFactory also takes part in the life cycle of a bean, making calls to custom initialization and destruction methods.
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:
* 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 is the difference between Bean Factory and Application Context ?
An application context offers much more than a Bean Factory.
1. Application contexts provide a means for resolving text messages, including support for i18n of those messages.
2. Application contexts provide a generic way to load file resources, such as images.
3. Application contexts can publish events to beans that are registered as listeners.
4. Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context.
5. Application Contexts facilitate Spring’s Resource interface which is a flexible generic abstraction for handling low-level resources. An application context itself is a ResourceLoader, Hence they provide an application with access to deployment-specific Resource instances.
6. MessageSource support: The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable.
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:
1. Configure Spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a Spring context file.
2. Subclass Spring's ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method.
What are examples of ORM’s Spring supports?
Hibernate
iBatis
JPA (Java Persistence API)
TopLink
JDO (Java Data Objects)
OJB
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.
1. Configure the Hibernate SessionFactory
2. Extend your DAO Implementation from HibernateDaoSupport
3. Wire in Transaction Support with AOP
What are the bean scopes in the Spring Framework ?
1. Singleton
2. Prototype
3. Request (web aware applicationContext only)
4. Session (web aware applicationContext only)
5. Global Session (web aware applicationContext only)

Singleton - Scopes a single bean definition to a single object instance per Spring IoC container.
Prototype - Scopes a single bean definition to any number of object instances.
Request - Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext.
Session - Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.
Global Session - Scopes a single bean definition to the lifecycle of a global HTTP Session. Typically only valid when used in a portlet context. Only valid in the context of a web-aware Spring ApplicationContext.
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
2. After Returning
3. After Throwing
4. After Finally
5. Around

Before - Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception).
After Returning - Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception.
After Throwing - Advice to be executed if a method exits by throwing an exception.
After Finally - Advice to be executed regardless of the means by which a join point exits (normal or exceptional return).
Around - Advice that surrounds a join point such as a method invocation. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It is also responsible for choosing whether to proceed to the join point or to shortcut the advised method execution by returning its own return value or throwing an exception
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.
2. It supports declarative transaction management.
3. It provides a simpler API for programmatic transaction management than a number of complex transaction APIs such as JTA.
4. It integrates very well with Spring's various data access abstractions.
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:
* It is possible to specify transaction behavior (or lack of it) down to individual method level.
* It is possible to make a setRollbackOnly() call within a transaction context if necessary.
The differences are:
* Unlike EJB Container Managed Transactions, which are tied to JTA, Spring's declarative transaction management works in any environment. It can work with JDBC, JDO, Hibernate or other transactions under the covers, with configuration changes only
* Spring enables declarative transaction management to be applied to any class, not merely special classes such as EJBs.
* Spring offers declarative rollback rules: this is a feature with no EJB equivalent. Both programmatic and declarative support for rollback rules is provided.
* Spring gives you an opportunity to customize transactional behavior, using AOP. With EJB CMT, you have no way to influence the container's transaction management other than setRollbackOnly().
* Spring does not support propagation of transaction contexts across remote calls, as do high-end application servers.
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.
JdbcTemplate template = new JdbcTemplate(myDataSource);
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)
Responsible for creating a PreparedStatement.
Does not need to handle SQLExceptions.
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.
Has one method – processRow(ResultSet)
Called for each row in ResultSet.
Typically stateful.
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.
2. byName - Based on the name of a property, a matching bean name in the IoC container will be injected into this property if it exists.
3. byType - Based on the type of class on a setter, if only one instance of the class exists in the IoC container it will be injected into this property. If there is more than one instance of the class a fatal exception is thrown.
4. constructor - Based on a constructor argument's class types, if only one instance of the class exists in the IoC container it will be used in the constructor.
5. autodetect - If there is a valid constructor, the constructor autowiring mode will be chosen. Otherwise if there is a default zero argument constructor the byType autowiring mode will be chosen.