-
Jan 25th, 2011, 02:28 PM
#1
Abstract Factory pattern setup on Container
Hi,
How can I setup the dispatcher-servlet with Abstract Factory pattern?
I am using Spring 3.0.5 and Hibernate3 without annotation.
The web application works fine if I do not use Abstract Factory pattern.
Here are my cod:
public abstract class Category {
public abstract List list(int departId);
..
}
public class CategoryFactory {
public enum CategoryType { firstclass,secondClass,...}
public static Category findCategory(CategoryType categoryType) {
switch (categoryType) {
case firstclass:
return new FirstclassCategory();
case secondclass:
return new SecondclassCategory();
...
}
}}
public class FirstclassCategory extends Category {
private HibernateTemplate hibernateTemplate;
public void setSessionFactory(SessionFactory sessionFactory) {
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
@Override
public List<FirstClass> list(int courseId){
...
}
}
public class SectionsController extends MultiActionController {
public ModelAndView sectionList(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ModelMap modelMap = new ModelMap();
CategoryFactory.CategoryType type= CategoryFactory.CategoryType.valueOf("firstClass") ;
modelMap.addAttribute("list",CategoryFactory.findC ategory(type).list(12);
return new ModelAndView(list", modelMap);
}
My short dispatcher-servlet.xml is:
<bean id="first" class="FirstclassCategory" abstract="true">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
<bean name="/*.htm" class="SectionsController">
<property name="firstViewBean" ref="first" />
</bean>
With this the server does not run.
What is wrong with this?
Thanks for your help.
MK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules