Spring中DaoSupport源码

来源:互联网 发布:广东继续教育网络平台 编辑:程序博客网 时间:2024/04/29 23:09

DaoSupport源码

package org.springframework.dao.support;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.factory.BeanInitializationException;import org.springframework.beans.factory.InitializingBean;public abstract class DaoSupport implements InitializingBean {    protected final Log logger = LogFactory.getLog(this.getClass());    public DaoSupport() {    }    public final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException {        this.checkDaoConfig();        try {            this.initDao();        } catch (Exception var2) {            throw new BeanInitializationException("Initialization of DAO failed", var2);        }    }    protected abstract void checkDaoConfig() throws IllegalArgumentException;    protected void initDao() throws Exception {    }}
package org.springframework.beans.factory;/** * Interface to be implemented by beans that need to react once all their * properties have been set by a BeanFactory: for example, to perform custom * initialization, or merely to check that all mandatory properties have been set. *  * <p>An alternative to implementing InitializingBean is specifying a custom * init-method, for example in an XML bean definition. * For a list of all bean lifecycle methods, see the BeanFactory javadocs. * * @author Rod Johnson * @see BeanNameAware * @see BeanFactoryAware * @see BeanFactory * @see org.springframework.beans.factory.support.RootBeanDefinition#getInitMethodName * @see org.springframework.context.ApplicationContextAware */public interface InitializingBean {      /**    * Invoked by a BeanFactory after it has set all bean properties supplied    * (and satisfied BeanFactoryAware and ApplicationContextAware).    * <p>This method allows the bean instance to perform initialization only    * possible when all bean properties have been set and to throw an    * exception in the event of misconfiguration.    * @throws Exception in the event of misconfiguration (such    * as failure to set an essential property) or if initialization fails.    */   void afterPropertiesSet() throws Exception;}

0 0
原创粉丝点击