com.github.dynamicextensionsalfresco.osgi.DependencySorter.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
//REPLACED BY JAVA. Nothing against Kotlin, just no reason to use multiple languages with only a few classes of one
// in the same project.
//package com.github.dynamicextensionsalfresco.osgi
//
//import org.slf4j.LoggerFactory
//import java.util.*
//
///**
// * Generic dependency sorter based on imports and exports.
// *
// * @author Laurent Van der Linden.
// */
//public object DependencySorterOld {
// val logger = LoggerFactory.getLogger(javaClass)
//
// fun sort(input: Collection, metadataPovider: DependencyMetadataProvider): Collection {
// val result = ArrayList()
//
// val exports = collectExports(input, metadataPovider)
//
// val visitedItems = ArrayList()
//
// for (item in input) {
// visit(item, exports, result, visitedItems, metadataPovider)
// }
//
// if (logger.isDebugEnabled) {
// logger.debug("sorting ${input.firstOrNull()}:")
// logger.debug(" input")
// for (item in input) {
// logger.debug(" - $item")
// }
// logger.debug(" output")
// for (item in result) {
// logger.debug(" - $item")
// }
// }
//
// return result
// }
//
// private fun collectExports(items: Collection, metadataProvider: DependencyMetadataProvider): Map {
// val result = HashMap()
//
// for (item in items) {
// val exports = metadataProvider.exports(item)
// for (export in exports) {
// result.put(export, item)
// }
// }
//
// return result
// }
//
// private fun visit(item: T, exports: Map, output: MutableList,
// visited: ArrayList, metadataProvider: DependencyMetadataProvider) {
// visited.add(item)
// val imports = metadataProvider.imports(item)
// for (import in imports) {
// val exportingItem = exports.get(import)
// if (exportingItem != null && exportingItem != item && !output.contains(exportingItem)) {
// logger.debug("visit {} from {} for import {}", exportingItem, item, import)
// if (!visited.contains(exportingItem)) {
// visit(exportingItem, exports, output, visited, metadataProvider)
// } else if (!metadataProvider.allowCircularReferences) {
// throw IllegalArgumentException(
// "Circular dependency detected between %s and %s for import %s".format(item, exportingItem, import)
// )
// }
// }
// }
//
// if (!output.contains(item)) {
// output.add(item)
// }
// }
//}
//
//interface DependencyMetadataProvider {
// val allowCircularReferences: Boolean
//
// fun imports(item: T): Collection
//
// fun exports(item: T): Collection
//}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy