Search in sources :

Example 1 with DynamicPropertyFactory

use of com.netflix.config.DynamicPropertyFactory in project eureka by Netflix.

the class ExampleEurekaService method main.

public static void main(String[] args) {
    DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance();
    ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig());
    EurekaClient eurekaClient = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig());
    ExampleServiceBase exampleServiceBase = new ExampleServiceBase(applicationInfoManager, eurekaClient, configInstance);
    try {
        exampleServiceBase.start();
    } finally {
        // the stop calls shutdown on eurekaClient
        exampleServiceBase.stop();
    }
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Example 2 with DynamicPropertyFactory

use of com.netflix.config.DynamicPropertyFactory in project eureka by Netflix.

the class Archaius1Utils method initConfig.

public static DynamicPropertyFactory initConfig(String configName) {
    DynamicPropertyFactory configInstance = DynamicPropertyFactory.getInstance();
    DynamicStringProperty EUREKA_PROPS_FILE = configInstance.getStringProperty("eureka.client.props", configName);
    String env = ConfigurationManager.getConfigInstance().getString(EUREKA_ENVIRONMENT, "test");
    ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, env);
    String eurekaPropsFile = EUREKA_PROPS_FILE.get();
    try {
        ConfigurationManager.loadCascadedPropertiesFromResources(eurekaPropsFile);
    } catch (IOException e) {
        logger.warn("Cannot find the properties specified : {}. This may be okay if there are other environment " + "specific properties or the configuration is installed with a different mechanism.", eurekaPropsFile);
    }
    return configInstance;
}
Also used : DynamicStringProperty(com.netflix.config.DynamicStringProperty) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) IOException(java.io.IOException)

Example 3 with DynamicPropertyFactory

use of com.netflix.config.DynamicPropertyFactory in project eureka by Netflix.

the class ExampleEurekaGovernatedService method init.

private static LifecycleInjector init() throws Exception {
    System.out.println("Creating injector for Example Service");
    LifecycleInjector injector = InjectorBuilder.fromModules(new EurekaModule(), new ExampleServiceModule()).overrideWith(new AbstractModule() {

        @Override
        protected void configure() {
            DynamicPropertyFactory configInstance = com.netflix.config.DynamicPropertyFactory.getInstance();
            bind(DynamicPropertyFactory.class).toInstance(configInstance);
            // the default impl of EurekaInstanceConfig is CloudInstanceConfig, which we only want in an AWS
            // environment. Here we override that by binding MyDataCenterInstanceConfig to EurekaInstanceConfig.
            bind(EurekaInstanceConfig.class).to(MyDataCenterInstanceConfig.class);
        // (DiscoveryClient optional bindings) bind the optional event bus
        // bind(EventBus.class).to(EventBusImpl.class).in(Scopes.SINGLETON);
        }
    }).createInjector();
    System.out.println("Done creating the injector");
    return injector;
}
Also used : EurekaModule(com.netflix.discovery.guice.EurekaModule) EurekaInstanceConfig(com.netflix.appinfo.EurekaInstanceConfig) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) LifecycleInjector(com.netflix.governator.LifecycleInjector) AbstractModule(com.google.inject.AbstractModule)

Aggregations

DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)3 AbstractModule (com.google.inject.AbstractModule)1 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)1 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)1 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)1 DynamicStringProperty (com.netflix.config.DynamicStringProperty)1 DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)1 EurekaClient (com.netflix.discovery.EurekaClient)1 EurekaModule (com.netflix.discovery.guice.EurekaModule)1 LifecycleInjector (com.netflix.governator.LifecycleInjector)1 IOException (java.io.IOException)1