Skip to content

Instantly share code, notes, and snippets.

@neilherbertuk
Last active January 23, 2023 08:05
Show Gist options
  • Save neilherbertuk/4d700c30ce05fa69cb8b3b630d42aeac to your computer and use it in GitHub Desktop.
Save neilherbertuk/4d700c30ce05fa69cb8b3b630d42aeac to your computer and use it in GitHub Desktop.
An example of how to retrieve values from OpenIAM's PropertyValueCache - https://neilherbert.uk/2023/01/avoiding-hardcoded-values-in-openiam-groovy-scripts/
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import org.openiam.idm.srvc.property.service.PropertyValueCache
import org.springframework.context.ApplicationContext
// Dependencies
Log log = LogFactory.getLog("propertValueExample") // Logging
ApplicationContext appContext = (ApplicationContext) context // IoC Container
PropertyValueCache propertyValueCache = appContext.getBean(PropertyValueCache.class) // Global Settings
log.info("Getting Value from PropertyValueCache")
String value = propertyValueCache.getString("uk.neilherbert.openiam.name") ?: "Not Found"
log.info("${value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment