Announcement Announcement Module
No announcement yet.
Abstract Factory pattern setup on Container Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Abstract Factory pattern setup on Container

    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);
    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 name="/*.htm" class="SectionsController">
    <property name="firstViewBean" ref="first" />

    With this the server does not run.
    What is wrong with this?

    Thanks for your help.