[webbeans-commits] Webbeans SVN: r3702 - ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Sep 17 16:47:40 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-09-17 16:47:40 -0400 (Thu, 17 Sep 2009)
New Revision: 3702
Added:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ClassBeanDeploymentItem.java
Log:
Add to DeploymentItem hierarchy
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ClassBeanDeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ClassBeanDeploymentItem.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/ClassBeanDeploymentItem.java 2009-09-17 20:47:40 UTC (rev 3702)
@@ -0,0 +1,102 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.builder.sorter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ClassBeanDeploymentItem<T> extends DeploymentItem<T>
+{
+ private boolean initialized;
+
+ private final Sorter sorter;
+
+ private List<ClassBeanDeploymentItem<?>> dependencies = Collections.emptyList();
+
+ ClassBeanDeploymentItem(Sorter sorter, WBClass<T> clazz)
+ {
+ super(clazz);
+ this.sorter = sorter;
+ }
+
+ abstract ClassBeanDeploymentItem<? super T> getSuperClassDependency();
+
+ void initialize()
+ {
+ if (!initialized)
+ {
+ if (isSpecializing())
+ {
+ addDependency(getSuperClassDependency());
+ }
+ else
+ {
+ Set<WBMethod<?, ?>> producerMethods = getWBClass().getDeclaredWBAnnotatedMethods(Produces.class);
+ if (!producerMethods.isEmpty())
+ {
+ for (WBMethod<?, ?> producerMethod : producerMethods)
+ {
+ if (producerMethod.getAnnotation(Specializes.class) != null)
+ {
+ addDependency(getSuperClassDependency());
+ break;
+ }
+ }
+ }
+ }
+
+ initialized = true;
+ }
+ }
+
+ void addDependency(ClassBeanDeploymentItem<?> dependency)
+ {
+ if (dependencies == Collections.EMPTY_LIST)
+ dependencies = new ArrayList<ClassBeanDeploymentItem<?>>();
+
+ dependencies.add(dependency);
+ }
+
+ List<ClassBeanDeploymentItem<?>> getDependencies()
+ {
+ initialize();
+ return dependencies;
+ }
+
+ ClassBeanDeploymentItem<? super T> findDeploymentItem(WBClass<?> clazz)
+ {
+ return sorter.findDeploymentItem(clazz);
+ }
+}
More information about the weld-commits
mailing list