[jboss-cvs] JBossAS SVN: r82346 - projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 17 11:31:59 EST 2008
Author: alesj
Date: 2008-12-17 11:31:59 -0500 (Wed, 17 Dec 2008)
New Revision: 82346
Modified:
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/BaseAttachmentVDFConnector.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/NamedAttachmentVDFConnector.java
projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/WebBeanDiscoveryEnvVDFConnector.java
Log:
Allow hierarchy lookup.
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/BaseAttachmentVDFConnector.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/BaseAttachmentVDFConnector.java 2008-12-17 15:29:18 UTC (rev 82345)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/BaseAttachmentVDFConnector.java 2008-12-17 16:31:59 UTC (rev 82346)
@@ -34,6 +34,8 @@
*/
public abstract class BaseAttachmentVDFConnector<U> extends AttachmentVDFConnector<U>
{
+ private boolean allowHierarchyLookup;
+
protected BaseAttachmentVDFConnector(ServletContext servletContext)
{
super(servletContext);
@@ -48,6 +50,37 @@
protected U getUtilityFromAttribute(DeploymentUnit unit)
{
+ U utility = lookup(unit);
+ if (utility == null && allowHierarchyLookup)
+ {
+ DeploymentUnit parent = unit.getParent();
+ while(parent != null && utility == null)
+ {
+ utility = lookup(parent);
+ parent = parent.getParent();
+ }
+ }
+ return utility;
+ }
+
+ /**
+ * Do attachment lookup.
+ *
+ * @param unit the deployment unit
+ * @return the lookup result
+ */
+ protected U lookup(DeploymentUnit unit)
+ {
return unit.getAttachment(getAttachmentType());
}
+
+ /**
+ * Do we allow to do hierarchy attachment lookup on deployment unit.
+ *
+ * @param allowHierarchyLookup the allow hierarchy lookup flag
+ */
+ public void setAllowHierarchyLookup(boolean allowHierarchyLookup)
+ {
+ this.allowHierarchyLookup = allowHierarchyLookup;
+ }
}
\ No newline at end of file
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/NamedAttachmentVDFConnector.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/NamedAttachmentVDFConnector.java 2008-12-17 15:29:18 UTC (rev 82345)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/NamedAttachmentVDFConnector.java 2008-12-17 16:31:59 UTC (rev 82346)
@@ -45,7 +45,7 @@
*/
protected abstract String getAttchmentName();
- protected U getUtilityFromAttribute(DeploymentUnit unit)
+ protected U lookup(DeploymentUnit unit)
{
return unit.getAttachment(getAttchmentName(), getAttachmentType());
}
Modified: projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/WebBeanDiscoveryEnvVDFConnector.java
===================================================================
--- projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/WebBeanDiscoveryEnvVDFConnector.java 2008-12-17 15:29:18 UTC (rev 82345)
+++ projects/webbeans-ri-int/trunk/jbossas/src/main/java/org/jboss/webbeans/integration/jbossas/vdf/WebBeanDiscoveryEnvVDFConnector.java 2008-12-17 16:31:59 UTC (rev 82346)
@@ -35,6 +35,7 @@
public WebBeanDiscoveryEnvVDFConnector(ServletContext servletContext)
{
super(servletContext);
+ setAllowHierarchyLookup(true);
}
protected Class<WebBeanDiscoveryEnvironment> getAttachmentType()
More information about the jboss-cvs-commits
mailing list