com.github.dynamicextensionsalfresco.models.AbstractModelRegistrar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alfresco-integration Show documentation
Show all versions of alfresco-integration Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.models;
import com.github.dynamicextensionsalfresco.osgi.DependencyMetadataProvider;
import com.github.dynamicextensionsalfresco.osgi.DependencySorter;
import org.alfresco.repo.dictionary.M2Namespace;
import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternResolver;
import java.util.ArrayList;
import java.util.Collection;
/**
* Created by jasper on 17/07/17.
*/
public abstract class AbstractModelRegistrar implements ModelRegistrar, ResourceLoaderAware, DependencyMetadataProvider {
private final Logger logger = LoggerFactory.getLogger(AbstractModelRegistrar.class);
protected ResourcePatternResolver resourcePatternResolver;
public AbstractModelRegistrar(){
}
public AbstractModelRegistrar(M2ModelListProvider modelsToRegister){
this.modelsToRegister = modelsToRegister;
}
@Autowired
public void setModelsToRegister(M2ModelListProvider modelsToRegister){
this.modelsToRegister = modelsToRegister;
}
public M2ModelListProvider modelsToRegister;
private void setResourcePatternResolver(ResourcePatternResolver resourcePatternResolver) {
this.resourcePatternResolver = resourcePatternResolver;
}
@Override
public void registerModels() {
Collection sortedModels = DependencySorter.sort(modelsToRegister.getModels(), this);
for (M2ModelResource modelResource:sortedModels) {
try {
registerModel(modelResource);
} catch (DictionaryException e){
if (logger.isWarnEnabled()) {
logger.warn("Could not register model '${modelResource.name}'", e);
}
}
}
}
@Override
public Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy