important methods of BeanFatory interface

previous-button-hisubmit-hi

 

Que: -What are the important methods of BeanFatory interface?

  1. object getBean (String)
  2. object getBean (String, Class)
  3. boolean isSingleton (String name)
  4. boolean isPrototype (String name)
  5. boolean containtsBean (String name)
  6. String [] getAliases (String name)

A spring bean can have more than one name. Those names are known as its aliases.by calling getAliases () method we can get all the alias names of the spring bean.

e.g.: -
<bean name=”hb1, hb2, hb3” class=”HelloBean”>
String s [] =container.getAliases (“hb1”);
for (int i=0; i<s.lenght; i++)
System.out.prinln (s[i]);

Output: -
hb2

hb3

Spring bean in the application is a singleton or not use can find out by calling isSingleton() method on the bean container. The following statements prints true for a bean as a spring bean is by default singleton in a spring container.

System.out.println(container.isSingleton(“hb1”));

  • isProtype () method returns false for a bean unless we change its scope to prototype.
  • constantBean () method returns true if the bean definition is found in the bean configuration file with that name.

System.out.println (container.constantBean(“hb1”));

For bean instantiation overloaded getBean() method is used as follows: –

HelloBean hb= (HelloBean) container.getBean (“hb1”, HelloBean.class);

Que: – Example spring application on creating a bean instance using static factory() method?

Some java classes can be instantiated only though their static factory methods. In such a case, we should indicate to the spring container about the same by using “factory-method” attribute of <bean> tag.

To this attribute, we need to specify the factory method name as the value.

Factorymethodinstantiation

  1. HelloBean.java
  2. ExecuteBean.java
  3. beans.xml

HelloBean.java”

public class HelloBean
{
private String message;
public HelloBean (String m);
{
message =m;
}
public static HelloBean getInstance()
{
System.out.println (“In factory method”);
HelloBean hb= new HelloBean (“Instantiated from static factory method”);
return hb;
} //user defined static factory method
public void displayMessage()
{
System.out.println (message);
}
}

beans.xml”

<beans>
<bean name=”hb1” class=”HelloBean” factory-method=”getInstance”/>
< /beans>

ExecuteBean.java”

class ExecuteBean
{
p
{
xmlBeanFactory factory=new XmlBeanFactory (newFileSystemResource (“beans.xml”));
HelloBean hb=(HelloBean) factory.getBean (“hb1”);
Hb.displayMessage ();
}
}

previous-button-hisubmit-hi

Role of java interfaces in spring application development

previous-button-hisubmit-hi

 

Que: -What is the role of interfaces in java applications?

Coding to the interfaces is preferable to coding classes. Interfaces provide loose coupling between service requester object and service provider object. As a result service provider changing any code in the service requester/service utilizer object. This is known as seamless system development.

Que: -What is the roll of java interfaces in spring application development?

In non-spring applications, interfaces in are useful. But somewhere, the implementation object of the interfaces has to be hardcoded in the application. In a spring application even that also not needed. If we have interfaces as dependency variable types, dependent object is loosely coupled with dependency object. Without changing the source code of the dependent object, we can swap-in and swap-out the dependency object class declaratively without hardcoding them. Therefor we say that as far as possible dependencies should be interfaces to promote loose coupling between application object.

Que: -Develop a spring application in which setter injection is implemented and loose coupling is also implemented between dependent and dependency?

Loose coupling application

  1. CustomerBean.java (dependent)
  2. Menu.java (dependency interface)
  3. BlueFoxRestaurantBean.java
  4. AdityaRestaurantBean.java
  5. SpringApplication.java
  6. beans.xml

 

Menu.java”

package com.nareshit.spring;
public interface menu
{
public abstract void provideFoodService ();
}

BlueFoxRestaurantBean.java”

package com.nareshit.spring;
public class BlueFoxRestaurantBean implements Menu
{
public void provideFoodService()
{
System.out.println (“Providing very good food service”);
} 
}

AdityaRestaurantBaen.java”

package com.nareshit.spring;
public class AdityaRestaurantBean implements Menu
{
public void provideFoodService()
{
System.out.println (“Providing excellent food service”);
} 
}

CustomerBean.java”

package com.nareshit.spring;
public class CustomerBean
{
Menu menu; //dependency
public void setMenu(Menu menu)
{
this.menu=menu;
}
public void expectFoodService()
{
System.out.println(“customer expecting food service”);
menu.provideFoodService(); //inter-bean communucation
} 
} //dependent bean

beans.xml”

<beans>
<bean id=”r1” class=”com.nareshit.spring.BlueFoxRestaurantBean”/>
<bean id=”r2” class=”com.nareshit.spring.AdityaRestaurantBean”/>
<bean id=”c” class =”com.nareshit.springCustomerBean”>
<property name=”menu” ref=”r1”/>
< /bean>
< /beans>

springapplication.java”

import com.nareshit.spring.Menu;
import com.nareshit.spring.CustomerBean;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.FileSystemResource;

public class SpringApplication
{
public static void main(String [] args)
{
Resource resource=new FileSystemResorce (“beans.xml”);
BeanFactory =new XmlBeanFactory (resource);
CustomerBean cb= (CustomerBean)factory.getBean (“c”);
Cb. expectFoodService ();
} //main
} //class

previous-button-hisubmit-hi

How to inject a list based collection into a spring bean

previous-button-hisubmit-hi

 

Que: -How to inject a list based collection into a spring bean? Give example

listbasedinjection

  1. student.java
  2. college.java
  3. springApplication.java
  4. beans.xml

In this example college is the dependent bean collection of student bean is the dependency.

  1. student.java”
package com.nareshit.spring;
public class student
{
Private int rollno;
Private String name;
public Student(int rollno, String name)
{
this.rollno=rollno;
this.name=name;
}
public void displayStudentDetails()
{
System.out.println(“Rollno:”+rollno);
System.out.println(“Name:”+name);
}//business method
}

2. “College.java”

package com.nareshit.spring;
import java.util.list;
public class College //dependent
{
private String name; //dependency 1
private List<student> students; //dependency 2
private College(String name)
{
this.name=name;
}//for constructor injection
public void setStudents(List<student> students)
{
this.students=students;
}//fpr setter injection
public List<student> getStudents()
{
return students;
}//business method
}

3. “beans.xml”

<beans>
<bean id=”s1” class=”com.nareshit.spring.Student”/>
<constructor-arg value=”101” />
<constructor-arg value=”Rama” />
< /bean>
<bean id=”s2” class=”com/nareshit.spring.Student”/>
<constructor-arg value=”102” />
<constructor-arg value=”Rahim” />
< /bean> 
<bean id=”s3” class=”com/nareshit.spring.Student”/>
<constructor-arg value=”103” />
<constructor-arg value=”David” />
< /bean> 
<bean id=”c” class=”com/nareshit.spring.Student”/>
<constructor-arg value=”NIT” />
<property name=”students” />
<list>
<ref bean=”s1” />
<ref bean=”s2”/>
<ref bean=”s3”/>
< /list>
< /property>
< /bean> 
< /beans>

4. “SpringApplication.java”

import com.nareshit.spring.College;
import com.nareshit.spring.Student;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.FileSystemResource;
import java.util.List;

class SpringApplication
{
public static void main(String [] args)
{
Resource resource=new FileSystemResorce (“beans.xml”);
BeanFactory =new XmlBeanFactory (resource);
Object o=factory.getBean (“c”);
College c1= (college) o;
List <student> listOfStudent=c1.getStudents (); //business method call
int count=1;
for(Student s:listOfStudents)
{
System.out.println(“Student”+count+”details…”);
s.displayStudentDetails ();
count ++;
}
} //main
} //class

previous-button-hisubmit-hi

Spring bean scope

previous-button-hisubmit-hi

 

By default spring beans are singletons i.e. spring container creates only one instance of the spring bean irrespective of the no. of getBean() method calls on the spring container. To change this default nature of the spring container we make use of “scope” attribute of the <bean> tag and give “prototype” as its value. In such a case spring container creates one instance per getBean() method call even if we specify the same bean ‘id’.

e.g.: -
<bean id=”hb” class=”HelloBean” scope=”prototype”>

Observe the output of the following application?

Constructorambiguity

  1. Employee.java
  2. springApplication.java
  3. Beans.java

1. “Employee.java”

public class Employee
{
string name;
string designation;
float salary;
Employee(String name, String designation)
{
this.name=name;
this.designation=designation;
}
Employee (float salary, Stirng name)
{
this.salary = salary;
this.name=name;
}
public void displayEmployeeDetails()
{
System.out.println (“name:”+designation);
System.out.println (“designation:”+designation);
System.out.println (“salary:”+salary);
}
}

SpringApllication.java”

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;

class SpringApplication
{ 
public static void main(String [] args)
{
Resource resource=new FileSystemResource (“beans.xml”);
BeanFactory =new XmlBeanFactory (resource);
Employee e= (Employee) factory.getBean (“eb”);
e.displayEmployeeDetails ();
}
}

beans.xml”

<beans>
<bean id=”eb” class=”Employee”>
<constructor-arg value=”5000.50”/>
<constructor-arg value=”Rama”/>
< /bean>
< /beans>

Note: –For each parameter of the constructor of the spring bean we have to use one <constructor-arg> tag while configuring the bean in bean configuration file.

Output: –

name : 5000.50

designation : Rama

salary : 0.0

Reason for the above unexpected output is, spring container treats <constructor-arg> values as spring first. If spring container encounters the constructor that takes strings as argument, it uses that kind of constructor while instantiating the spring bean without appropriate conversion. Because of such springframework’s behavior constructor ambiguity occurred while instantiating the Employee bean.

To resolve this constructor ambiguity we make use of two attributes of <constructor-arg> tag: –

  1. index
  2. type

Index specifies the parameter number in the parameter list of the constructor but the numbering starts from.

Type specifies the data of the constructor parameter.
beans.xml //modified beans file

<beans>
<bean id=”eb” class=”Employee”>
<constructor-arg value=”5000.50” type =”float” index=”0”/>
<constructor-arg value=”Rama” type=”java.lang.String” index=”1”/>
< /bean>
< /beans>

previous-button-hisubmit-hi

Spring application to explore the life cycle of a spring bean

previous-button-hisubmit-hi

 

Lifecycleapplication

  1. AccountBean.java
  2. SpringApplication.java
  3. beans.xml

1. “AccountBean.java”

public class AccountBean
{
Float amount; //dependency
public AccountBean()
{
System.out.println(“bean instance created”);
}
public void getAmount (float amount);
{
this.amount = amount;
System.out.println(“bean dependency is provided with setter injection”);
}
public void ownInit()
{
System.out.println(“Resource are allocated to the spring bean here”); 
}//custom init method
public void ownDestroy()
{
System.out.println(“Resource are released”);
} //custom destroy method
public void calculateInterest()
{
Float interest=amount*0.05f;
System.out.println(“Interest :Rs:”+interest);
}//business method
}

2. “beans.xml”

<bean>
<bean name=”ab” class=”accountBean” 
init-method=”owninit” destroy-method=”ownDestroy”><property name=”omount” value=”5000” />
< /bean>
< /beans>

3. SpringApplication.java

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ClassPathResource;//import org.springframework.beans.factory.support.DefaultSingletonBean

class SpringApplication
{
public static void main(String [] args)
{
Resource resource=new ClassPathResorce (“beans.xml”);
XmlBeanFactory sc=new XmlBeanFactory (resource);
AccountBean accountBean= (AccountBean) sc.getBean (“ab”);
accountBean.calculateInterest();
sc.destroySingletons(); //if not runs normally,use following
// ((DefaultSingletonBeanRegistry) factory).destroySingletons ();
}
}

previous-button-hisubmit-hi

Spring bean life cycle

previous-button-hisubmit-hi

 

Que: -What is spring bean life cycle?

Spring container controls life cycle of spring bean that is from bean instantiation to destruction. Spring bean is a POJO it need not implement any spring specific API interfaces or extend any classes so as to facilitate the spring container to controls life cycle i.e. for spring bean component contract is not required.

Spring bean has four life cycle phases:

  1. Instantiation phase
  2. Initialization phase
  3. Ready to use/servicing phase
  4. Destruction phase

Spring bean life cycle is described as follows:

1. Instantiation phase: –

Spring container loads spring bean class into memory and creates the bean instance. When the spring bean instance is created, spring container uses dependency injection to populate the bean fields. All the dependencies are configured for the spring bean before its initialization finished.

2. Initialization phase: –

In the spring bean class if any custom initialization method is specified, spring container calls that method. In this method we can give any resource to the spring bean.

Note: –Unless initialization phase is over, spring container does not give bean references to the caller.

In case of BeanFactory, instantiation and initialization happens then getBean() method is called.

3. Ready to use phase: –

When spring container gives the bean references to the caller, its business method can be called.

4. Destruction phase: –

Upon container shutdown or any explicit method is called, spring container calls the user defined destroy() method of the spring bean. Just before the bean instance is garbage collected. In this method, we release the resources allocated to the bean.

Que: -How to create custom initialization method for a spring bean?

Step 1: –In the spring bean class implement any user defined method with any name.

Step 2: –In the spring configuration file make use of “init-method” attribute in the <bean> tag and specify the user defined method name as value to that attribute.

Que: -How to specify custom destruction() method for a spring bean?

Step 1: –In the spring bean class implement any user defined method.

Step 2: –In the <bean> tag make use of “destroy method” attribute and specify the user defined destroy method name as value to the attribute.

previous-button-hisubmit-hi

Spring application on setter injection

previous-button-hisubmit-hi

 

Helloworldapplication

1. HelloBean.java

2. ExecuteBean.java

3. beans.xml

HelloBean.java

—————————————-

Public class HelloBean
{
Private String message;
  Public void setMessage(String message)
  {
  this.message =message;
  }
  Public void displayMessage()
  {
  System.out.println(message);
  }
}

beans.xml

—————————————-

<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi.schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id ="hb" class="HelloBean">
<property name="message" value="Hello world"/>
</bean>
</beans>

ExecuteBean.java

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

class ExecuteBean
{
public static void main(String[] args)
{
XmlBeanFactory container=new XmlBeanFactory(new FileSystemResource(“beans.xml”));//spring container instance created
HelloBean my bean= (HelloBean)container.getBean(“hb”);//.class file of HelloBean loaded into memory
mybean.displayMessage ();
}
}

****************************************

helloworldapplication2

HelloBean.java

ExecuteBean.java

beans.xml

HelloBean.java

———————————–

public class HelloBean
{
private String message;
public HelloBean(String message)
{
this.message=message;
}
public void displayMessage()
{
System.out.println (message);
}
}

beans.xml

—————————————-

<?xml version= "1.0"?>
<beans xmlns="http://www.springframework.org/shema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi.schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="hb" class="HelloBean">
<constructor-arg value="Hai world" />
</bean>
</beans>

ExecuteBean.java

—————————————-

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
class ExecuteBean
{
public static void main(String[] args)
{
XmlBeanFactory container=new XmlBeanFactory(new FileSystemResource(“beans.xml”));//spring container instance created
HelloBean my bean= (HelloBean)container.getBean(“hb”);//.class file of HelloBean loaded into memory
mybean.displayMessage ();
}
}

****************************************

interbeancommunication

Controller.java

ServiceBean.java

DAOBean.java

ExecuteBean.java

beans.xml

ControllerBean.java

—————————————-

public class ControllerBean //dependent
{
ServiceBean service; //dependency
public void setService(ServiceBean service)
{
this.service=service;
}
public void execute()
{
System.out.println(“presentstion layer code executed”);
service.calculateInterest();
}
}

ServiceBean.java

———————————————————–

