Example usage for org.springframework.core.env Environment getProperty

List of usage examples for org.springframework.core.env Environment getProperty

Introduction

In this page you can find the example usage for org.springframework.core.env Environment getProperty.

Prototype

@Nullable
String getProperty(String key);

Source Link

Document

Return the property value associated with the given key, or null if the key cannot be resolved.

Usage

From source file:com.porvak.bracket.social.database.upgrade.v3.UpdateEncryptionMethod.java

License:asdf

@Inject
public UpdateEncryptionMethod(Environment environment, TextEncryptor newEncryptor) {
    this.oldEncryptor = new SearchableStringEncryptor(environment.getProperty("security.encryptPassword"),
            environment.getProperty("security.encryptSalt"));
    this.newEncryptor = newEncryptor;
}

From source file:ro.teamnet.hero.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.consumerKey"),
            env.getProperty("twitter.consumerSecret")));
    cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.clientId"),
            env.getProperty("facebook.clientSecret")));
    cfConfig.addConnectionFactory(new LinkedInConnectionFactory(env.getProperty("linkedin.consumerKey"),
            env.getProperty("linkedin.consumerSecret")));
}

From source file:ch.sdi.core.impl.data.converter.ConverterFactory.java

/**
 * Looks up the configured converter for a collector fieldname.
 * <p>//  w w w.j  av  a2 s.c o  m
 * If the fieldname has no configured converter the standard ConverterString() (which does nothing) is
 * returned.
 * <p>
 *
 * @param aFieldname must not be empty
 * @return the appropriate converter
 * @throws SdiException if the configured converter cannot be found
 */
public FieldConverter<?> getConverterFor(String aFieldname) throws SdiException {
    if (!StringUtils.hasText(aFieldname)) {
        throw new SdiException("Given fieldname is empty!", SdiException.EXIT_CODE_UNKNOWN_ERROR);

    } // if !StringUtils.hasText( aFieldname )

    myLog.debug("Looking up converter for field " + aFieldname);

    Environment env = myAppCtxt.getEnvironment();
    String converterName = env.getProperty(SdiMainProperties.KEY_PREFIX_CONVERTER + aFieldname);

    if (!StringUtils.hasText(converterName)) {
        return new ConverterString().init(env, aFieldname);
    } // if !StringUtils.hasText( converterName )

    myLog.debug("Looking up converter with name " + converterName);

    Map<String, Object> beans = myAppCtxt.getBeansWithAnnotation(SdiConverter.class);

    myLog.trace("Found candidates for converter: " + beans.keySet());

    for (Object bean : beans.values()) {
        if (!(bean instanceof FieldConverter)) {
            throw new SdiException("Bean annotated with @SdiConverter which is not a FieldConverter, but: "
                    + bean.getClass().getName(), SdiException.EXIT_CODE_CONFIG_ERROR);
        } // if !bean instanceof FieldConverter

        FieldConverter<?> converter = (FieldConverter<?>) bean;

        SdiConverter annotation = bean.getClass().getAnnotation(SdiConverter.class);
        String value = annotation.value();

        if (converterName.equals(value)) {
            return converter.init(env, aFieldname);
        } // if converterName.equals( value )
    }

    throw new SdiException("Converter " + converterName + " for field '" + aFieldname + "' not found",
            SdiException.EXIT_CODE_CONFIG_ERROR);
}

From source file:com.kdubb.socialshowcaseboot.config.SocialConfig.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
    cfConfig.addConnectionFactory(new TwitterConnectionFactory(env.getProperty("twitter.appKey"),
            env.getProperty("twitter.appSecret")));
    cfConfig.addConnectionFactory(new FacebookConnectionFactory(env.getProperty("facebook.appKey"),
            env.getProperty("facebook.appSecret")));
    cfConfig.addConnectionFactory(new LinkedInConnectionFactory(env.getProperty("linkedin.appKey"),
            env.getProperty("linkedin.appSecret")));
}

From source file:ch.sdi.core.impl.data.converter.ConverterNumberList.java

/**
 * @see ch.sdi.core.intf.FieldConverter#init(org.springframework.core.env.Environment, java.lang.String)
 *///  ww  w . j a va2  s  .c om
@Override
public FieldConverter<List<Number>> init(Environment aEnv, String aFieldname) throws SdiException {
    String delimiter = aEnv.getProperty(
            SdiMainProperties.KEY_PREFIX_CONVERTER + CONVERTER_NAME + "." + aFieldname + DELIMITER_SUFFIX);
    if (!StringUtils.hasText(delimiter)) {
        myLog.trace("No delimiter found for field " + aFieldname + ". Looking for a generic delimiter");
        delimiter = aEnv
                .getProperty(SdiMainProperties.KEY_PREFIX_CONVERTER + CONVERTER_NAME + DELIMITER_SUFFIX);
    } // if !StringUtils.hasText( pattern )

    if (!StringUtils.hasText(delimiter)) {
        myLog.warn("No delimiter found for field " + aFieldname + ". Setting to default '/'");
        delimiter = "/";
    } else {
        delimiter = delimiter.trim();
        myLog.debug("found delimiter for ConverterNumberList: " + delimiter);
    }

    setDelimiter(delimiter);
    return this;
}

From source file:org.meruvian.yama.webapi.service.RestUserService.java

@Override
public void setEnvironment(Environment environment) {
    uploadPath = environment.getProperty("upload.path.profile_pic");
    profilePicPath = environment.getProperty("default.profile_pic.path");
}

From source file:com.folion.config.SocialConfiguration.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment env) {

    FacebookAuthenticationService facebookAuthenticationService = new FacebookAuthenticationService(
            env.getProperty("facebook.appKey"), env.getProperty("facebook.appSecret"));
    facebookAuthenticationService.setDefaultScope("email");

    connectionFactoryConfigurer.addConnectionFactory(facebookAuthenticationService.getConnectionFactory());
}

From source file:org.dawnsci.marketplace.services.FileService.java

public FileService(Environment environment) {
    solutionsRoot = new File(System.getProperty("user.dir"),
            environment.getProperty("marketplace.solutions-folder")).toPath();
    if (!solutionsRoot.toFile().exists()) {
        solutionsRoot.toFile().mkdirs();
    }// w  w  w  . j ava  2s.  com
    pagesRoot = new File(System.getProperty("user.dir"), environment.getProperty("marketplace.pages-folder"))
            .toPath();
    if (!pagesRoot.toFile().exists()) {
        pagesRoot.toFile().mkdirs();
    }
    // make sure that the required file resources are present
    try {
        copyRequiredFile("welcome.md");
        copyRequiredFile("marketplace-icon.png");
        copyRequiredFile("catalog-icon.png");
        copyRequiredFile("wizard-icon.png");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.dawnsci.marketplace.config.SocialConfiguration.java

@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer,
        Environment environment) {
    // a TwitterConnectionFactory has already been configured elsewhere
    connectionFactoryConfigurer.addConnectionFactory(
            new GoogleConnectionFactory(environment.getProperty("spring.social.google.app-id"),
                    environment.getProperty("spring.social.google.app-secret")));
    connectionFactoryConfigurer.addConnectionFactory(
            new GitHubConnectionFactory(environment.getProperty("spring.social.github.app-id"),
                    environment.getProperty("spring.social.github.app-secret")));
}

From source file:org.juiser.spring.boot.config.JuiserSpringSecurityCondition.java

private boolean isSpringSecurityEnabled(ConditionContext ctx) {

    boolean enabled = true;

    Environment env = ctx.getEnvironment();

    for (String propName : props) {
        if (env.containsProperty(propName)) {
            if (!Boolean.parseBoolean(env.getProperty(propName))) {
                enabled = false;//from  w  w w. j  av a  2  s.co m
                break;
            }
        }
    }

    if (enabled) {
        enabled = ClassUtils.isPresent(SPRING_SEC_CLASS_NAME, ctx.getClassLoader());
    }

    return enabled;
}