@Bean public Yaml yaml() { Yaml yaml = new Yaml(); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; } }
@Bean @Scope("prototype") public Yaml yaml() { Yaml yaml = new Yaml(); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; }
@Bean @Scope("prototype") public Yaml yaml() { Yaml yaml = new Yaml(); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; }
void loadEntities(String... files) { Yaml yaml = new Yaml(this); yaml.setBeanAccess(beanAccess); for(String file : files) { if(!file.startsWith("/")) { file = "/" + file; } String origPackage = this.packageName; this.packageName = this.defaultPackage; yaml.load(getClass().getResourceAsStream(file)); this.packageName = origPackage; } }
public static <T> T readConfigFile(Path file, Class<T> classType) throws CarbonSecurityServerException { try (InputStreamReader inputStreamReader = new InputStreamReader(Files.newInputStream(file), StandardCharsets.UTF_8)) { Yaml yaml = new Yaml(); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(inputStreamReader, classType); } catch (IOException e) { throw new CarbonSecurityServerException( String.format("Error in reading file %s", file.toString()), e); } }
/** * Returns a config object from identity.yaml when given the config key and the config object type. * * @param configKey Configuration identifier key. * @param t Configuration value class type. * @param <T> Configuration value class type. * @return Configuration class type object. */ public <T> T getConfiguration(String configKey, Class<T> t) { Object configValue = identityConfigs.get(configKey); Map<String, Object> configEntry = new HashMap<>(); configEntry.put(configKey, configValue); Yaml yaml = new Yaml(); String dump = yaml.dump(configEntry); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(dump, t); }
public static <T> T readConfigFile(Path file, Class<T> classType) throws IdentityRecoveryException { try (InputStreamReader inputStreamReader = new InputStreamReader(Files.newInputStream(file), StandardCharsets.UTF_8)) { CustomClassLoaderConstructor constructor = new CustomClassLoaderConstructor(FileUtil.class.getClassLoader()); Yaml yaml = new Yaml(constructor); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(inputStreamReader, classType); } catch (IOException e) { throw new IdentityRecoveryException( String.format("Error in reading file %s", file.toString()), e); } }
private static IdPClientConfiguration readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(IdPClientConfiguration.class, IdPClientConfiguration.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, IdPClientConfiguration.class); }
private RDBMSDataProviderConfBean readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(RDBMSDataProviderConfBean.class, RDBMSDataProviderConfBean.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, RDBMSDataProviderConfBean.class); } }
private BusinessRulesQueryConfigs readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(BusinessRulesQueryConfigs.class, BusinessRulesQueryConfigs.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, BusinessRulesQueryConfigs.class); } }
private PersistenceStoreConfigs readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(PersistenceStoreConfigs.class, PersistenceStoreConfigs.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, PersistenceStoreConfigs.class); } }
private StrategyConfig readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(StrategyConfig.class, StrategyConfig.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, StrategyConfig.class); } }
private DeploymentConfig readYamlContent(InputStream yamlContent) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(DeploymentConfig.class, DeploymentConfig.class.getClassLoader())); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlContent, DeploymentConfig.class); } }
@Override public List<MailReceiver> readMailReceiver() { File dir = git.getRepo().directory(); File file = new File(dir, "/mailinglists.yml"); if (!file.exists()) { return null; } try { Yaml yaml = new Yaml(); yaml.setBeanAccess(BeanAccess.FIELD); return (List<MailReceiver>) yaml.load(FileUtils.readFileToString(file)); } catch (IOException e) { log.error(e.getMessage(), e); } return null; }
/** * Returns the configuration object for the given YAML string. * * @param configClass returning configuration object type * @param classLoader class loader of the configuration object * @param yamlString YAML string * @param <T> type of the returning configuration object * @return configuration object for the given YAML string */ private <T> T getConfigurationObject(Class<T> configClass, ClassLoader classLoader, String yamlString) { Yaml yaml = new Yaml(new CustomClassLoaderConstructor(configClass, classLoader)); yaml.setBeanAccess(BeanAccess.FIELD); return yaml.loadAs(yamlString, configClass); }
private List<Queries> readConfigs() { List queries; try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(FILE_SQL_QUERIES)) { if (inputStream == null) { throw new RuntimeException("Cannot find file '" + FILE_SQL_QUERIES + "' in class path."); } Yaml yaml = new Yaml(new OsgiClassLoaderConstructor()); yaml.setBeanAccess(BeanAccess.FIELD); queries = yaml.loadAs(inputStream, PermissionConfig.class).getQueries(); } catch (IOException e) { throw new RuntimeException("Cannot read YAML file '" + FILE_SQL_QUERIES + "' from classpath.", e); } catch (Exception e) { throw new RuntimeException("YAML file '" + FILE_SQL_QUERIES + "' is invalid.", e); } return queries; }
public ConfigSerializer() { final DumperOptions options = new DumperOptions(); options.setPrettyFlow(true); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); yaml = new Yaml(new ConfigConstructor(), new ConfigRepresenter(), options); yaml.setBeanAccess(BeanAccess.FIELD); }
private static Yaml getYaml() { Representer representer = new TapeRepresenter(); representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG); Constructor constructor = new TapeConstructor(); constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG)); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(BLOCK); dumperOptions.setWidth(256); Yaml yaml = new Yaml(constructor, representer, dumperOptions); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; } }
private Yaml getYaml() { Representer representer = new TapeRepresenter(fileResolver); representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG); Constructor constructor = new TapeConstructor(fileResolver); constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG)); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(BLOCK); dumperOptions.setWidth(256); Yaml yaml = new Yaml(constructor, representer, dumperOptions); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; }
private static Yaml getYaml() { Representer representer = new TapeRepresenter(); representer.addClassTag(YamlTape.class, YamlTape.TAPE_TAG); Constructor constructor = new TapeConstructor(); constructor.addTypeDescription(new TypeDescription(YamlTape.class, YamlTape.TAPE_TAG)); DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setDefaultFlowStyle(BLOCK); dumperOptions.setWidth(256); Yaml yaml = new Yaml(constructor, representer, dumperOptions); yaml.setBeanAccess(BeanAccess.FIELD); return yaml; } }