ItEr20S04ArquitecturaServidorItEr19S04: Removing WorkReportsDAORegistry and creating a general Registry intended to replace all Registries.
This commit is contained in:
parent
c183170dda
commit
078009217b
3 changed files with 52 additions and 48 deletions
|
|
@ -0,0 +1,48 @@
|
|||
package org.navalplanner.business.common;
|
||||
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportDAO;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportTypeDAO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A registry, AKA service locator, for objects in which dependency injection
|
||||
* (DI) is not directly supported by Spring (e.g. entities) must use this class
|
||||
* to access DAOs. For the rest of classes (e.g. services, tests, etc.), Spring
|
||||
* DI is a more convenient option.
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class Registry {
|
||||
|
||||
private static final Registry singleton = new Registry();
|
||||
|
||||
@Autowired
|
||||
private IWorkReportDAO workReport;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportTypeDAO workReportType;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportLineDAO workReportLine;
|
||||
|
||||
private Registry() {
|
||||
|
||||
}
|
||||
|
||||
public static Registry getInstance() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public static IWorkReportDAO getWorkReportDao() {
|
||||
return getInstance().workReport;
|
||||
}
|
||||
|
||||
public static IWorkReportTypeDAO getWorkReportTypeDao() {
|
||||
return getInstance().workReportType;
|
||||
}
|
||||
|
||||
public static IWorkReportLineDAO getWorkReportLineDao() {
|
||||
return getInstance().workReportLine;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package org.navalplanner.business.workreports.daos;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A registry of WorkReports DAOs. Classes in which dependency injection (DI) is
|
||||
* not directly supported by Spring (e.g. entities) must use this class to
|
||||
* access resource DAOs. For the rest of classes (e.g. services, tests, etc.),
|
||||
* Spring DI is a more convenient option.
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
|
||||
public final class WorkReportsDAORegistry {
|
||||
|
||||
private static WorkReportsDAORegistry instance = new WorkReportsDAORegistry();
|
||||
|
||||
@Autowired
|
||||
private IWorkReportDAO workReport;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportTypeDAO workReportType;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportLineDAO workReportLine;
|
||||
|
||||
private WorkReportsDAORegistry() {
|
||||
}
|
||||
|
||||
public static WorkReportsDAORegistry getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static IWorkReportDAO getWorkReportDao() {
|
||||
return getInstance().workReport;
|
||||
}
|
||||
|
||||
public static IWorkReportTypeDAO getWorkReportTypeDao() {
|
||||
return getInstance().workReportType;
|
||||
}
|
||||
|
||||
public static IWorkReportLineDAO getWorkReportLineDao() {
|
||||
return getInstance().workReportLine;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,12 +75,12 @@
|
|||
class="org.navalplanner.business.planner.daos.PlannerDAORegistry"
|
||||
factory-method="getInstance" />
|
||||
|
||||
<bean id="workReportsDaoRegistry"
|
||||
class="org.navalplanner.business.workreports.daos.WorkReportsDAORegistry"
|
||||
factory-method="getInstance" />
|
||||
|
||||
<bean id="advanceDaoRegistry"
|
||||
class="org.navalplanner.business.advance.daos.AdvanceDAORegistry"
|
||||
factory-method="getInstance" />
|
||||
|
||||
<bean id="registry"
|
||||
class="org.navalplanner.business.common.Registry"
|
||||
factory-method="getInstance" />
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue