code cleanup
This commit is contained in:
parent
1839d28df9
commit
2e74ea1b7b
2 changed files with 36 additions and 3 deletions
|
@ -11,7 +11,11 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.lms;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
|
||||||
/** Abstract factory to create an LmsAPITemplate for specific LMS type */
|
/** Abstract factory to create an LmsAPITemplate for specific LMS type.
|
||||||
|
* Since a LmsAPITemplate of a specific LMS type
|
||||||
|
* is whether a singleton component nor a simple prototype but one (singleton) instance
|
||||||
|
* can exist per defined LMSSetup, we need a specialized factory to build such
|
||||||
|
* a LmsAPITemplate for a specific LMSSetup. */
|
||||||
public interface LmsAPITemplateFactory {
|
public interface LmsAPITemplateFactory {
|
||||||
|
|
||||||
/** Defines the LMS type if a specific implementation.
|
/** Defines the LMS type if a specific implementation.
|
||||||
|
|
|
@ -8,9 +8,12 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.olat;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.olat;
|
||||||
|
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.async.AsyncService;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
@ -21,8 +24,29 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPITemplateFactory;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
|
/** Factory for OlatLmsAPITemplate. Since a LmsAPITemplate of a specific LMS type
|
||||||
|
* is whether a singleton component nor a simple prototype but one (singleton) instance
|
||||||
|
* can exist per defined LMSSetup, we need a specialized factory to build such
|
||||||
|
* a LmsAPITemplate for a specific LMSSetup.
|
||||||
|
* </p<
|
||||||
|
* Add needed dependencies as final fields and let them inject within the constructor
|
||||||
|
* as usual. Just add the additionally needed dependencies used to build a OlatLmsAPITemplate. */
|
||||||
public class OlatLmsAPITemplateFactory implements LmsAPITemplateFactory {
|
public class OlatLmsAPITemplateFactory implements LmsAPITemplateFactory {
|
||||||
|
|
||||||
|
private final AsyncService asyncService;
|
||||||
|
private final Environment environment;
|
||||||
|
private final CacheManager cacheManager;
|
||||||
|
|
||||||
|
public OlatLmsAPITemplateFactory(
|
||||||
|
final AsyncService asyncService,
|
||||||
|
final Environment environment,
|
||||||
|
final CacheManager cacheManager) {
|
||||||
|
|
||||||
|
this.asyncService = asyncService;
|
||||||
|
this.environment = environment;
|
||||||
|
this.cacheManager = cacheManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LmsType lmsType() {
|
public LmsType lmsType() {
|
||||||
return LmsType.OPEN_OLAT;
|
return LmsType.OPEN_OLAT;
|
||||||
|
@ -30,8 +54,13 @@ public class OlatLmsAPITemplateFactory implements LmsAPITemplateFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<LmsAPITemplate> create(final APITemplateDataSupplier apiTemplateDataSupplier) {
|
public Result<LmsAPITemplate> create(final APITemplateDataSupplier apiTemplateDataSupplier) {
|
||||||
// TODO Auto-generated method stub
|
return Result.tryCatch(() -> {
|
||||||
return null;
|
return new OlatLmsAPITemplate(
|
||||||
|
apiTemplateDataSupplier,
|
||||||
|
this.asyncService,
|
||||||
|
this.environment,
|
||||||
|
this.cacheManager);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue