You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/05/04 09:54:47 UTC
svn commit: r1677545 - /incubator/tamaya/site/trunk/content/examples.mdtext
Author: anatole
Date: Mon May 4 07:54:47 2015
New Revision: 1677545
URL: http://svn.apache.org/r1677545
Log:
Enhanced examples file.
Modified:
incubator/tamaya/site/trunk/content/examples.mdtext
Modified: incubator/tamaya/site/trunk/content/examples.mdtext
URL: http://svn.apache.org/viewvc/incubator/tamaya/site/trunk/content/examples.mdtext?rev=1677545&r1=1677544&r2=1677545&view=diff
==============================================================================
--- incubator/tamaya/site/trunk/content/examples.mdtext (original)
+++ incubator/tamaya/site/trunk/content/examples.mdtext Mon May 4 07:54:47 2015
@@ -43,28 +43,41 @@ Hereby configuration is read by adding a
This example shows how to register additional property sources. Hereby both ways are shown:
-* Implementing and registering a single {{PropertySource}}
-* Implementing and registering a {{PropertySourceProvider}} that is able to register multiple {{PropertySource}s.
+* Implementing and registering a single _org.apache.tamaya.spi.PropertySource_
+* Implementing and registering a _org.apache.tamaya.spi.PropertySourceProvider_ that is able to register multiple
+ _PropertySources_.
# Resource Example
-This example shows how the _resource_ module helps you to describe your target file resources using a ant-styled
-descriptive syntax.
+This example shows how the _tamaya-resource_ module helps you to describe your target file resources using a ant-styled
+descriptive syntax:
+
+ public class MyPathPropertySourceProvider extends AbstractPathPropertySourceProvider {
+
+ public MyPathPropertySourceProvider(){
+ super("classpath:cfgOther/**/*.properties", "classpath:META-INF/MyOtherConfigProperties.*");
+ }
+
+ @Override
+ protected Collection<PropertySource> getPropertySources(URL url) {
+ return Arrays.asList(new PropertySource[]{new SimplePropertySource(url)});
+ }
+ }
# Resolver Example
-This example shows how the _resolver_ module enables the use of dynamic placeholders, e.g. as follows:
+This example shows how the _tamaya-resolver_ module enables the use of dynamic placeholders, e.g. as follows:
# Resolved entries
example.fullName=${conf:example.name}(${conf:example.type})
- example.fullVersion=${conf:example.fullName} - ${conf:example.version}, build ${resource:buildata
+ example.fullVersion=${conf:example.fullName} - ${conf:example.version}, build ${resource:buildata}
# Injection Example
-This example shows how the _injection_ module adds injection capabilities:
+This example shows how the _tamaya-injection_ module adds injection capabilities:
@ConfigRoot("example")
public class Example {
@@ -85,10 +98,24 @@ This example shows how the _injection_ m
}
The example illustrates both: injection into a class, as well as the creation of a configuration template.
-This example hereby does not use CDI or any other DI framework.
+This example hereby does not use CDI or any other DI framework:
+
+ Example example = new Example();
+ ConfigurationInjector.getInstance().configure(example);
+
+ ExampleTemplate template = ConfigurationInjector.getInstance().createTemplate(ExampleTemplate.class);
# FileObeserver Example
This example shows the possibility to observe changes on a configuration directory and dynamically update the
-configuration values, when changes were detected. It is based on the _events_ extension module.
+configuration values, when changes were detected. It is based on the _tamaya-events_ extension module.
+
+ public class ObservingConfigProvider extends ObservingPropertySourceProvider{
+
+ public ObservingConfigProvider(){
+ super(Paths.get("/data/domainconfig"), // observe /data/domainconfig directory
+ new PropertiesFormat()); // Support .properties as file format
+ }
+ }
+