Java tutorial
/******************************************************************************* * Copyright (c) 2009 David Harrison. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl-3.0.html * * Contributors: * David Harrison - initial API and implementation ******************************************************************************/ package com.sfs.whichdoctor.dao; import com.sfs.beans.SQLBean; import com.sfs.beans.UserBean; import com.sfs.dao.ObjectTypeDAO; import javax.annotation.Resource; import javax.sql.DataSource; import org.springframework.jdbc.core.JdbcTemplate; /** * The Class BaseDAOImpl. * * @author David Harrison */ public class BaseDAOImpl { /** The sql. */ private SQLBean sql; /** The object type dao. */ @Resource private ObjectTypeDAO objectTypeDAO; /** The data source. */ @Resource private DataSource dataSource; /** The data source writer. */ @Resource private DataSource dataSourceWriter; /** The ISB data source. */ @Resource private DataSource isbDataSource; /** * Instantiates a new base dao impl. */ public BaseDAOImpl() { this.sql = new SQLBean("com.sfs.whichdoctor.sql"); } /** * Sets the object type dao. * * @param objectTypeDAORef the new object type dao */ public final void setObjectTypeDAO(final ObjectTypeDAO objectTypeDAORef) { this.objectTypeDAO = objectTypeDAORef; } /** * Gets the object type dao. * * @return the object type dao */ public final ObjectTypeDAO getObjectTypeDAO() { return this.objectTypeDAO; } /** * Sets the data source. * * @param dataSourceRef the new data source */ public final void setDataSource(final DataSource dataSourceRef) { this.dataSource = dataSourceRef; } /** * Sets the data source writer. * * @param dataSourceWriterRef the new data source writer */ public final void setDataSourceWriter(final DataSource dataSourceWriterRef) { this.dataSourceWriter = dataSourceWriterRef; } /** * Gets the jdbc template reader. * * @return the jdbc template reader */ protected final JdbcTemplate getJdbcTemplateReader() { return new JdbcTemplate(dataSource); } /** * Gets the jdbc template writer. * * @return the jdbc template writer */ protected final JdbcTemplate getJdbcTemplateWriter() { return new JdbcTemplate(dataSourceWriter); } /** * Gets the jdbc template reader. * * @return the jdbc template reader */ protected final JdbcTemplate getIsbJdbcTemplate() { return new JdbcTemplate(isbDataSource); } /** * Gets the SQL. * * @return the SQL */ protected final SQLBean getSQL() { return sql; } /** * Gets the system user. * * @return the system user */ protected final UserBean getSystemUser(final String first, final String last) { UserBean systemUser = new UserBean(); systemUser.setUserName("System"); systemUser.setDN("system"); systemUser.setPreferredName(first); systemUser.setLastName(last); systemUser.setEmail("system@whichdoctor"); systemUser.setOverridePrivileges(true); return systemUser; } }