Anatole Tresch & Werner Keil
Trivadis AG @atsticks @wernerkeil
Anatole Tresch & Werner Keil Trivadis AG @atsticks - - PowerPoint PPT Presentation
Anatole Tresch & Werner Keil Trivadis AG @atsticks @wernerkeil Apache T amaya Configuration Management Bio Anatole Tresch Principal Consultant, Trivadis AG (Switzerland) Star Spec Lead JSR 354 Technical
Trivadis AG @atsticks @wernerkeil
Anatole Tresch
3
Bio
Werner Keil
4
Bio
Agenda
5
6
General Infos
7
aspect for Java EE 8
History of Apache Tamaya
The People behind Tamaya
8
The Objectives of Apache Tamaya
9
What people think is configuration?
11
What we think is configuration
12
Component X Component Y
<dependency>
Configuration
<dependency>
Components:
Behaviour and state Transitive Deps Scopes Code Dynamic Not serializalbe
Configuration:
Data, Value Types Transitive Deps Scopes Key, value pairs Static Serializable
UC: Access Configuration Similarly
14
Configuration
API API
MicroService Container IaaS PaaS Cache SaaS Build-Tool
SPI
UC: Reduce Redundancy
15
Service Foo Cache Foo Configuration:
Service.host.ip=192.168.1.10 Service.stage=test Service.param=paramValue
Redundant!
File 1 File 2
Tamaya Configuration Foo Configuration:
Service.host.ip=${env:HOST_IP} Service.stage=${env:STAGE} Service.param=paramValue
Cache Configuration:
Cache.host.ip=192.168.1.10 Cache.stage=test Cache.param=cacheValue
Tamaya Configuration Cache Configuration:
Cache.host.ip=${env:HOST_IP} Cache.stage=${env:STAGE} Cache.param=cacheValue
Tamaya Configuration Tamaya Configuration
UC: Convention over Configuration
16
Foo Configuration:
Service.host.ip=${cfg:env.host.ip} Service.stage=${cfg:env.stage} Service.param=paramValue
Cache Configuration:
Cache.host.ip=${cfg:env.host.ip} Cache.stage=${cfg:env.stage} Cache.param=cacheValue
Defaults:
env.host.ip=${env:HOST_IP} env.stage=${env:STAGE}
Service Foo Cache Tamaya Configuration Tamaya Configuration
UC: Pluggable Config Backends
Classic: Tamaya Configuration
17
Distributed:
ZooKeeper Etcd ...
Classic Policy (PropertySources)
Myproject/bin/... Myproject/conf/server.xml Myproject/conf/cluster.xml Myproject/conf/security.xml Myproject/lib/...
...
Unified Config API
Remote Policy (PropertySources) ??? Unified API for configuration access Policies can be provided as jar- artifacts separately Additional benefits: config documentation Your Project
UC: Enterprise Integration
18
Company X: Config SOAP
Myproject/bin/... Myproject/conf/server.xml Myproject/conf/cluster.xml Myproject/conf/security.xml Myproject/lib/... ...
Company Z: Config Rest Company Y: etcd
Company A: Legacy Config
Tamaya Configuration Classic Policy (PropertySources)
Unified Config API
Config Integration (PropertySources) Your Project
19
Service Foo Cache
Tamaya Configuration Tamaya Configuration
Locations:
file:${filedir} classpath:META-INF/defaults/configuration.*
classpath:META-INF/${STAGE}/configuration.*
url:http://myserver.int/cfg System properties Env. PropertiesFormats:
properties xml json yamlConfig Policy <implements>
Define, implement and distribute Company Wide Configuration Policy Policy Policy
<implements>
UC: Enforceable Policies
20
supported as well
Summary: Why we need Tamaya?
The API
21
Let's start simple!
22
Configuration config = ConfigurationProvider.getConfiguration(); String name = config.getOrDefault("name", "John"); int ChildNum = config.get("childNum", int.class);
ConfigurationProvider
23
public class ConfigurationProvider{ public static Configuration getConfiguration(); public static ConfigurationContext getConfigurationContext(); public static ConfigurationContextBuilder getConfigurationContextBuilder() public static void setConfigurationContext( ConfigurationContext context); }
24
public interface Configuration{ String get(String key); String getOrDefault(String key, String defaultValue); <T> T get(String key, Class<T> type); <T> T get(String key, TypeLiteral<T> type); <T> T getOrDefault(String key, Class<T> type, T defaultValue); <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue); Map<String,String> getProperties(); // Functional Extension Points Configuration with(ConfigOperator operator): <T> T query(ConfigQuery<T> query); }
Configuration
Core Concepts
25
PropertySources
ConfigurationContext PropertyFilters PropertySource PropertySource PropertySource PropertySource Configuration CombinationPolicy PropertyProviders
<provides>
P r
e r t y C
v e r t e r
Overriding Basics
26
#default ordinal = 0 name=Benjamin childNum=0 family=Tresch #override ordinal tamaya.ordinal=10 name=Anatole childNum=3 tamaya.ordinal=10 name=Anatole childNum=3 family=Tresch
CombinationPolicy
27
list=a,b,c list{collection-type}=List tamaya.ordinal=10 list=aa,bb tamaya.ordinal=10 list=aa,bb,a,b,c list{collection-type}=List
SPI: PropertySource PropertySourceProvider
public interface PropertySource { static final String TAMAYA_ORDINAL = "tamaya.ordinal"; String getName(); int getOrdinal(); String get(String key); Map<String, String> getProperties(); } public interface PropertySourceProvider { Collection<PropertySource> getPropertySources(); }
Extension Modules
29
Available Plugins
30
configuration
* work in progress
Planned Features
31
Configuration Injection
32
@ConfiguredType(defaultSections=”com.mycomp.tenantAdress”) public final class MyTenant{ private String name; @ConfiguredProperty @DefaultValue(”2000”) private long customerId; @ConfiguredProperty(keys={ ”privateAddress”,”businessAdress”,”[my.qualified.adress]” }) private String address; ... }
MyTenant t = new MyTenant(); ConfigurationInjection .getConfigurationInjector() .configure(t); MyTenant t = new MyTenant(); ConfigurationInjection .getConfigurationInjector() .configure(t); @RequestScoped public class MyClass{ @Inject private MyTenant t; … } @RequestScoped public class MyClass{ @Inject private MyTenant t; … }
Configuration Template
33
@ConfiguredType(defaultSections=”com.mycomp.tenantAdress”) public interface MyTenant{ public String getName(); @ConfiguredProperty @DefaultValue(”2000”) public long getCustomerId(); @ConfiguredProperty(keys={ ”privateAddress”,”businessAdress”,”[my.qualified.adress]” }) public String getAddress(); }
MyTenant t = ConfigurationInjection .getConfigurationInjector() .createTemplate(MyTenant.class); MyTenant t = ConfigurationInjection .getConfigurationInjector() .createTemplate(MyTenant.class);
Demo
34
Summary
35
Apache Tamaya Provides
We need help
36
Apache Tamaya is great, but we need you...
Links
https://oracleus.activeevents.com/2013/connect/sessionDetail.ww?SESSION_ID=7755
http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg37597.html
37
Q&A
38
Anatole Tresch
Trivadis AG Principal Consultant Twitter/Google+: @atsticks anatole@apache.org anatole.tresch@trivadis.com