| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Grails
Revision: 7257
Author: ait
Date: 27 Jul 2008 15:27:03
Changes:No need to maange metaClass manually in Groovy. Probably original code was transformed from Java to Groovy
Files:| ... | ...@@ -45,10 +45,9 @@ | |
| 45 | 45 | * Created: Jun 12, 2007 |
| 46 | 46 | * Time: 12:00:23 PM |
| 47 | 47 | */ |
| 48 | public class ClosureInvokingAction extends AbstractAction implements GroovyObject { | |
| 48 | public class ClosureInvokingAction extends AbstractAction { | |
| 49 | 49 | private Closure callable; |
| 50 | 50 | private static final Log LOG = LogFactory.getLog(ClosureInvokingAction.class); |
| 51 | private transient MetaClass metaClass; | |
| 52 | 51 | private static final String RESULT = "result"; |
| 53 | 52 | |
| 54 | 53 | def commandClasses |
| ... | ...@@ -58,7 +57,6 @@ | |
| 58 | 57 | |
| 59 | 58 | public ClosureInvokingAction(Closure callable) { |
| 60 | 59 | this.callable = callable; |
| 61 | this.metaClass = InvokerHelper.getMetaClass(this) | |
| 62 | 60 | this.commandClasses = callable.parameterTypes |
| 63 | 61 | this.noOfParams = commandClasses.size() |
| 64 | 62 | this.hasCommandObjects = noOfParams > 1 || (noOfParams == 1 && commandClasses[0] != Object.class && commandClasses[0] != RequestContext.class) |
| ... | ...@@ -167,13 +165,11 @@ | |
| 167 | 165 | } |
| 168 | 166 | |
| 169 | 167 | public Object invokeMethod(String name, args) { |
| 170 | if(metaClass instanceof ExpandoMetaClass) { | |
| 171 | def emc = metaClass | |
| 168 | def emc = metaClass | |
| 169 | if(emc instanceof ExpandoMetaClass) { | |
| 172 | 170 | MetaMethod metaMethod = emc.getMetaMethod(name, args) |
| 173 | if(metaMethod) return metaMethod.invoke(this, args) | |
| 174 | else { | |
| 175 | return invokeMethodAsEvent(name, args) | |
| 176 | } | |
| 171 | if(metaMethod) | |
| 172 | return metaMethod.invoke(this, args) | |
| 177 | 173 | } |
| 178 | 174 | return invokeMethodAsEvent(name, args) |
| 179 | 175 | } |
| ... | ...@@ -189,20 +185,4 @@ | |
| 189 | 185 | return result(name,name, args) |
| 190 | 186 | } |
| 191 | 187 | } |
| 192 | ||
| 193 | public Object getProperty(String property) { | |
| 194 | return metaClass.getProperty(this, property) | |
| 195 | } | |
| 196 | ||
| 197 | public void setProperty(String property, Object newValue) { | |
| 198 | metaClass.setProperty(this, property, newValue) | |
| 199 | } | |
| 200 | ||
| 201 | public MetaClass getMetaClass() { | |
| 202 | return metaClass | |
| 203 | } | |
| 204 | ||
| 205 | public void setMetaClass(MetaClass metaClass) { | |
| 206 | this.metaClass = metaClass | |
| 207 | } | |
| 208 | 188 | } |