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

com.cedarsoft.gdao.spring.DaoFactory Maven / Gradle / Ivy

There is a newer version: 1.6.3
Show newest version
package com.cedarsoft.gdao.spring;

import com.cedarsoft.gdao.GenericDao;
import com.cedarsoft.gdao.GenericDaoManager;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.FactoryBean;

/**
 * Special factory bean that resolves DAOs for a class
 */
public class DaoFactory implements FactoryBean {
  @NotNull
  private final GenericDaoManager genericDaoManager;

  @NotNull
  private final Class type;

  /**
   * Creates a new factory
   *
   * @param genericDaoManager the manager that is used to resolve the DAOs
   * @param type              the type the dao is searched for
   */
  public DaoFactory( @NotNull GenericDaoManager genericDaoManager, @NotNull Class type ) {
    this.genericDaoManager = genericDaoManager;
    this.type = type;
  }

  @NotNull
  public GenericDao getObject() throws Exception {
    return genericDaoManager.getDao( type );
  }

  public Class getObjectType() {
    return GenericDao.class;
  }

  public boolean isSingleton() {
    return true;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy