You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2012/06/13 23:36:09 UTC

[3/5] git commit: DELTASPIKE-196 move BaseConfigPropertyProducer to spi

DELTASPIKE-196 move BaseConfigPropertyProducer to spi

and make it abstract.


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

Branch: refs/heads/master
Commit: f2e29a272a05303b7822411f214822264ea7cfc7
Parents: c0e0209
Author: Mark Struberg <st...@apache.org>
Authored: Wed Jun 13 18:54:47 2012 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Wed Jun 13 18:54:47 2012 +0200

----------------------------------------------------------------------
 .../api/config/BaseConfigPropertyProducer.java     |   87 --------------
 .../spi/config/BaseConfigPropertyProducer.java     |   88 +++++++++++++++
 .../core/impl/config/ConfigPropertyProducer.java   |    2 +-
 ...CustomConfigAnnotationWithMetaDataProducer.java |    2 +-
 4 files changed, 90 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/f2e29a27/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/BaseConfigPropertyProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/BaseConfigPropertyProducer.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/BaseConfigPropertyProducer.java
deleted file mode 100644
index 3b538d0..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/BaseConfigPropertyProducer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.deltaspike.core.api.config;
-
-import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.annotation.Annotation;
-
-import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
-
-/**
- * This contains the fundamental parts for implementing own
- * ConfigProperty producers.
- *
- * TODO: add documentation
- */
-public class BaseConfigPropertyProducer
-{
-
-    /**
-     * @return the configured value for the given InjectionPoint
-     */
-    protected String getStringPropertyValue(InjectionPoint injectionPoint)
-    {
-        ConfigProperty configProperty = extractConfigProperty(injectionPoint.getAnnotated());
-
-        if (configProperty == null)
-        {
-            throw new IllegalStateException("producer method called without @ConfigProperty being present!");
-        }
-
-        String configuredValue;
-        String defaultValue = configProperty.defaultValue();
-        if (ConfigProperty.NULL.equals(defaultValue))
-        {
-            // no special defaultValue has been configured
-            configuredValue = ConfigResolver.getPropertyValue(configProperty.name());
-        }
-        else
-        {
-            configuredValue = ConfigResolver.getPropertyValue(configProperty.name(), defaultValue);
-        }
-
-        return configuredValue;
-    }
-
-
-    /**
-     * Extract the ConfigProperty annotation from the given Annotated member.
-     */
-    protected ConfigProperty extractConfigProperty(Annotated annotated)
-    {
-        ConfigProperty configProperty = annotated.getAnnotation(ConfigProperty.class);
-
-        if (configProperty == null)
-        {
-            // scan for meta-annotation
-            for (Annotation annotation : annotated.getAnnotations())
-            {
-                configProperty = annotation.annotationType().getAnnotation(ConfigProperty.class);
-
-                if (configProperty != null)
-                {
-                    break;
-                }
-            }
-        }
-
-        return configProperty;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/f2e29a27/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
new file mode 100644
index 0000000..e3c588b
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
@@ -0,0 +1,88 @@
+/*
+ * 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.deltaspike.core.spi.config;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
+
+/**
+ * This contains the fundamental parts for implementing own
+ * ConfigProperty producers.
+ *
+ * TODO: add documentation
+ */
+public abstract class BaseConfigPropertyProducer
+{
+
+    /**
+     * @return the configured value for the given InjectionPoint
+     */
+    protected String getStringPropertyValue(InjectionPoint injectionPoint)
+    {
+        ConfigProperty configProperty = extractConfigProperty(injectionPoint.getAnnotated());
+
+        if (configProperty == null)
+        {
+            throw new IllegalStateException("producer method called without @ConfigProperty being present!");
+        }
+
+        String configuredValue;
+        String defaultValue = configProperty.defaultValue();
+        if (ConfigProperty.NULL.equals(defaultValue))
+        {
+            // no special defaultValue has been configured
+            configuredValue = ConfigResolver.getPropertyValue(configProperty.name());
+        }
+        else
+        {
+            configuredValue = ConfigResolver.getPropertyValue(configProperty.name(), defaultValue);
+        }
+
+        return configuredValue;
+    }
+
+
+    /**
+     * Extract the ConfigProperty annotation from the given Annotated member.
+     */
+    protected ConfigProperty extractConfigProperty(Annotated annotated)
+    {
+        ConfigProperty configProperty = annotated.getAnnotation(ConfigProperty.class);
+
+        if (configProperty == null)
+        {
+            // scan for meta-annotation
+            for (Annotation annotation : annotated.getAnnotations())
+            {
+                configProperty = annotation.annotationType().getAnnotation(ConfigProperty.class);
+
+                if (configProperty != null)
+                {
+                    break;
+                }
+            }
+        }
+
+        return configProperty;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/f2e29a27/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigPropertyProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigPropertyProducer.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigPropertyProducer.java
index 200957a..3861884 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigPropertyProducer.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigPropertyProducer.java
@@ -23,7 +23,7 @@ import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.InjectionPoint;
 
-import org.apache.deltaspike.core.api.config.BaseConfigPropertyProducer;
+import org.apache.deltaspike.core.spi.config.BaseConfigPropertyProducer;
 import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/f2e29a27/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/CustomConfigAnnotationWithMetaDataProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/CustomConfigAnnotationWithMetaDataProducer.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/CustomConfigAnnotationWithMetaDataProducer.java
index a9429de..35c7959 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/CustomConfigAnnotationWithMetaDataProducer.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/CustomConfigAnnotationWithMetaDataProducer.java
@@ -5,7 +5,7 @@ import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.InjectionPoint;
 
-import org.apache.deltaspike.core.api.config.BaseConfigPropertyProducer;
+import org.apache.deltaspike.core.spi.config.BaseConfigPropertyProducer;
 
 /**
  * Sample producer for {@link CustomConfigAnnotationWithMetaData}