-
What is web module?
Spring comes with a full-featured MVC framework for building web applications.
Although Spring can easily be integrated with other MVC frameworks, such as
Struts, Spring’s MVC framework uses IoC to provide for a clean separation of
controller logic from business objects. It also allows you to declaratively
bind request parameters to your business objects. It also can take advantage
of any of Spring’s other services, such as I18N messaging and validation.
-
What is a BeanFactory?
A BeanFactory is an implementation of the factory pattern that applies
Inversion of Control to separate the application’s configuration and
dependencies from the actual application code.
-
What is AOP Alliance?
AOP Alliance is an open-source project whose goal is to promote adoption of
AOP
and interoperability among different AOP implementations by defining a common
set of interfaces and components.
-
What is Spring configuration file?
Spring configuration file is an XML file. This file contains the classes
information and describes how these classes are configured and introduced to
each other.
-
What does a simple spring application contain?
These applications are like any Java application. They are made up of several
classes, each performing a specific purpose within the application. But these
classes are configured and introduced to each other through an XML file. This
XML file describes how to configure the classes, known as the Spring
configuration file.
-
What is XMLBeanFactory?
BeanFactory has many implementations in Spring. But one of the most
useful one is org.springframework.beans.factory.xml.XmlBeanFactory,
which loads its beans based on the definitions contained in an XML file. To
create an XmlBeanFactory, pass a java.io.InputStream to the
constructor. The InputStream will provide the XML to the factory. For
example, the following code snippet uses a java.io.FileInputStream to
provide a bean definition XML file to XmlBeanFactory.
-
|
BeanFactory
factory = new XmlBeanFactory(new
FileInputStream("beans.xml"));
|
To retrieve the bean from a BeanFactory, call the getBean()
method by passing the name of the bean you want to retrieve.
-
|
MyBean myBean =
(MyBean) factory.getBean("myBean");
|
-
What are important ApplicationContext implementations in spring
framework?
-
ClassPathXmlApplicationContext – This context loads a context
definition from an XML file located in the class path, treating context
definition files as class path resources.
-
FileSystemXmlApplicationContext – This context loads a context
definition from an XML file in the filesystem.
-
XmlWebApplicationContext – This context loads the context
definitions from an XML file contained within a web application.
-
Explain Bean lifecycle in Spring framework?
1. The spring container finds the bean’s
definition from the XML file and instantiates the bean.
2. Using the dependency injection,
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 bean wiring?
Combining together beans within the Spring container is known as bean wiring
or wiring. When wiring beans, you should tell the container what beans are
needed and how the container should use dependency injection to tie them
together.
-
How do add a bean in spring application?
-
|
<?xml
version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans
PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="foo"
class="com.act.Foo"/>
<bean
id="bar" class="com.act.Bar"/>
</beans>
|
In the bean tag the id attribute specifies the bean name and the class
attribute specifies the fully qualified class name.
java6 ejb3 jsf hibernate eclipse ajax groovy spring seam java struts webservice j2me guice java5 jca tapestry soa linux ria books
|