Thursday, August 14, 2014

Spring Core Module Questions



What is Spring ?
Spring is an open source framework created to address the complexity of enterprise application development. One of the chief advantages of the Spring framework is its layered architecture, which allows you to be selective about which of its components you use while also providing a cohesive framework for J2EE application development.

What are features of Spring ?
Lightweight:
spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 1MB. And the processing overhead is also very negligible.
Inversion of control (IOC):
Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects.
Aspect oriented (AOP):
Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services.
Container:
Spring contains and manages the life cycle and configuration of application objects.
MVC Framework:
Spring comes with MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework.
Transaction Management:
Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Spring's transaction support is not tied to J2EE environments and it can be also used in container less environments.
JDBC Exception Handling:
The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy. Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services with Hibernate, JDO and iBATIS
  contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
 

.How to read the spring-config.xml?
                                                                   
By  using Application Context interface.its implementation class is used to read spring-confg.xml file

ApplicationContext context =new ClassPathxmlApplication (“spring-config.xml”);


Advantages of spring?

            1. spring is open source and light weight framework

            2. singleton is not required to implement

            3. Transaction logic is just configuration

            4.Exception Handling is very simple

            5.It will simplifiey JDBC coding

            6It will simplifiey ORM coding

            7.Resource closeing is not required while working with spring

            8.It will simplify RMO coding and EJB

How many ways to archive dependency injection?
           
            1. Constructer dependency injection
            2. Setter dependency injection
            3.intrerface injection
           
--àDependencies are provided through the constructer of the component

EX.      Public class ContructerInjection {---àservice
            Private dependency dep;---àDao
            Public Constructer Injection(Dependency dep){
            this.dep=dep;
}
}




---àDependencies are provided through the java bean style setter() method of the component.It is more popular then constructer  injection


EX:
            public class SetterInjection{---àservice

            Private dependency dep;---àDao

            Public void setMyDependancy(Dependancy dep){

            This.dep=dep;
}
}

àIn interface injection we have have to implement special interfaces

Spring container?
            Spring container works based on following
1. Bean Factory (interface)
2. Application Context (interface)
3. WebApplicationContext (interface)

BeanFactory

BeanFactory is a lightweight container it loads bean definitions and manages your  beans and manage a singleton or prototype defined bean          

The implementation classes are
ClassPathResource: In this no need to complete  file path


BeanFactory factory =new XmlBeanFactory (new ClassPathResource (“applicationContext.xml”);

            2 FileSystemResource

BeanFactory factory =new XmlBeanFactory (new FileSystemResource (“C:..\appicationContext.xml”);


Note:
1. spring doesn’t create the single object while reading the spring-config.xml>It creates the single object when we call first time getBean (-,-)

      2. BeanFactory doesn’t support I18 and Event Handling


 Application Context

Application context provides all the features of  BeanFactory and  some additional features like I18 concepts and Event Handling]
AC provides generic way to load file resources such as images Implementation classless for AC
           
FileSystemApplicationContext:It is like above file system Resource. This class accepts only total path of file
syntax 

BeanFactory factory =new FileSystemXmlApplication (new FileSystemResource (“C:..\appicationContext.xml”);

            2. ClassPathXmlApplicationContext:It is like above class path Resource.It loads configuration from classpath(using classLoder concept)

syntax

BeanFactory factory =new ClassPathXmlApplicationContext (new ClassPathResource (“applicationContext.xml”);

Note

While reading the configuration file it creates the singleton objects.

What is auto wiring?

In spring we have set the dependencies we have to approaches, constructer injection and setter injection. instead  them we have to inject the dependencies automatically we use concept  called auto wiring
1.In constructer injection just use the following configuration

<autowire=”constructer”>------------àit will set all the dependencies


2.In setter injection just use the following configuration tag
<autowire =”byname”> -------------à it will set all the dependencies


-àif we want to assign values with then we have to use manual(like constructer and setter injections)
àif we have less dependencies then we can prefer auto wiring

What  is parent attribute?

In java inheritance is achieved using extends keyword. in spring we can get one bean  definition details into another bean we use this parent attribute

What are main features of spring?

The main features of spring are
            1.IOC or Dependency injection
            2.Loosely coupled

What is IOC or Dependency injection?

Framework container  runtime environment is dynamically  assigning dependent values to recourses of application then it is called Dependency injection or or IOC

Ex: The way ActionServlet  writes the form data to FormBean class object comes under dependency injection

What is spring bean?

Any predefined or user defined  java classes are called spring bean

Spring support POJO classes or not?

Spring supports pojo classess.pojo class is nothing but  a class which is not extending  any other class or technology

Procedure to  set up first spring application?
1.create a work space for spring application
2.create the java project
3.add the spring libraries to project by selecting add spring  capabilities in myeclipse.in Eclipse ide following way
ProjectàpropertiesàjavaBuildPathàAdd librayàuser Libraryànewàcreate a folder lib(spring)àadd jarsàthen add all spring jars

For developing a spring App u have to create the following classes?
           
1.spring bean class
2.spring bean configuration class
3.client app to get the bean class object

Differentiate between BeanFactory and ApplicationContext in spring.

- With ApplicationContext more than one config files are possible while only one config file or .xml file is possible with BeanFactory. 
- ApplicationContext publishes events to beans that are registered as listeners while BeanFactory doesn't support this
- ApplicationContext support internationalization messages, application life-cycle events, validation and many enterprise services like JNDI access, EJB integration, remoting etc. while BeanFactory doesn't support any of these.

What is the difference between singleton and prototype bean?
Mainly it is the scope of a beans which defines their existence on the application
- Singleton: It means single bean definition to a single object instance per Spring IOC container.
- Prototype: It means a single bean definition to any number of object instances.

 How do beans become 'singleton' or prototype?
- There exists an attribute in bean tag, called 'singleton’. 
- If it is marked 'true', the bean becomes singleton. 
- If it is marked 'false', the bean becomes prototype.

 What type of transaction Management Spring support?
Spring supports two types of transaction management: 

1. Programmatic transaction management
2. Declarative transaction management.
When do you use programmatic and declarative transaction management ?
- Programmatic transaction management is used preferably when you have a small number of transactional operations. 
- Incase of large number of transactional operations it is better to use declarative transaction management.

What is IOC?
- IOC stands for Inversion of Control pattern. 
- It is also called as dependency injection. 
- This concept says that you do not create your objects but describe how they should be created. 
- Similarly, you do not directly connect your components and services together in code but describe which services are needed by which components in a configuration file. 
- A container then hooks them all up.

What are the benefits of IOC?
The main benefits of IOC or dependency injection are: 

a.) It minimizes the amount of code in your application. 
b.) It makes your application easy to test as it doesn't require any singletons or JNDI lookup mechanisms in your unit test cases. 
c.) Loose coupling is promoted with minimal effort and least intrusive mechanism. 
d.) IOC containers support eager instantiation and lazy loading of services
.
What is Bean Wiring ?
Bean wiring means creating associations between application components i.e. beans within the spring container.
What is IOC (or Dependency Injection)? 
The basic concept of the Inversion of Control pattern (also known as dependency injection) is that you do not create your objects but describe how they should be created. You don't directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container (in the case of the Spring framework, the IOC container) is then responsible for hooking it all up.

i.e., Applying IoC, objects are given their dependencies at creation time by some external entity that coordinates each object in the system. That is, dependencies are injected into objects. So, IoC means an inversion of responsibility with regard to how an object obtains references to collaborating objects.
What are the different types of IOC (dependency injection) ?
There are three types of dependency injection:
  • Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters.
  • Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods).
  • Interface Injection (e.g. Avalon): Injection is done through an interface.
Note: Spring supports only Constructor and Setter Injection 
 What are the benefits of IOC (Dependency Injection)?
Benefits of IOC (Dependency Injection) are as follows:
  • Minimizes the amount of code in your application. 
  • Make your application more testable by not requiring any singletons or JNDI lookup mechanisms in your unit test cases. 
  • Loose coupling is promoted with minimal effort and least intrusive mechanism
  • IOC containers support eager instantiation and lazy loading of services.
What is web module?
This module is built on the application context module, providing a context that is appropriate for web-based applications. This module also contains support for several web-oriented tasks such as transparently handling multipart requests for file uploads and programmatic binding of request parameters to your business objects. It also contains integration support with Jakarta Struts.
What are the types of Dependency Injection Spring supports?
Setter Injection:
Setter-based DI is realized by calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean.
Constructor Injection:
Constructor-based DI is realized by invoking a constructor with a number of arguments, each representing a collaborator.
 What is 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 Application Context?
A bean factory is fine to simple applications, but to take advantage of the full power of the Spring framework, you may want to move up to Springs 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. But 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 ? 
On the surface, an application context is same as a bean factory. But application context offers much more..
  • Application contexts provide a means for resolving text messages, including support for i18n of those messages.
  • Application contexts provide a generic way to load file resources, such as images.
  • Application contexts can publish events to beans that are registered as listeners.
  • 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.
  • ResourceLoader support: Spring’s Resource interface us a flexible generic abstraction for handling low-level resources. An application context itself is a ResourceLoader, Hence provides an application with access to deployment-specific Resource instances.
  • 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 implementation of 'Application Context' are
  • 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");
  • 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");
  • XmlWebApplicationContext : It loads context definition from an XML file contained within a web application.
How is a typical spring implementation look like ?
 
  For a typical Spring Application we need the following files:
  • 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 ?
   Bean life cycle in Spring Bean Factory Container is as follows:
  • The 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 ? 
The act of creating associations between application components (beans) within the Spring container is reffered to as Bean wiring.
What do you mean 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. The autowiring functionality has five modes.
  • no
  • byName
  • byType
  • constructor
  • autodirect
What is DelegatingVariableResolver?
     
  Spring provides a custom JavaServer Faces VariableResolver implementation that extends the standard Java Server Faces managed beans mechanism which lets you use JSF and Spring together. This variable resolver is called asDelegatingVariableResolver
How to integrate  Java Server Faces (JSF) with Spring? 
  
 JSF and Spring do share some of the same features, most noticeably in the area of IOC services. By declaring JSF managed-beans in the faces-config.xml configuration file, you allow the FacesServlet to instantiate that bean at startup. Your JSF pages have access to these beans and all of their properties.We can integrate JSF and Spring in two ways:
  • DelegatingVariableResolver: Spring comes with a JSF variable resolver that lets you use JSF and Spring together.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
   "http://www.springframework.org/dtd/spring-beans.dtd">
<faces-config>
   <application>
      <variable-resolver>
         org.springframework.web.jsf.DelegatingVariableResolver
      </variable-resolver>
   </application>
</faces-config>

The DelegatingVariableResolver will first delegate value lookups to the default resolver of the underlying JSF implementation, and then to Spring's 'business context' WebApplicationContext. This allows one to easily inject dependencies into one's JSF-managed beans.
  • FacesContextUtils:custom VariableResolver works well when mapping one's properties to beans in faces-config.xml, but at times one may need to grab a bean explicitly. The FacesContextUtils class makes this easy. It is similar to WebApplicationContextUtils, except that it takes a FacesContext parameter rather than a ServletContext parameter.
ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
What is  Java Server Faces (JSF) - Spring integration mechanism? 
Spring provides a custom JavaServer Faces VariableResolver implementation that extends the standard JavaServer Faces managed beans mechanism. When asked to resolve a variable name, the following algorithm is performed:
  • Does a bean with the specified name already exist in some scope (request, session, application)? If so, return it
  • Is there a standard JavaServer Faces managed bean definition for this variable name? If so, invoke it in the usual way, and return the bean that was created.
  • Is there configuration information for this variable name in the Spring WebApplicationContext for this application? If so, use it to create and configure an instance, and return that instance to the caller.
  • If there is no managed bean or Spring definition for this variable name, return null instead.
  • BeanFactory also takes part in the life cycle of a bean, making calls to custom initialization and destruction methods.
As a result of this algorithm, you can transparently use either JavaServer Faces or Spring facilities to create beans on demand.
What is Significance of JSF- Spring integration ?
Spring - JSF integration is useful when an event handler wishes to explicitly invoke the bean factory to create beans on demand, such as a bean that encapsulates the business logic to be performed when a submit button is pressed.
 How to integrate your Struts application with Spring? 
To integrate your Struts application with Spring, we have two options:
  • Configure Spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a Spring context file.
  • Subclass Spring's ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method.
What are Bean scopes in Spring Framework ?
   
The Spring Framework supports exactly five scopes (of which three are available only if you are using a web-aware ApplicationContext). The scopes supported are listed below:

Scope
Description
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.
What are the types of the transaction management Spring supports ?
   Spring Framework supports:
  • Programmatic transaction management.
  • Declarative transaction management.
 What are the benefits of the Spring Framework transaction management ?
   
The Spring Framework provides a consistent abstraction for transaction management that delivers the following benefits:
  • 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.
