com.github.dynamicextensionsalfresco.models.DAOModelRegistrar.kt 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 org.alfresco.repo.dictionary.DictionaryDAO
import org.alfresco.repo.dictionary.M2Model
import org.alfresco.service.namespace.QName
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Required
import java.util.*
/**
* Registers and unregisters [M2Model]s with a [DictionaryDAO]. This class is stateful and intended to
* support dynamic loading of models.
* @author Laurens Fridael
*/
public open class DAOModelRegistrar(private val dictionaryDao: DictionaryDAO, modelsToRegister: M2ModelListProvider) : AbstractModelRegistrar(modelsToRegister) {
private val logger = LoggerFactory.getLogger(javaClass)
/* State */
private val registeredModelNames = LinkedList()
/* Main operations */
override fun unregisterModels() {
val it = registeredModelNames.iterator()
while (it.hasNext()) {
val modelName = it.next()
try {
logger.debug("Unregistering model '{}' via DictionaryDAO", modelName)
dictionaryDao.removeModel(modelName)
} finally {
it.remove()
}
}
}
override fun registerModel(modelResource: M2ModelResource) {
val qName = dictionaryDao.putModel(modelResource.m2Model)
registeredModelNames.add(qName)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy