tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From radcor...@apache.org
Subject [3/5] tomee git commit: Update README.md
Date Tue, 11 Dec 2018 00:32:08 GMT
Update README.md


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/61008108
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/61008108
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/61008108

Branch: refs/heads/master
Commit: 6100810883929db6023903e4afbdf9ec90cbfd6a
Parents: 0febf05
Author: Daniel Cunha (soro) <danielsoro@apache.org>
Authored: Fri Dec 7 15:58:18 2018 -0300
Committer: Roberto Cortez <radcortez@yahoo.com>
Committed: Tue Dec 11 00:31:53 2018 +0000

----------------------------------------------------------------------
 examples/mp-config-example/README.md | 46 +++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/61008108/examples/mp-config-example/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-config-example/README.md b/examples/mp-config-example/README.md
index e69de29..b7bccc9 100644
--- a/examples/mp-config-example/README.md
+++ b/examples/mp-config-example/README.md
@@ -0,0 +1,46 @@
+# Microprofile Config
+This is an example on how to use microprofile config in TomEE.
+
+##### Run the application:
+
+    mvn clean install tomee:run 
+
+Within the application there is an three way to inject values using config
+
+##### For the ConfigProperty with default value call:
+
+    GET http://localhost:8080/mp-config-example/sample/defaultProperty
+    
+##### For the get property inject with ConfigProperty call:
+    
+     GET http://localhost:8080/mp-config-example/sample/injectedJavaVersion
+     
+##### For the get property from Config with getValue call:
+    
+     GET http://localhost:8080/mp-config-example/sample/javaVersion
+
+##### Config Feature
+
+MicroProfile Config is a solution to externalise configuration from microservices. 
+Each individual property can be injected directly
+
+     @Inject
+     @ConfigProperty(name = "java.runtime.version")
+     private String javaVersion;
+     
+You can also set a default value for it, case the config does not match the property in the
context it will use the default value
+
+    @Inject
+    @ConfigProperty(name = "defaultProperty", defaultValue = "ALOHA")
+    private String defaultProperty;
+    
+The config object can also be injected. Then use the getValue() method to retrieve the individual
property.
+    
+    @Inject
+    private Config config;
+    
+    @GET
+    @Path("javaVersion")
+    public String getJavaVersionPropertyFromSystemProperties() {
+        return config.getValue("java.runtime.version", String.class);
+    }
\ No newline at end of file


Mime
View raw message