Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Configuration beyond Java EE 8
1. BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF
HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH
Configuration
beyond
Java EE
Configuration
with Apache
Tamaya and Microprofile.io
2. Configuration beyond Java EE 828.03.2017
Anatole Tresch
Principal Consultant, Trivadis AG (Switzerland)
Star Spec Lead
Technical Architect, Lead Engineer
PPMC Member Apache Tamaya
@atsticks
anatole@apache.org
anatole.tresch@trivadis.com
2
About Me
3. Configuration beyond Java EE 828.03.2017
Agenda
3
●
What‘s all about ?
●
Framework Architecture
●
Accessing Configuration
●
Configuration Backends
●
Configuration Runtime
●
Services
●
Demo / Adoption Area
7. Configuration beyond Java EE 828.03.2017
7
How is it stored?
Remotely or locally?
Classpath, file or ...?
Which format?
All of the above (=multiple sources) ?
8. Configuration beyond Java EE 828.03.2017 8
When to configure?
Development time ?
Build/deployment time?
Startup?
Dynamic, anytime?
19. Configuration beyond Java EE 828.03.2017
19
Accessing Config: Injection
public class NonAnnotatedConfigBean {
public String simple_value = "Should be overridden!";
public String fieldKey;
public String classFieldKey = "Foo";
public String fullKey;
public String test2 = "This is not set.";
}
public class AnnotatedBean{
@Config(value = {"foo.bar.myprop", "mp"}, defaultValue = "ET")
private String simpleValue;
@Config
String anotherValue;
}
20. Configuration beyond Java EE 828.03.2017
20
Accessing Config: CDI
public class AnnotatedBean{
@Inject
@Config(value = {"foo.bar.myprop", "mp"}, defaultValue = "ET")
private String simpleValue;
@Inject @Config
String anotherValue;
}
21. Configuration beyond Java EE 828.03.2017
21
Accessing Config: CDI
public class AnnotatedBean{
@Inject
@ConfigProperty(name = "foo.bar.myprop", defaultValue = "ET")
private String simpleValue;
@Inject @ConfigProperty(name = "foo.bar.myprop")
String anotherValue;
}
25. Configuration beyond Java EE 828.03.2017
Backend Model: PropertySource
25
●
Add dependency
org.apache.tamaya:core: 0.2-incubating
●
Add Config to META-INF/javaconfiguration.properties
●
GO!
public interface PropertySource {
PropertyValue get(String key);
Map<String, PropertyValue> getProperties();
int getOrdinal();
String getName();
boolean isScannable();
}
26. Configuration beyond Java EE 828.03.2017
Backend Model: PropertyValue
26
●
Add dependency
org.apache.tamaya:core: 0.2-incubating
●
Add Config to META-INF/javaconfiguration.properties
●
GO!
public final class PropertyValue{
public String getKey();
public String getValue();
public String get(String key);
public Map<String,String> getMetaEntries();
...
}
31. Configuration beyond Java EE 828.03.2017 31
●
Just Java 7 or higher !
What I need to run Tamaya ?
Configuration Cluster
Java EE
Tamaya
Java SE
Tamaya
Tamaya
Vertx.io
Tamaya
TomEE
Tamaya
Spring
Tamaya
OSGI
33. Configuration beyond Java EE 828.03.2017
Apache Tamaya in 120 seconds...
33
1.Configuration = ordered list of
PropertySources
2.Properties found are combined using a
CombinationPolicy
3.Raw properties are filtered by PropertyFilter
4.For typed access PropertyConverters
have to do work
5.Extensions add more features
(discussed later)
6.Component Lifecycle is controlled by the
ServiceContextManager
ConfigurationContext
PropertyFilters
PropertySource
PropertySource
PropertySource
PropertySource
Configuration
CombinationPolicy
PropertyProviders
<provides>
PropertyConverter
36. Configuration beyond Java EE 828.03.2017 36
●
Configuration is read from remote source, e.g.
●
Etcd cluster
●
Consul cluster
●
Any Web URL
●
...
Remote PropertySources
Service Location Layer
Configuration Cluster
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamayaetcd</artifactId>
<version>...</version>
</dependency>
38. Configuration beyond Java EE 828.03.2017 38
●
Configuration that configures configuration
●
E.g. at METAINF/tamayaconfig.xml
●
Allows easy and quick setup of your configuration environment
●
Allows dynamic enablement of property sources
●
...
Meta-Configuration DRAFT !
41. Configuration beyond Java EE 828.03.2017 41
Resource expressions…
public class MyProvider extends AbstractPathPropertySourceProvider{
public MyProvider(){
super(“classpath:/METAINF/config/**/*.properties“);
}
@Override
protected Collection<PropertySource> getPropertySources(URL url) {
// TODO map resource to property sources
return Collections.emptySet();
}
}
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamayaresources</artifactId>
<version>...</version>
</dependency>
42. Configuration beyond Java EE 828.03.2017
And more: a topic on its own!
42
●
Tamaya-spi-support: Some handy base classes to implement SPIs
●
Tamaya-functions: Functional extension points (e.g. remapping, scoping)
●
Tamaya-events: Detect and publish ConfigChangeEvents
●
Tamaya-optional: Minimal access layer with optional Tamaya support
●
Tamaya-filter: Thread local filtering
●
Tamaya-usagetracker: Tracking use and stats for configuration consumption
●
Tamaya-validation*: Configuration Documentation and Validation
●
Format Extensions: yaml, json, ini, … including formats-SPI
●
Integrations with Vertx, CDI, Spring, OSGI*, Camel, etcd, Consul
●
Tamaya-mutable-config: Writable ConfigChangeRequests
●
Tamaya-metamodel*: Configuration Meta-Model
●
Tamaya-collections*: Collection Support
●
Tamaya-resolver: Expression resolution, placeholders, dynamic values
●
Tamaya-resources: Ant styled resource resolution
•...
* experimental
45. Configuration beyond Java EE 828.03.2017
Summary
45
●
Work on config JSR for a EE 8 has been stopped by Oracle
●
Community work is done in Microprofile.io and ASF
●
Microprofile API is very minimal, but will evolve.
●
Apache Tamaya provides most features you will ever need and supports
all major runtimes.