use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource in project indy by Commonjava.
the class CacheProducer method start.
@PostConstruct
public void start() {
// FIXME This is just here to trigger shutdown hook init for embedded log4j in infinispan-embedded-query.
// FIXES:
//
// Thread-15 ERROR Unable to register shutdown hook because JVM is shutting down.
// java.lang.IllegalStateException: Cannot add new shutdown hook as this is not started. Current state: STOPPED
//
new MarshallableTypeHints().getBufferSizePredictor(CacheHandle.class);
File confDir = indyConfiguration.getIndyConfDir();
File ispnConf = new File(confDir, ISPN_XML);
String configuration;
if (ispnConf.exists()) {
try {
configuration = FileUtils.readFileToString(ispnConf);
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration from file: " + ispnConf, e);
}
} else {
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(ISPN_XML)) {
configuration = IOUtils.toString(stream);
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration from classpath: " + ISPN_XML, e);
}
}
StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
try {
configuration = interpolator.interpolate(configuration);
} catch (InterpolationException e) {
throw new RuntimeException("Cannot resolve expressions in infinispan configuration.", e);
}
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("Using Infinispan configuration:\n\n{}\n\n", configuration);
try {
cacheManager = new DefaultCacheManager(new ByteArrayInputStream(configuration.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration.", e);
}
}
use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource in project sling by apache.
the class BundleListUtils method createInterpolator.
public static Interpolator createInterpolator(MavenProject project, MavenSession mavenSession) {
StringSearchInterpolator interpolator = new StringSearchInterpolator();
final Properties props = new Properties();
props.putAll(project.getProperties());
props.putAll(mavenSession.getSystemProperties());
props.putAll(mavenSession.getUserProperties());
interpolator.addValueSource(new PropertiesBasedValueSource(props));
// add ${project.foo}
interpolator.addValueSource(new PrefixedObjectValueSource(Arrays.asList("project", "pom"), project, true));
// add ${session.foo}
interpolator.addValueSource(new PrefixedObjectValueSource("session", mavenSession));
// add ${settings.foo}
final Settings settings = mavenSession.getSettings();
if (settings != null) {
interpolator.addValueSource(new PrefixedObjectValueSource("settings", settings));
}
return interpolator;
}
use of org.codehaus.plexus.interpolation.PropertiesBasedValueSource in project indy by Commonjava.
the class SecurityController method getInterpolator.
private StringSearchInterpolator getInterpolator() {
final Properties props = new Properties();
props.setProperty(KeycloakConfig.KEYCLOAK_REALM, config.getRealm());
props.setProperty(KeycloakConfig.KEYCLOAK_URL, config.getUrl());
if (config.getUiResource() != null) {
props.setProperty(KeycloakConfig.KEYCLOAK_UI_RESOURCE, config.getUiResource());
}
if (config.getRealmPublicKey() != null) {
props.setProperty(KeycloakConfig.KEYCLOAK_REALM_PUBLIC_KEY, config.getRealmPublicKey());
}
final StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.addValueSource(new PropertiesBasedValueSource(props));
return interpolator;
}
Aggregations