class ServiceBean//dependent
{
DAOBean dao; //dependency
public void setDao(DAOBeancdao)
{
this.dao=dao;
}//setter injection
public void calculateInterest()
{
dao.findAccount();
System.out.println(“Interest calculated in service layer”);
}//business method
}

DAOBean.java

—————————————-

public class DAOBean
{
public void findAccount()
{
System.out.println(“Account details given by DAO bean”);
}
}//Data Access Layer spring bean source code

ExecuteBean

—————————————-

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

class ExecuteBean
{
public static void main(String[] args)
{
XmlBeanFactory container=new XmlBeanFactory(new FileSystemResource(“beans.xml”));//spring container instance created
ControllerBean my bean= (ControllerBean)container.getBean(“cb”);//class file of HelloBean loaded into memory
mybean.execute ();
}
}

beans.xml

—————————————-

 

<?xml version= "1.0"?>
<beans
xmlns= "http://www.springframework.org/schema/beans"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi.schemaLocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id = "db" class= "DAOBean">
<bean id = "sb" class= "ServiceBean">
<property name= "dao" ref= "db" />
<bean id = "cb" class= "ControllerBean">
<property name= "service" ref= "sb">
</bean>
< /beans>

previous-button-hisubmit-hi

Constructor Injection

previous-button-hisubmit-hi

 

Que: -How is constructor injection implemented in a spring application?

Step 1: – Declare the dependency as instance variable in the dependent bean.

e.g.: - public class HelloBean //dependent
{
String message; //dependency
--------------------
--------------------
}

Step 2: – Define a parameterize constructor in the dependent bean.

e.g.: - public HelloBean (String m)
{
Message m;
}

In this parameterize constructor initialize the dependency variable.

Step 3: – In the bean configuration file, while configuring the dependent bean make use of <constructor-arg > tag.

e.g.: - <constructor –arg value= “Hello world” />

Note: – In the above tag various attributes are there to deal with overloaded constructor with any number of arguments without ambiguity.

If the dependency is a user defined variable i.e. a reference, we use “ref” attribute instead of value attribute to populate the dependency.

Que: -How to get spring core container in a spring application?

org .springframework.beans.factory.BeanFactory” is an interface implementation class of this interface is nothing but spring core container or IOC container.

BeanFactory

XmlBeanFactory is one of the few implementations of BeanFactory interface. This is the most widely used spring container class. If we instantiate XmlBeanFactory class, it is nothing but spring container. XmlBeanFactory constructor takes “org.springframework.core.io.Resource” interface object as argument. Resource interface has many implementation class of which the following are widely used:
If we use FileSystemResource object we need to specify the bean configuration file absolute path of the file system. If we use ClassPathResource bean configuration file should be placed in classpath. Resource object provides bean configuration file to the BeanFactory. We get the spring container in a spring application as follows:

resource

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

factory” is a reference referring to spring container object. Spring container object needs the configuration file to load the bean definition which is provided by Resource object. Factory design pattern is used in the implementation of spring container. When the BeanFactory instance is created only spring bean definitions are loaded into memory but spring beans are not instantiated. When getBean() method is called on the factory instance, at that time spring bean instance is created by the spring container and the bean references is returned.

previous-button-hisubmit-hi

Core module of spring framework

previous-button-hisubmit-hi

 

Que: – What is core module of spring framework?

Core module is the base of spring framework. Core module is also known as IOC module. Inversion of control module is Nothing but spring container. Spring container is mainly responsible for bean life cycle management and providing dependencies to the spring beans.

Que: – What are the main principles of spring framework?

In spring application development two features are mainly used:

  1. IOC (Inversion of control)
  2. AOP

Que: -what is IOC (Inversion of control)?

Inversion of control is a designing principle which is purely conceptual in which, an external agency (entity) providing dependencies application components instead of hand coding or hard coding them in the component code. IOC principle is famously known as Hollywood principle, i.e. “Don’t call us, we will call u”.

Que: -what is DI (Dependency Injection)?

Physical realization of the theoretical principle called IOC is nothing but dependency injection (DI)”.In case of spring applications, spring container is the external entity that provides dependency object references into dependent objects through the feature known as dependency injection (DI).

We have two kind of injection: –

  1. Setter injection
  2. Constructor injection

Note: –Interface injection (method injection) is also available for used.

Que: -How to implement setter injection?

Step 1: –Declare the dependency as the instance variable in the spring bean class.

e.g.: - public class serviceBean
{
DAOBean dao;
-------------------
-------------------
}

Step 2: – Ensure public zero argument constructor in the dependent class.

Step 3: – Develop the public setter method to the dependency variable in the dependent class.

e.g.: - public void setDAO (DAOBean d)
{
Dao=d;
}

In this method we assign the parameter value to the dependency variable. This setter method is called by spring container implicitly.

Step 4: – In the bean configuration file make use of <property>

Tag value configuring the dependent bean.

e.g.: - <property name= “dao” ref= “otherbean id”/>

Or

<property name= “message” value= “Helloworld”/>

Note: – If the dependency is a primitive variable or string variable, we populate it using “value” attribute. If the dependency variable is a reference variable of any user defined type, “ref” attribute of <property> tag is used to populate the dependency variable.

previous-button-hisubmit-hi

Spring framework application development

previous-button-hisubmit-hi

 

Q. Modify the previous application so as to have a constructor in “HelloBean” class instead of setter method.

Note: ExecuteBean.java is as it is from previous application.

“HelloBean.java”:

public class HelloBean
{
private String message;
public HelloBean (String message)
{
this.message= message;
}
public void displayMessage(){
System.out.println("Hello world"):
}// business method
}

bean.xml:

<beans>
<bean Id= "hb" class= "HelloBean">
<constructor-org value="HelloWorld"/>
</bean>
</beans>

ExecuteBean.java

import org.springframrwork.beans.factory.xml.XmlBeanFactory;
import org.springframrwork.core.io.FileSystemResource;

class ExecuteBean
{
public static void main (String [] args)
{
XmlBeanFactory container= new XmlBeanFactory(new FileSystemResource("beans. xml"));
HelloBean mybean = (HelloBean)container.getBean("nb");
mybean.displayMessage();
}
}

Note: while configuring a spring bean in the beans configuration files, we use <property> tag to populate bean field if setter method is specified in the bean class.

In the bean class if the constructor is used, to initialize the bean field, we use <constructor-org> tag while configuring the spring bean in bean configuration file.

Q. Develop a spring application in which controller-bean communicates with service-bean and service-bean communicates with DAO-bean.

Ans: 

DAOBean.java:

public class DAOBean
{ 
public void findAccount()
{
System.out.println("Account details given by DAO Bean");
}
}// Data access layer spring bean source code

ServiceBean.java:

class ServiceBean // dependent
{
DAOBean dao; // dependency
public void setDAO(DAOBean dao)
{
this.dao = dao;
}// setter injection
public void calculateInterest()
{
dao.findAccount();
System.out.println ("interest calculated in service layer");
}//business method
}

ControllerBean.java:

public class ControllerBean // dependent
{
ServiceBean service;// dependency
public void setService(ServiceBean service)
{
this.service = service;
}
public void execute()
{
System.out.println ("Presentation layer code executed");
service.calculateInterest();}
}

beans.xml:

<beans>
<bean Id= "db" class = "DAOBean"/>
<bean id= "sb" class = "ServiceBean">
<property name = "dao" ref="db"/>
</bean>
<bean id= "cb" class = "ContrallerBean">
<property name= "service" ref= "sb"/>
</bean>
</beans>

ExecuteBean.java:

import org.springframrwork. beans.factory.xml.XmlBeanFactory;
import org.springframrwork.core.io.FileSystemResource;

class ExecuteBean
{
public static void main ( String [] args)
{
XmlBeanFactory container= new XmlBeanFactory(new FileSystemResource("beans.xml"));
ControllerBean mybean = (ControllerBean)container.getBean("cb");
mybean.execute();
}
}

previous-button-hisubmit-hi