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

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;

37 Cards in this Set

  • Front
  • Back

What is IOC/Inversion of Control

Inversion of Control is a design where a programs flow can be controlled by some kind of external configuration. This could be an XML file or some sort of library. This is used heavily in Spring, struts and EJBs.

What is dependency Injection?

Dependency Injection is a specific implementation of inversion of control where a dependency is passed to an object. It's used by Spring.

What are the different types of dependency injection and which does Spring support?

Constructor Injection


Setter Injection


Interface Injection



Spring only supports Constructor and Setter

What are the benefits of IOC?

-Minimizes Code


-Makes an application more testible due to modularity.


-Loose coupling is promoted, and can help replace more intrusive patterns like the Factory pattern to get or place objects.


-IOC containers also support eager instantiating and lazy loading of services, manage object lifecycles, and resolve dependencies.

What is Spring?

Spring is an open source framework created to address the complexity of Enterprise Application Development. It has a layered architecture which allows for better integration of other web application components.

What are some features of Spring?

-Lightweight - low processing overhead.


-IOC allows for loose coupling


-Aspect Oriented Programming is supported.


-Its container helps manage the life cycle and configuration of objects.


-Spring comes with an MBC web application framework, that is highly configurable and supports many other technologies like JSP, Velocity, and Tiles.


-Provides a generic abstraction layer for transaction management.


-And provides for a more meaningful way of handling JDBC Exceptions, with support for database services like Hibernate, JDO, and Ibatis.

What are the modules of Spring?

Core Container


Test


AOP


Instrumentation


Web and Remoting


Data Access and Integration.

What is a Bean Factory in Spring?

Its like a factory class that manages a collection of beans. It holds bean definitions and can distribute those beans on a client's request. It supports custom init and destruction methods too for beans.

What is the difference between Application Context?

In addition to having the bean factory functinos. It also is able to resolve text messages, provides a generic way to load file resources, and can publish events to beans registered as listener.

What are the different implementations of the ApplicationContext?

ClassPathXmlApplicationContext


FileSystemXmlApplicationContext


XMLWebApplicationContext

What is the bean life cycle in the Spring bean Container?

1.A bean definition is retrieved and the bean is instantiated.


2.The properties of the bean are populated using the definition.


3. BeanNameAware setBeanName


4. BeanFactoryAware setBeanFactory


5. BeanPostProcessor postProcessBeforeInitialization()


6. custom init method if exists.


7. BeanPostProcessor postProcessAfterInitialization.


8. Bean is usable by the client.

What is Bean Wiring?

Creating associations between application components or beans inside Spring.

What do you mean by autowiring.

An automatic bean wiring done by the spring container. It has 4 modes.


byName


byType


byConstructor


autowire.

What design pattern is used by Spring MVC?

Front Controller, which is a DispatcherServlet

What does the view resolver do.

After a controller does its processing, the view resolver resolves the logical name provided by the controller with its associated jsp, and prepares it to be sent to the client.

What does DefaultAnnotationHandlerMapping do. XML configuration?

This allows controllers and controller methods to be mapped using annotations rather than



You must have a <context:component-scan>(to discover and register controllers) and <mvc:annotationdriven>(to turn on annotation support) in your dispatcher servlet configuration though.

How do you turn on annotation based bean wiring?

You need to have the <context:annotation-config> tag in your xml. This enables @Autowired @Inject and @Resource

How does @Autowired work?

Its used to specify autowiring on properties, methods and constructors. It can be more selectively used, and can bypass a lack of setters for a property.



However if no bean is found to wire with the annotated item, a NoSuchBeanDefinitionException will be thrown.

What are the annotations used to register a class as a Spring Bean?

After enabling <context:component-scan>


@Component


@controller


@Repository


@Service

How do you integrate Struts With Spring

1.Install the context loader plugin in struts-config.xml


2.In the type attribute, specify it as a DelegatingActionProxy


3.in action-servlet.xml map the html action to the action class and reference the injected bean.


4. in applicationcontet.xml, map the injected bean to a bean class.


5.in the action class isntall a setter for the injected bean.

What ORMs does Spring support?

Hibernate,


Ibatis,


TopLink,


JDO


JPA


OJB

What are the ways to access Hibernate using Spring?

Two popular approachs are the Hibernate Contextual Sessions and the HibernateTemplate.

How do you integrate Spring and Hibernate using Contextual Sessions?

XML


1. Create the DaoImpl class with a setter for the session factory.


2.Wire the DataSource, SessionFactory, HibernateTransactionManager, and DaoImpl class.


3. Bind each CRUD method to a transaction.



Annotations


1.Create the annotated @Repository DaoImpl class with an annotated @Inject sessionFactory.


2.Wire the classes DataSource, SessinoFactory, HibernateTransactionManager, in the app context.xml


3.Enable annotations using <context:componentscan>


4. Bind and annotate @Transactional for each Crud method and use the tx:annotation-driven tag in the application context.


5. Include a PersistencExceptionTranslationPostProcessor bean definitino to convert platform specific exceptions to a richer set of Spring runtime data access exceptions

What is the HibernateTemplate?

The Hibernate Template is a helper class which provides different methods for querying, retriving data from the database and converts HibernateExceptions into unchecked DataAccessExceptions.

What benefits does the Hibernate Template Provide?

The Hibernate Template provides.


1.Common functions are simplified to single method calls.


2.Simplifies transactions and session management.


3. and exceptions are automatically caught and converted to runtime exceptions.

How do you integrate Spring and Hibernate using Template Injection?

Wire the DataSource, SessionFactory, and HibernateTransactionManager and the DaoImpl class in the spring.xml



Place a setter for the Hibernate Template in the daoimpl class.



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 the bean scopes in the Spring framework?

Singleton (single bean to a single object instance within the Spring IoC container)


Prototype (single definition to any number of instances)


Request (httprequest )


Session (httpsession)


GlobalSession (lifecycle of global http session)

What is AOP?

Aspect Oriented Programming facilitates the modularizing of crosscutting concerns, like logging and transaction management. It encapsulates common behavior into reusable modules.

How is AOP used in Spring?

The Big one is Declarative Transaction Management, which assists and simplifying executing transactions.

What is an Aspect?

A modularizing of a cross cutting concern. In Java its a regular class thats either mapped in an xml or annotated with the @Aspect annotation.

Join Point?

A point during the execution of a program where an Aspect can interject. In Spring, its during a method execution.

What is Advice in AOP?

An action taken by an aspect at a particular join point.

What are the different types of advice?

Before


After


AfterThrowing


AfterReturning


Around



Introduction(cannot be used with any point cut. Only applies at class level. You can only use itnroduction advice with the introduction advisor)

What types of transaction management does Spring support?

Programmatic and Declarative.

What are the benefits of the Spring Framework for transaction management?

Supports Declarative Transaction Management and provides a simpler api for programmatic transaction management.



Integrates with Spring's data access Transactions.



Provides a consistent programming model across different transaction APIs like Hibernate, JTA, JDBC, JPA, and JDO

What should you use programmatic or declarative transaction management?

Use programmatic when you have a small number of simple transactions.



Use declarative when you have numerous complex transactions.

What is Spring's JDBC template?

The JDBC template is Spring's central class for interacting with a database through JDBC. It provides methods for doing things like converting database data into primitives and objects, executing statements, and more meaningful error handling tools.