• 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/39

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;

39 Cards in this Set

  • Front
  • Back
What is IOC?
calling code has the ability to customize the calling methods according to an external configuration (XML) file. IOC is used heavily in all frameworks such as Spring, Struts, and EjB. The most common implementation of IOC is dependency injection.
What is dependency injection?
Builder pattern to obtain valid instances of your object's dependencies and pass them to your object during the object's creation and/or initialization. Using polymorphism and interfaces, declaratively express dependencies through a configuration medium (like XML). The main goal is to decouple classes and test concrete classes in isolation.
What are the different types of dependency injection and which does Spring support?
constructor, setter, interface; constructor & setter
What are the benefits of IOC ?
minimizes code, more testable, supports loose coupling, eager instatation and lazy loading services

What is Spring ?
open source framework, advantages of the Spring framework is its layered architecture
What are some features of Spring ?
Lightweight, IOC (inversion of control), AOP (Aspect oriented programming), container, mvc framework, transaction management, jdbc exception handling
name the modules of spring
core container, test, AOP, instrumentation, web and remoting, data access and integration
what is bean factory?

factory class that contains a collection of beans., create associations between collaborating objects

What is Application Context?
same as a bean factory.Both load bean definitions, wire beans together, and dispense beans upon request, ApplicationContext will preinstantiate singleton beans, resolving text messages, generic way to load file resources, Events to beans that are registered as listeners.
What are the common implementations of the Application Context ?
ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, XmlWebApplicationContext
What is the typical Bean life cycle in Spring Bean Factory Container ?
e spring container finds the bean’s definition from the XML file and instantiates the bean, Using the dependency injection, spring populates all of the properties as specified in the bean definition, If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID., If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself., If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called., If an init-method is specified for the bean, it will be called., Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.
What do you mean by bean wiring ?
creating associations between application components (beans) within the Spring container
What do you mean by autowiring?
The Spring container is able to autowire relationships between collaborating beans. autowiring functionality has four modes; byName, byType, constructor, autodetect
Name the design pattern used in the Spring MVC architecture and the control element?

spring mvc - Front Controller pattern.


control element- Dispatcher Servlet

What does DefaultAnnotationHandlerMapping do in Spring MVC?
used by DispatcherServlet to map requests to specific controllers and controller methods annotated with @RequestMapping.
What does the ViewResolver do in Spring MVC?
exchanges a logical view name supplied by the controller for a an actual view (JSP) that renders the result.
How do you turn ON annotation support in Spring MVC?
Use <mvc:annotation-driven/> in mvc-dispatcher-servlet.xml
List the annotations used to configure a basic controller class in Spring MVC.

@Controller


@RequestMapping

How do you turn ON annotation-based autowiring in Spring?
To turn ON autowiring use the <context:annotation-config/> tag in the spring xml.
How does the @Autowired annotation work?

It is used to automatically wire values into properties, methods, and constructors.


Bean properties can be annotated direcly allowing removal of the setters in the class and the property tags in the spring xml. If no bean is found to wire to the annotated property a NoSuchBeanDefinitionException is thrown by default.

What annotations are used to register a class as a spring bean?
component, controller, repository, service
How do you integrate Struts with Spring?
Install the ContextLoaderPlugin in struts-config.xml, In the "type" attribute of the action tag use: org.springframework.web.struts.DelegatingActionProxy., In action-servlet.xml map the HTML action to the action class and reference the injected bean., In appContext.xml map the injected bean to a bean class., In the action class install a setter for the injected bean.
What ORMs does Spring support ?
hibernate, iBatis, JPA, toplink, JDO, OJB

What are the ways to access Hibernate using Spring?

Hibernate Contextual Sessions (newer)


HibernateTemplate (older)

How do you integrate Spring and Hibernate using Contextual Sessions?

XML approach:


Create the DaoImpl class with a setter for the Session Factory., Wire up the following beans: DataSource, SessionFactory, HibernateTransactionManager, and DaoImpl class., Bind each CRUD method to a transaction in the appContext.xml. Define the AOP configuarion using the aop:config tags and the transaction advice using the tx:advice tags and the transaction properties (propagation, isolation, and rollback) for each method with the tx:method tags.


Annotation approach:


Create the annotated (@Repository) DaoImpl class with an annotated (@Inject) sessionFactory., Wire up the following beans: DataSource, SessionFactory, and HibernateTransactionManager in the appContext.xml, Use context:component-scan to find the annotated classes. Include a PersistenceExceptionTranslationPostProcessor bean definition to convert platform specific exceptions to a richer set of Spring runtime data access exceptions., Bind and annotate (@Transactional) each CRUD method to a transaction in the DaoImpl class and use the tx:annotation-driven tag in appContext.xml.

Define HibernateTemplate.
helper class which provides different methods for querying/retrieving data from the database. It also converts checked HibernateExceptions into unchecked DataAccessExceptions.
What benefits does the HibernateTemplate provide?
HibernateTemplate, a Spring Template class simplifies interactions with Hibernate Session. , Common functions are simplified to single method calls., Sessions are automatically closed. , Exceptions are automatically caught and converted to runtime exceptions.
How did you integrate Spring and Hibernate using Template Injection?
Wire up the following beans in the spring.xml: DataSource, SessionFactory, HibernateTransactionManager, and DaoImpl class., Place a setter for the HibernateTemplate in the DaoImpl class and, Create an anonymous inner class to implement the doInHibernate method of the Callback interface and place the desired Template CRUD method there. Pass the inner class object to the Template execute method to invoke the desired CRUD operation.
What are Bean scopes in Spring Framework ?
singleton, prototype, request, session, global session
What is AOP?
Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns, or behavior that cuts across the typical divisions of responsibility, such as logging and transaction management. The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules.
How is AOP used in Spring?
provide declarative enterprise services, especially as a replacement for EJB declarative services
What do you mean by Aspect ?
A modularization of a concern that cuts across multiple objects. , implemented using aspect annotation
What do you mean by 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 do you mean by Advice?
Action taken by an aspect at a particular join point.
What are the types of Advice?
introduction, before advice, after returning advice, after throwing advice, after finally advice, around advice
What are the types of the transaction management Spring supports?
Programmatic transaction management., Declarative transaction management.
What are the benefits of the Spring Framework transaction management?
Provides a consistent programming model across different transaction APIs such as JTA, JDBC, Hibernate, JPA, and JDO., Supports declarative transaction management., Provides a simpler API for programmatic transaction management than a number of complex transaction APIs such as JTA., Integrates very well with Spring’s various data access abstractions.
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. On the other hand, if your application has numerous transactional operations, declarative transaction management is usually worthwhile.
What is Spring's jdbc template?

Spring’s JdbcTemplate is central class to interact 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);