Skip to content

Instantly share code, notes, and snippets.

@dkowis
Created November 11, 2014 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkowis/3f753f3259fa8509c3d9 to your computer and use it in GitHub Desktop.
Save dkowis/3f753f3259fa8509c3d9 to your computer and use it in GitHub Desktop.
package org.openrepose.spring
import java.net.URL
import org.openrepose.commons.config.parser.ConfigurationParserFactory
import org.openrepose.commons.config.resource.impl.BufferedURLConfigurationResource
import org.openrepose.core.container.config.ContainerConfiguration
import org.openrepose.core.systemmodel.SystemModel
import scala.reflect.ClassTag
object ConfigurationObjects {
val systemModelXSD = getClass.getResource("/META-INF/schema/system-model/system-model.xsd")
val containerConfigXSD = getClass.getResource("/META-INF/schema/container/container-configuration.xsd")
def systemModel(resource: String): SystemModel = {
configResource[SystemModel](resource, systemModelXSD)
}
def containerConfig(resource: String): ContainerConfiguration = {
configResource[ContainerConfiguration](resource, containerConfigXSD)
}
def configResource[T:ClassTag](resource: String, xsdURL: URL): T = {
import scala.reflect._
val ct:ClassTag[T] = classTag[T]
val parser = ConfigurationParserFactory.getXmlConfigurationParser(
ct.runtimeClass.asInstanceOf[Class[T]],
xsdURL)
val configResource = new BufferedURLConfigurationResource(this.getClass.getResource(resource))
parser.read(configResource)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment