From 9ebed5079d6c0afda987721a7637f3d80ad65b0f Mon Sep 17 00:00:00 2001 From: user1 Date: Thu, 23 Jun 2016 10:08:46 +0200 Subject: [PATCH] fix detangle configuration --- .../kit/scc/FilesystemBeanConfiguration.java | 103 ++++++++++++++++++ .../edu/kit/scc/FilesystemConfiguration.java | 83 +------------- 2 files changed, 105 insertions(+), 81 deletions(-) create mode 100644 src/main/java/edu/kit/scc/FilesystemBeanConfiguration.java diff --git a/src/main/java/edu/kit/scc/FilesystemBeanConfiguration.java b/src/main/java/edu/kit/scc/FilesystemBeanConfiguration.java new file mode 100644 index 0000000..d8b7745 --- /dev/null +++ b/src/main/java/edu/kit/scc/FilesystemBeanConfiguration.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016 Karlsruhe Institute of Technology (KIT) + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +package edu.kit.scc; + +import org.snia.cdmiserver.dao.CapabilityDao; +import org.snia.cdmiserver.dao.CdmiObjectDao; +import org.snia.cdmiserver.dao.ContainerDao; +import org.snia.cdmiserver.dao.DataObjectDao; +import org.snia.cdmiserver.dao.DomainDao; +import org.snia.cdmiserver.dao.filesystem.CapabilityDaoImpl; +import org.snia.cdmiserver.dao.filesystem.CdmiObjectDaoImpl; +import org.snia.cdmiserver.dao.filesystem.ContainerDaoImpl; +import org.snia.cdmiserver.dao.filesystem.DataObjectDaoImpl; +import org.snia.cdmiserver.dao.filesystem.DomainDaoImpl; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration +@Profile("filesystem") +public class FilesystemBeanConfiguration { + + @Value("${cdmi.data.baseDirectory}") + private String baseDirectory; + + @Value("${cdmi.data.objectIdPrefix}") + private String objectIdPrefix; + + /** + * Initializes the file system version of the CDMI object DAO interface. + * + * @return a {@link CdmiObjectDao} + */ + @Bean + public CdmiObjectDao cdmiObjectDao() { + CdmiObjectDaoImpl cdmiObjectDaoImpl = new CdmiObjectDaoImpl(); + cdmiObjectDaoImpl.setBaseDirectory(baseDirectory); + cdmiObjectDaoImpl.setObjectIdPrefix(objectIdPrefix); + cdmiObjectDaoImpl.setObjectIdDirectory("cdmi_objectid"); + return cdmiObjectDaoImpl; + } + + /** + * Initializes the file system version of the {@link ContainerDao}. + * + * @return a {@link ContainerDao} + */ + @Bean + public ContainerDao containerDao(CdmiObjectDao cdmiObjectDao) { + ContainerDaoImpl containerDaoImpl = new ContainerDaoImpl(); + containerDaoImpl.setBaseDirectoryName(baseDirectory); + containerDaoImpl.setCdmiObjectDao(cdmiObjectDao); + return containerDaoImpl; + } + + /** + * Initializes the file system version of the {@link DataObjectDao}. + * + * @return a {@link DataObjectDao} + */ + @Bean + public DataObjectDao dataObjectDao(CdmiObjectDao cdmiObjectDao) { + DataObjectDaoImpl dataObjectDaoImpl = new DataObjectDaoImpl(); + dataObjectDaoImpl.setBaseDirectoryName(baseDirectory); + dataObjectDaoImpl.setCdmiObjectDao(cdmiObjectDao); + return dataObjectDaoImpl; + } + + /** + * Initializes the file system version of the {@link CapabilityDao}. + * + * @return a {@link CapabilityDao} + */ + @Bean + public CapabilityDao capabilityDao(CdmiObjectDao cdmiObjectDao) { + CapabilityDaoImpl capabilityDaoImpl = new CapabilityDaoImpl(); + capabilityDaoImpl.setBaseDirectory(baseDirectory); + capabilityDaoImpl.setCdmiObjectDao(cdmiObjectDao); + return capabilityDaoImpl; + } + + /** + * Initializes the file system version of the {@link DomainDao}. + * + * @return a {@link DomainDao} + */ + @Bean + public DomainDao domainDao(CdmiObjectDao cdmiObjectDao) { + DomainDaoImpl domainDaoImpl = new DomainDaoImpl(); + domainDaoImpl.setBaseDirectoryName(baseDirectory); + domainDaoImpl.setCdmiObjectDao(cdmiObjectDao); + return domainDaoImpl; + } + +} diff --git a/src/main/java/edu/kit/scc/FilesystemConfiguration.java b/src/main/java/edu/kit/scc/FilesystemConfiguration.java index 60bc49a..66e7de2 100644 --- a/src/main/java/edu/kit/scc/FilesystemConfiguration.java +++ b/src/main/java/edu/kit/scc/FilesystemConfiguration.java @@ -18,23 +18,14 @@ import org.slf4j.LoggerFactory; import org.snia.cdmiserver.dao.CapabilityDao; import org.snia.cdmiserver.dao.CdmiObjectDao; -import org.snia.cdmiserver.dao.ContainerDao; -import org.snia.cdmiserver.dao.DataObjectDao; -import org.snia.cdmiserver.dao.DomainDao; -import org.snia.cdmiserver.dao.filesystem.CapabilityDaoImpl; -import org.snia.cdmiserver.dao.filesystem.CdmiObjectDaoImpl; -import org.snia.cdmiserver.dao.filesystem.ContainerDaoImpl; -import org.snia.cdmiserver.dao.filesystem.DataObjectDaoImpl; -import org.snia.cdmiserver.dao.filesystem.DomainDaoImpl; import org.snia.cdmiserver.model.Capability; import org.snia.cdmiserver.model.CdmiObject; import org.snia.cdmiserver.model.Container; import org.snia.cdmiserver.model.Domain; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.file.Files; @@ -45,7 +36,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -@Configuration +@Component @Profile("filesystem") public class FilesystemConfiguration { @@ -54,79 +45,9 @@ public class FilesystemConfiguration { @Value("${cdmi.data.baseDirectory}") private String baseDirectory; - @Value("${cdmi.data.objectIdPrefix}") - private String objectIdPrefix; - @Value("${cdmi.qos.backend.type}") private String backendType; - /** - * Initializes the file system version of the CDMI object DAO interface. - * - * @return a {@link CdmiObjectDao} - */ - @Bean - public CdmiObjectDao cdmiObjectDao() { - CdmiObjectDaoImpl cdmiObjectDaoImpl = new CdmiObjectDaoImpl(); - cdmiObjectDaoImpl.setBaseDirectory(baseDirectory); - cdmiObjectDaoImpl.setObjectIdPrefix(objectIdPrefix); - cdmiObjectDaoImpl.setObjectIdDirectory("cdmi_objectid"); - return cdmiObjectDaoImpl; - } - - /** - * Initializes the file system version of the {@link ContainerDao}. - * - * @return a {@link ContainerDao} - */ - @Bean - public ContainerDao containerDao(CdmiObjectDao cdmiObjectDao) { - ContainerDaoImpl containerDaoImpl = new ContainerDaoImpl(); - containerDaoImpl.setBaseDirectoryName(baseDirectory); - containerDaoImpl.setCdmiObjectDao(cdmiObjectDao); - return containerDaoImpl; - } - - /** - * Initializes the file system version of the {@link DataObjectDao}. - * - * @return a {@link DataObjectDao} - */ - @Bean - public DataObjectDao dataObjectDao(CdmiObjectDao cdmiObjectDao) { - DataObjectDaoImpl dataObjectDaoImpl = new DataObjectDaoImpl(); - dataObjectDaoImpl.setBaseDirectoryName(baseDirectory); - dataObjectDaoImpl.setCdmiObjectDao(cdmiObjectDao); - return dataObjectDaoImpl; - } - - /** - * Initializes the file system version of the {@link CapabilityDao}. - * - * @return a {@link CapabilityDao} - */ - @Bean - public CapabilityDao capabilityDao(CdmiObjectDao cdmiObjectDao) { - CapabilityDaoImpl capabilityDaoImpl = new CapabilityDaoImpl(); - capabilityDaoImpl.setBaseDirectory(baseDirectory); - capabilityDaoImpl.setCdmiObjectDao(cdmiObjectDao); - return capabilityDaoImpl; - } - - /** - * Initializes the file system version of the {@link DomainDao}. - * - * @return a {@link DomainDao} - */ - @Bean - public DomainDao domainDao(CdmiObjectDao cdmiObjectDao) { - DomainDaoImpl domainDaoImpl = new DomainDaoImpl(); - domainDaoImpl.setBaseDirectoryName(baseDirectory); - domainDaoImpl.setCdmiObjectDao(cdmiObjectDao); - return domainDaoImpl; - } - - @Autowired private CdmiObjectDao cdmiObjectDao;