tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [04/11] incubator-tamaya-extensions git commit: Added features module.
Date Sun, 26 Feb 2017 23:05:17 GMT
Added features module.


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

Branch: refs/heads/master
Commit: e71203c9da8759da5162f1d2519ec96e16bce7ca
Parents: 9465845
Author: anatole <anatole@apache.org>
Authored: Tue Feb 14 23:54:28 2017 +0100
Committer: anatole <anatole@apache.org>
Committed: Mon Feb 27 00:05:00 2017 +0100

----------------------------------------------------------------------
 modules/features/bnd.bnd                        |   2 +
 modules/features/pom.xml                        |  62 +++++++
 .../org/apache/tamaya/features/Features.java    | 177 +++++++++++++++++++
 .../apache/tamaya/features/package-info.java    |   4 +
 4 files changed, 245 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/features/bnd.bnd b/modules/features/bnd.bnd
new file mode 100644
index 0000000..e0d0b58
--- /dev/null
+++ b/modules/features/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+	org.apache.tamaya.features
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/pom.xml
----------------------------------------------------------------------
diff --git a/modules/features/pom.xml b/modules/features/pom.xml
new file mode 100644
index 0000000..4bc274b
--- /dev/null
+++ b/modules/features/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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 current 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.tamaya.ext</groupId>
+        <artifactId>tamaya-extensions</artifactId>
+        <version>0.3-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tamaya-features</artifactId>
+    <name>Apache Tamaya Feature Check</name>
+    <packaging>jar</packaging>
+
+    <properties>
+        <jdkVersion>1.7</jdkVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tamaya</groupId>
+            <artifactId>tamaya-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>java-hamcrest</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/src/main/java/org/apache/tamaya/features/Features.java
----------------------------------------------------------------------
diff --git a/modules/features/src/main/java/org/apache/tamaya/features/Features.java b/modules/features/src/main/java/org/apache/tamaya/features/Features.java
new file mode 100644
index 0000000..6abb6c5
--- /dev/null
+++ b/modules/features/src/main/java/org/apache/tamaya/features/Features.java
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+package org.apache.tamaya.features;
+
+import javax.naming.InitialContext;
+import java.util.Objects;
+
+/**
+ * Simple Features singleton to check, which Tamaya modules are currently available.
+ */
+public final class Features {
+
+    /** Private singleton constructor. */
+    private Features(){}
+
+    /**
+     * Checks if <i>tamaya-events</i> is on the classpath.
+     * @return true, if <i>tamaya-events</i> is on the classpath.
+     */
+    public static boolean eventsAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.events.ConfigEventManager");
+    }
+
+    /**
+     * Checks if <i>tamaya-formats</i> is on the classpath.
+     * @return true, if <i>tamaya-formats</i> is on the classpath.
+     */
+    public static boolean formatsAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.format.ConfigurationFormats");
+    }
+
+    /**
+     * Checks if <i>tamaya-core</i> is on the classpath.
+     * @return true, if <i>tamaya-core</i> is on the classpath.
+     */
+    public static boolean tamayaCoreAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.core.internal.DefaultConfigurationProvider");
+    }
+
+    /**
+     * Checks if <i>tamaya-injection</i> is on the classpath.
+     * @return true, if <i>tamaya-injection</i> is on the classpath.
+     */
+    public static boolean injectionAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.inject.ConfigurationInjector");
+    }
+
+    /**
+     * Checks if <i>tamaya-injection-cdi</i> or <i>tamaya-injection-ee</i>
is on the classpath.
+     * @return true, if <i>tamaya-injection-cdi</i> or <i>tamaya-injection-ee</i>
is on the classpath.
+     */
+    public static boolean injectionCDIAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.integration.cdi.TamayaCDIIntegration");
+    }
+
+    /**
+     * Checks if <i>tamaya-mutableconfig</i> is on the classpath.
+     * @return true, if <i>tamaya-mutableconfig</i> is on the classpath.
+     */
+    public static boolean mutableConfigAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.mutableconfig.MutableConfigProvider");
+    }
+
+    /**
+     * Checks if <i>tamaya-optional</i> is on the classpath.
+     * @return true, if <i>tamaya-optional</i> is on the classpath.
+     */
+    public static boolean optionalAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.optional.OptionalConfiguration");
+    }
+
+    /**
+     * Checks if <i>tamaya-resolver</i> is on the classpath.
+     * @return true, if <i>tamaya-resolver</i> is on the classpath.
+     */
+    public static boolean resolverAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.resolver.ResourceResolver");
+    }
+
+    /**
+     * Checks if <i>tamaya-resources</i> is on the classpath.
+     * @return true, if <i>tamaya-respurces</i> is on the classpath.
+     */
+    public static boolean resourcesAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.resource.ConfigResources");
+    }
+
+    /**
+     * Checks if <i>tamaya-spisupport</i> is on the classpath.
+     * @return true, if <i>tamaya-spisupport</i> is on the classpath.
+     */
+    public static boolean spiSupportAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.spisupport.PropertySourceComparator");
+    }
+
+    /**
+     * Checks if <i>tamaya-filter</i> is on the classpath.
+     * @return true, if <i>tamaya-filter</i> is on the classpath.
+     */
+    public static boolean filterSupportAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.filter.ConfigurationFilter");
+    }
+
+    /**
+     * Checks if <i>tamaya-spring</i> is on the classpath.
+     * @return true, if <i>tamaya-spring</i> is on the classpath.
+     */
+    public static boolean springAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.integration.spring.TamayaEnvironment");
+    }
+
+    /**
+     * Checks if <i>tamaya-jndi</i> is on the classpath.
+     * @return true, if <i>tamaya-jndi</i> is on the classpath.
+     */
+    public static boolean jndiAvailable() {
+        return checkClassIsLoadable("org.apache.tamaya.jndi.JNDIPropertySource");
+    }
+
+    /**
+     * Checks if <i>spring-core</i> is on the classpath.
+     * @return true, if <i>spring-core</i> is on the classpath.
+     */
+    public static boolean extSpringCoreAvailable() {
+        return checkClassIsLoadable("org.springframework.core.env.Environment");
+    }
+
+    /**
+     * Checks if <i>OSGIe</i> is on the classpath.
+     * @return true, if <i>OSGI</i> is on the classpath.
+     */
+    public static boolean extOSGIAvailable() {
+        return checkClassIsLoadable("org.osgi.framework.BundleContext");
+    }
+
+    /**
+     * Checks if JNDI is working.
+     * @return true, if JNDI is working.
+     */
+    public static boolean extJndiAvailable() {
+        try{
+            new InitialContext();
+            return true;
+        }catch(Exception e){
+            return false;
+        }
+    }
+
+    /**
+     * Checks if the given class canm be loaded, using {@code Class.forName(classname)}.
+     * @return true, if the given class canm be loaded.
+     */
+    public static boolean checkClassIsLoadable(String classname) {
+        try{
+            Class.forName(Objects.requireNonNull(classname));
+            return true;
+        }catch(Exception e){
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/e71203c9/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
----------------------------------------------------------------------
diff --git a/modules/features/src/main/java/org/apache/tamaya/features/package-info.java b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
new file mode 100644
index 0000000..eeb00e5
--- /dev/null
+++ b/modules/features/src/main/java/org/apache/tamaya/features/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Tamaya Feature Module.
+ */
+package org.apache.tamaya.features;
\ No newline at end of file


Mime
View raw message