com.github.dynamicextensionsalfresco.web.WebResourcesRegistrar.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annotations-runtime Show documentation
Show all versions of annotations-runtime 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.web
import com.github.dynamicextensionsalfresco.webscripts.WebScriptUriRegistry
import org.osgi.framework.BundleContext
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 org.springframework.extensions.webscripts.WebScript
import javax.annotation.PostConstruct
import javax.annotation.PreDestroy
/**
* Register resources webscript if /META-INF/alfresco/web resources are found
*
* @author Laurent Van der Linden
*/
public class WebResourcesRegistrar @Autowired constructor(
private val webscriptRegistry: WebScriptUriRegistry,
private val bundleContext: BundleContext) :ResourceLoaderAware {
private var resourcePatternResolver: ResourcePatternResolver? = null
private var currentWebscript: WebScript? = null
@PostConstruct
fun registerResourceWebscript() {
if (resourcePatternResolver?.getResources("osgibundle:$WEB_PATH**")?.isNotEmpty() ?: false) {
currentWebscript = ResourceWebscript(bundleContext)
webscriptRegistry.registerWebScript(currentWebscript)
}
}
@PreDestroy
fun unregisterResourceWebscript() {
if (currentWebscript != null) {
webscriptRegistry.unregisterWebScript(currentWebscript)
}
}
override fun setResourceLoader(resourceLoader: ResourceLoader?) {
this.resourcePatternResolver = resourceLoader as ResourcePatternResolver
}
companion object {
val WEB_PATH = "/META-INF/alfresco/web/"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy