tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya git commit: Added CDI support module.
Date Sun, 27 Sep 2015 22:14:22 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master d6e48286c -> d8c56f8aa


Added CDI support module.


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

Branch: refs/heads/master
Commit: d8c56f8aa0bac09af824693f6aaa5a09e4892fb3
Parents: d6e4828
Author: anatole <anatole@apache.org>
Authored: Mon Sep 28 00:14:13 2015 +0200
Committer: anatole <anatole@apache.org>
Committed: Mon Sep 28 00:14:13 2015 +0200

----------------------------------------------------------------------
 docs/src/main/asciidoc/mod_cdi.adoc | 159 +++++++++++++++++++++++++++++++
 docs/src/main/asciidoc/modules.adoc |   1 +
 2 files changed, 160 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d8c56f8a/docs/src/main/asciidoc/mod_cdi.adoc
----------------------------------------------------------------------
diff --git a/docs/src/main/asciidoc/mod_cdi.adoc b/docs/src/main/asciidoc/mod_cdi.adoc
new file mode 100644
index 0000000..b0c5074
--- /dev/null
+++ b/docs/src/main/asciidoc/mod_cdi.adoc
@@ -0,0 +1,159 @@
+= Apache Tamaya -- Extension: Classloader Isolation Support
+
+:name: Tamaya
+:rootpackage: org.apache.tamaya.integration.cdi
+:title: Apache Tamaya Extension: CDI Integration
+:revdate: September 2015
+:authorinitials: ATR
+:author: Anatole Tresch
+:email: <anatole@apache.org>
+:source-highlighter: coderay
+:website: http://tamaya.incubator.apache.org/
+:toc:
+:toc-placement: manual
+:encoding: UTF-8
+:numbered:
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+'''
+
+<<<
+
+toc::[]
+
+<<<
+:numbered!:
+<<<
+[[Remote]]
+== Tamaya CDI Integration (Extension Module)
+=== Overview
+
+The Tamaya CDI Integration provides CDI extensions implementing the following functionality:
+
+* Configuration of classes to be vetoed based on regular expressions of the fully qualified
classnames.
+* Loading of CDI managed components as configuration extensions such as +PropertySources,
PropertySourceProvieders,
+  PropertyFilters, etc+.
+
+
+=== Compatibility
+
+The module is based on Java 7, so it will not run on Java 7 and beyond.
+
+
+=== Installation
+
+To benefit from Tamaya CDI integration you only must add the corresponding dependency to
your module:
+
+[source, xml]
+-----------------------------------------------
+<dependency>
+  <groupId>org.apache.tamaya.ext</groupId>
+  <artifactId>tamaya-cdi</artifactId>
+  <version>{tamayaVersion}</version>
+</dependency>
+-----------------------------------------------
+
+The component will auto-register its components and override the default +ServicceContext+
in use. Additionally it
+registers CDI extensions that implement Configuration injection based on Tamaya's +tamaya-injection+
and
++tamaya-classloader-support+ modules.
+
+=== How it Works
+
+This module registers as +ServiceContext+ and integrates CDI for component loading as well
as configuration injection.
+All types injected by this module are injected using _dependent scope_. So with this module
you can define/deploy
+your +PropertySources+ and other artifacts simply by adding corresponding CDI managed beans:
+
+[source, java]
+--------------------------------------------------------
+@Singleton
+public class TestPropertySource implements PropertySource{
+
+    final Map<String,String> config = new HashMap<>();
+
+    public TestPropertySource(){
+        config.put("a.b.c.key1", "keys current a.b.c.key1");
+        config.put("a.b.c.key2", "keys current a.b.c.key2");
+        config.put("{"+getName()+"}source", getClass().getName());
+    }
+
+    @Override
+    public int getOrdinal() {
+        return 10;
+    }
+
+    @Override
+    public String getName() {
+        return getClass().getName();
+    }
+
+    @Override
+    public String get(String key) {
+        return config.get(key);
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        return config;
+    }
+
+    @Override
+    public boolean isScannable() {
+        return true;
+    }
+}
+--------------------------------------------------------
+
+The +ServiceContext+ implementation hereby combines the components registered using the +ServiceLoader+
mechanism
+hereby considering classloaser hierarchies.
+
+
+=== Injecting Configuration
+
+This component also allows to inject configuration using Tamaya's type-safe injection mechanism:
+
+[source, java]
+--------------------------------------------------------
+@RequestScoped
+public class ConfiguredClass{
+
+    @ConfiguredProperty
+    private String testProperty;
+
+    @ConfiguredProperty(keys = {"a.b.c.key1","a.b.c.key2","a.b.c.key3"})
+    @DefaultValue("The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.")
+    String value1;
+
+    @ConfiguredProperty(keys = {"foo","a.b.c.key2"})
+    private String value2;
+
+    @ConfiguredProperty
+    @DefaultValue("N/A")
+    private String runtimeVersion;
+
+    @ConfiguredProperty
+    @DefaultValue("${sys:java.version}")
+    private String javaVersion2;
+
+    @ConfiguredProperty
+    @DefaultValue("5")
+    private Integer int1;
+
+    ...
+
+}
+--------------------------------------------------------
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d8c56f8a/docs/src/main/asciidoc/modules.adoc
----------------------------------------------------------------------
diff --git a/docs/src/main/asciidoc/modules.adoc b/docs/src/main/asciidoc/modules.adoc
index 71ae98c..7d9486c 100644
--- a/docs/src/main/asciidoc/modules.adoc
+++ b/docs/src/main/asciidoc/modules.adoc
@@ -69,6 +69,7 @@ NOTE All extensions, despite the _tamaya-builder_ module, currently run
on Java
 |+org.apache.tamaya.ext:tamaya-server+        |Lets a Tamaya configuration instance provide
scoped configuration as a http service.     |link:mod_server.html[Documentation]
 |+org.apache.tamaya.ext:tamaya-optional+      |Lets a Tamaya configuration to be used as
an optional project extension only.  |link:mod_optional.html[Documentation]
 |+org.apache.tamaya.ext:tamaya-classloader-support+      |Manages Tamaya configuration and
services considering classloading hierarchies.  |link:mod_classloader_support.html[Documentation]
+|+org.apache.tamaya.ext:tamaya-cdi+           |Tamaya integration module for CDI.       
              |link:mod_cdi.html[Documentation]
 |=======
 
 


Mime
View raw message