ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1352106 - /ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
Date Wed, 20 Jun 2012 14:00:37 GMT
Author: hibou
Date: Wed Jun 20 14:00:37 2012
New Revision: 1352106

URL: http://svn.apache.org/viewvc?rev=1352106&view=rev
Log:
fix condition instanciation

Modified:
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java

Modified: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java?rev=1352106&r1=1352105&r2=1352106&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
(original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
Wed Jun 20 14:00:37 2012
@@ -36,6 +36,7 @@ import org.apache.tools.ant.BuildExcepti
 import org.apache.tools.ant.ExtensionPoint;
 import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
 import org.apache.tools.ant.ProjectHelper;
 import org.apache.tools.ant.RuntimeConfigurable;
 import org.apache.tools.ant.Target;
@@ -433,18 +434,36 @@ public abstract class AbstractAntDslProj
         return element;
     }
 
-    @SuppressWarnings("unchecked")
     public <T> T mapExpectedUnknown(Project project, AntDslContext context, InnerElement
eInnerElement, Class<T> c) {
         if (eInnerElement == null) {
             return null;
         }
-        UnknownElement element = mapUnknown(project, context, eInnerElement, false);
-        element.maybeConfigure();
-        Object real = element.getRealThing();
-        if (!(c.isAssignableFrom(real.getClass()))) {
-            throw new BuildException("Incorrect condition: expecting a " + c.getSimpleName()
+ " but was : " + real.getClass().getName());
+
+        UnknownElement element = new UnknownElement("projectComponentContainer");
+        element.setProject(project);
+        RuntimeConfigurable wrapper = new RuntimeConfigurable(element, element.getTaskName());
+        context.pushWrapper(wrapper);
+        UnknownElement child = mapUnknown(project, context, eInnerElement, false);
+        element.addChild(child);
+        context.popWrapper();
+
+        ProjectComponentContainer container = new ProjectComponentContainer();
+        element.configure(container);
+        if (!(c.isAssignableFrom(container.component.getClass()))) {
+            throw new BuildException("Incorrect element: expecting a " + c.getSimpleName()
+ " but was : "
+                    + container.component.getClass().getName());
+        }
+        @SuppressWarnings("unchecked")
+        T expected = (T) container.component;
+        return expected;
+    }
+
+    public static class ProjectComponentContainer {
+        ProjectComponent component;
+
+        public void add(ProjectComponent component) {
+            this.component = component;
         }
-        return (T) real;
     }
 
     public static class InnerElement {



Mime
View raw message