You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/06/07 14:11:52 UTC

git commit: DELTASPIKE-161 special handling of internal untyped beans

Updated Branches:
  refs/heads/master 30d16a497 -> a2e172d5b


DELTASPIKE-161 special handling of internal untyped beans


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

Branch: refs/heads/master
Commit: a2e172d5bd037618db58ce4bc887d972472c1917
Parents: 30d16a4
Author: gpetracek <gp...@apache.org>
Authored: Thu Jun 7 14:09:49 2012 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Thu Jun 7 14:09:49 2012 +0200

----------------------------------------------------------------------
 .../core/impl/exclude/InternalUntypedBean.java     |   28 +++++++++++++++
 .../impl/exclude/extension/ExcludeExtension.java   |   24 ++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/a2e172d5/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/InternalUntypedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/InternalUntypedBean.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/InternalUntypedBean.java
new file mode 100644
index 0000000..5849b39
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/InternalUntypedBean.java
@@ -0,0 +1,28 @@
+/*
+ * 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.impl.exclude;
+
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+
+/**
+ * Allows to deactivate the veto of internal beans annotated with @Typed()
+ */
+public interface InternalUntypedBean extends Deactivatable
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/a2e172d5/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/ExcludeExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/ExcludeExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/ExcludeExtension.java
index cb8a519..798801a 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/ExcludeExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/extension/ExcludeExtension.java
@@ -20,6 +20,7 @@ package org.apache.deltaspike.core.impl.exclude.extension;
 
 import org.apache.deltaspike.core.api.config.ConfigResolver;
 import org.apache.deltaspike.core.api.exclude.annotation.Exclude;
+import org.apache.deltaspike.core.impl.exclude.InternalUntypedBean;
 import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder;
 import org.apache.deltaspike.core.impl.exclude.CustomProjectStageBeanFilter;
 import org.apache.deltaspike.core.impl.exclude.GlobalAlternative;
@@ -33,11 +34,13 @@ import org.apache.deltaspike.core.util.ProjectStageProducer;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.util.Nonbinding;
+import javax.inject.Named;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -63,6 +66,7 @@ public class ExcludeExtension implements Extension, Deactivatable
     private Boolean isActivated = null;
     private Boolean isGlobalAlternativeActivated = null;
     private Boolean isCustomProjectStageBeanFilterActivated = null;
+    private Boolean isInternalUntypedBeanFilterActivated = null;
 
     /**
      * triggers initialization in any case
@@ -103,6 +107,11 @@ public class ExcludeExtension implements Extension, Deactivatable
             vetoCustomProjectStageBeans(processAnnotatedType);
         }
 
+        if (this.isInternalUntypedBeanFilterActivated)
+        {
+            vetoInternalUntypedBeans(processAnnotatedType);
+        }
+        
         if (!this.isActivated)
         {
             return;
@@ -148,6 +157,18 @@ public class ExcludeExtension implements Extension, Deactivatable
         }
     }
 
+    protected void vetoInternalUntypedBeans(ProcessAnnotatedType<Object> processAnnotatedType)
+    {
+        Class<?> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass();
+        Typed typed = beanClass.getAnnotation(Typed.class);
+
+        if (typed != null && typed.value().length == 0 && !beanClass.isAnnotationPresent(Named.class) &&
+            beanClass.getName().startsWith("org.apache.deltaspike."))
+        {
+            processAnnotatedType.veto();
+        }
+    }
+
     private void activateGlobalAlternativesWeld(ProcessAnnotatedType<Object> processAnnotatedType,
         BeanManager beanManager)
     {
@@ -520,6 +541,9 @@ public class ExcludeExtension implements Extension, Deactivatable
 
             isCustomProjectStageBeanFilterActivated =
                 ClassDeactivationUtils.isActivated(CustomProjectStageBeanFilter.class);
+            
+            isInternalUntypedBeanFilterActivated =
+                ClassDeactivationUtils.isActivated(InternalUntypedBean.class);
         }
     }