Why 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.
What is SQLProvider ?
   SQLProvider:
  • Has one method – getSql()
  • Typically implemented by PreparedStatementCreator implementers.
  • Useful for debugging.
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.

Do I need any other SOAP framework to run Spring Web Services?
You don't need any other SOAP framework to use Spring Web services, though it can use
some of the features of Axis 1 and 2.
 I get NAMESPACE_ERR exceptions when using Spring-WS. What can I do about it?
If you get the following Exception:
NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
            
Most often, this exception is related to an older version of Xalan being used. Make sure to upgrade to 2.7.0.
Does Spring-WS run under Java 1.3?
Spring Web Services requires Java 1.4 or higher.
Does Spring-WS work under Java 1.4? 
Spring Web Services works under Java 1.4, but it requires some effort to make it work. Java 1.4 is bundled with the older XML parser Crimson, which does not handle namespaces correctly. Additionally, it is bundled with an older version of Xalan, which also has problems. Unfortunately, placing newer versions of these on the class path does not override them. .
The only solution that works is to add newer versions of Xerces and Xalan in the lib/endorsed directory of your JDK, as explained in those FAQs (i.e.$JAVA_HOME/lib/endorsed). The following libraries are known to work with Java 1.4.2:

Library
Version
2.8.1
2.7.0
1.3.04
1.2
If you want to use WS-Security, note that the XwsSecurityInterceptor requires Java 5, because an underlying library (XWSS) requires it. Instead, you can use the Wss4jSecurityInterceptor.
Does Spring-WS work under Java 1.6? 
Java 1.6 ships with SAAJ 1.3, JAXB 2.0, and JAXP 1.4 (a custom version of Xerces and Xalan). Overriding these libraries by putting different version on the classpath will result in various classloading issues, or exceptions in org.apache.xml.serializer.ToXMLSAXHandler. The only option for using more recent versions is to put the newer version in the endorsed directory (see above).
Why do the Spring-WS unit tests fail under Mac OS X? 
For some reason, Apple decided to include a Java 1.4 compatibility jar with their JDK 1.5. This jar includes the XML parsers which were included in Java 1.4. No other JDK distribution does this, so it is unclear what the purpose of this compatibility jar is.
The jar can be found at /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/.compatibility/14compatibility.jar. You can safely remove or rename it, and the tests will run again.
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 theSpring configuration file. 
What is XMLBeanFactory?
BeanFactory has many implementations in Spring. But one of the most useful one isorg.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 toXmlBeanFactory.
        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?
  • The 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 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>
What are singleton beans and how can you create prototype beans?
Beans defined in spring framework are singleton beans. There is an attribute in bean tag named ‘singleton’ if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans.
        <beans>
           <bean id="bar" class="com.act.Foo" singleton=”false”/>
        </beans>
What are the important beans lifecycle methods?
There are two important bean lifecycle methods. The first one is setup which is called when the bean is loaded in to the container. The second method is the teardown method which is called when the bean is unloaded from the container.
How can you override beans default lifecycle methods?
The bean tag has two more important attributes with which you can define your own custom initialization and destroy methods. Here I have shown a small demonstration. Two new methods fooSetup and fooTeardown are to be added to your Foo class.
        <beans>
          <bean id="bar" class="com.act.Foo" init-method=”fooSetup” destroy=”fooTeardown”/>
        </beans>
What are Inner Beans?
When wiring beans, if a bean element is embedded to a property tag directly, then that bean is said to the Inner Bean. The drawback of this bean is that it cannot be reused anywhere else.
what are the different types of bean injections?
There are two types of bean injections.
  • By setter
  • By constructor
What is Auto wiring?
You can wire the beans as you wish. But spring framework also does this work for you. It can auto wire the related beans together. All you have to do is just set the autowire attribute of bean tag to an autowire type.
        <beans>
          <bean id="bar" class="com.act.Foo" Autowire=”autowire type”/>
        </beans>
. What are different types of Autowire types?
There are four different types by which autowiring can be done.
    • byName
    • byType
    • constructor
    • autodetect
What are the different types of events related to Listeners?
There are a lot of events related to ApplicationContext of spring framework. All the events are subclasses of org.springframework.context.Application-Event. They are
  • ContextClosedEvent – This is fired when the context is closed.
  • ContextRefreshedEvent – This is fired when the context is initialized or refreshed.
  • RequestHandledEvent – This is fired when the web context handles any request.



No comments:

Post a Comment