⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basiclogicflow.java

📁 pojo的mvc框架
💻 JAVA
字号:
package xyz.frame.core;import java.io.IOException;import java.util.LinkedList;import javax.servlet.ServletException;import org.apache.log4j.Logger;import xyz.frame.Interceptor;import xyz.frame.LogicException;import xyz.frame.LogicFlow;import xyz.frame.RedirectException;import xyz.frame.component.ComponentClassFactory;import xyz.frame.component.ComponentInstantiationException;import xyz.frame.component.ComponentType;import xyz.frame.interceptor.InterceptorClass;import xyz.frame.interceptor.InterceptorDealer;import xyz.frame.interceptor.InterceptorInstantiationException;import xyz.frame.url.InternalLogicRequest;import xyz.frame.util.GettingException;import xyz.frame.util.SettingException;import xyz.frame.view.ViewException;/** * The base implementation of logic flow *  * @author Guilherme Silveira *  */public class BasicLogicFlow implements LogicFlow {	private static final Logger logger = Logger.getLogger(BasicLogicFlow.class);	private InterceptorDealer interceptorDealer;	private LinkedList<Interceptor> interceptors = new LinkedList<Interceptor>();	private LinkedList<InterceptorClass> interceptorsClass;	private Interceptor lastInterceptor;	private InterceptorClass lastInterceptorClass;	private InternalLogicRequest request;	public BasicLogicFlow(ComponentType componentClass,			XyzExecution engine, ExecuteLogicInterceptor logicInterceptor)			throws InterceptorInstantiationException {		logger.debug("Creating new basic logic flow");		this.interceptorsClass = new LinkedList<InterceptorClass>(				componentClass.getInterceptors());		this.request = engine.getRequest();		this.interceptorDealer = new InterceptorDealer(engine.getController()				.getIntrospector());		for (InterceptorClass clazz : this.interceptorsClass) {			try {				interceptors.addLast(clazz.newInstance());			} catch (ComponentInstantiationException e) {				throw new InterceptorInstantiationException(e.getMessage(), e);			}		}		interceptors.addLast(logicInterceptor);		interceptorsClass				.addLast(ComponentClassFactory.INTERCEPTOR_LIST_FACTORY						.getInterceptorClass(ExecuteLogicInterceptor.class));	}	/**	 * Executes the next step in the flow	 */	public void execute() throws ViewException, LogicException {		logger.debug("Calling execute on flow");		if (lastInterceptor != null) {			try {				interceptorDealer.outject(lastInterceptor,						lastInterceptorClass, request);			} catch (GettingException e) {				throw new LogicException(e.getMessage(), e);			}		}		lastInterceptor = interceptors.removeFirst();		lastInterceptorClass = interceptorsClass.removeFirst();		try {			interceptorDealer.inject(lastInterceptor, lastInterceptorClass,					request);		} catch (ComponentInstantiationException e) {			throw new LogicException(e.getMessage(), e);		} catch (SettingException e) {			throw new LogicException(e.getMessage(), e);		}		lastInterceptor.intercept(this);	}	/**	 * 	 * Redirects somewhere in the server	 * 	 * @throws LogicException	 *             some logic exception has hapenned	 * @see xyz.frame.LogicFlow#redirect(java.lang.String)	 */	public void redirect(String url) throws RedirectException {		try {			request.getRequest().getRequestDispatcher(url).forward(					request.getRequest(), request.getResponse());		} catch (ServletException e) {			if (e.getRootCause() == null) {				throw new RedirectException(e.getMessage(), e);			}			throw new RedirectException(e.getRootCause().getMessage(), e					.getRootCause());		} catch (IOException e) {			throw new RedirectException(e.getMessage(), e);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -