All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.tom.mvc.view.DefaultViewFactory Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
package cn.tom.mvc.view;

import java.util.HashMap;

import cn.tom.mvc.config.Constants;
import cn.tom.mvc.core.CocookException;
import cn.tom.mvc.ext.BeanFactory;

public class DefaultViewFactory extends ViewFactory{

	private final static HashMap> views = new HashMap>() ; 
	private String viewType  = getViewType();
	static{
		views.put("velocity", VelocityView.class);
		views.put("freemarker", FreeMarkerView.class);
	}
	
	@Override
	public View create() {
		Class clazz =  views.get(viewType);
		if(clazz == null) return null;
		View view;
		try {
			view =  BeanFactory.newInstance(clazz);
		} catch (Exception e) {
			throw new CocookException(e);
		} 
		return view;
	}
	
	
	private String getViewType(){
		return Constants.getViewType();
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy