1 28 29 package com.idaremedia.antx.construct; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 import org.apache.tools.ant.UnknownElement; 34 35 import com.idaremedia.antx.AntX; 36 import com.idaremedia.antx.AssertableTask; 37 import com.idaremedia.antx.FixtureExaminer; 38 import com.idaremedia.antx.apis.Requester; 39 import com.idaremedia.antx.ownhelpers.TaskExaminer; 40 import com.idaremedia.antx.ownhelpers.UEContainerProxy; 41 42 66 67 public final class PerformTaskTask extends AssertableTask 68 { 69 72 public PerformTaskTask() 73 { 74 super(AntX.utilities+"PerformTaskTask:"); 75 } 76 77 78 79 84 public void setName(String refId) 85 { 86 require_(refId!=null,"setName- nonzro refid"); 87 m_itemUC = (UEContainerProxy)FixtureExaminer.getReferencedObject(getProject(), 88 new Requester.ForComponent(this), refId, UEContainerProxy.class); 89 m_itemUCRefId = refId; 90 } 91 92 93 94 100 public void setKeep(boolean keepIt) 101 { 102 m_purgeRefId = !keepIt; 103 } 104 105 106 107 113 public void execute() 114 { 115 verifyCanExecute_("exec"); 116 117 if (m_purgeRefId) { 118 getProject().getReferences().remove(m_itemUCRefId); 119 m_itemUCRefId = null; 120 } 121 UnknownElement ue = m_itemUC.getUE(); 122 if (!m_purgeRefId) { 123 ue = TaskExaminer.copyUEProxy(ue,getProject(),null); 124 } 125 ue.setLocation(getLocation()); 126 ue.perform(); 127 m_itemUC = null; 128 } 129 130 131 132 135 protected void verifyCanExecute_(String calr) 136 { 137 verifyInProject_(calr); 138 139 if (m_itemUC==null) { 140 String ermsg = uistrs().get("task.needs.name", getTaskName()); 141 log(ermsg,Project.MSG_ERR); 142 throw new BuildException(ermsg,getLocation()); 143 } 144 } 145 146 147 private UEContainerProxy m_itemUC; private String m_itemUCRefId; 149 private boolean m_purgeRefId=true;} 151 152 | Popular Tags |