2 * Copyright 2004-2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.codehaus
.groovy
.grails
.commons
.metaclass
;
18 * An interface that defines methods for a handling dynamic method, static method and property
21 * @author Graeme Rocher
24 * Created: Oct 27, 2005
26 public interface DynamicMethods
{
29 * Adds a dynamic constructor
31 * @param constructor The constructor to add
33 public void addDynamicConstructor(DynamicConstructor constructor
);
36 * Adds a new dynamic method invocation
37 * @param methodInvocation
39 public abstract void addDynamicMethodInvocation(
40 DynamicMethodInvocation methodInvocation
);
43 * Adds a new static method invocation
44 * @param methodInvocation
46 public abstract void addStaticMethodInvocation(
47 StaticMethodInvocation methodInvocation
);
50 * Adds a new dynamic property
53 public abstract void addDynamicProperty(DynamicProperty property
);
56 * Retrieves a dynamic property for the specified property name
57 * @param propertyName The name of the property
58 * @return A DynamicProperty instance of null if none exists
60 public abstract DynamicProperty
getDynamicProperty(String propertyName
);
63 * Retrieves a dynamic method for the specified method name
64 * @param method_signature Then signature of the method
65 * @return The method instance or null if non exists
67 public DynamicMethodInvocation
getDynamicMethod(String method_signature
);
70 * Attempts to get a dynamic property. If successful the InvocationCallback
71 * instance is marked as invoked
73 * @param object The instance
74 * @param propertyName The property name to get
75 * @param callback The callback object
77 * @return The property value if it exists
79 public abstract Object
getProperty(Object object
, String propertyName
,
80 InvocationCallback callback
);
84 * Attempts to set a dynamic property. If successful the InvocationCallback
85 * instance is marked as invoked
87 * @param object The instance
88 * @param propertyName The property name to set
89 * @param callback The callback object
91 public abstract void setProperty(Object object
, String propertyName
,
92 Object newValue
, InvocationCallback callback
);
95 * Attempts to invoke a dynamic method with the specified name and arguments
96 * If successful the callback object is marked as invoked.
98 * @param object The instance to invoke on
99 * @param methodName The name of the method
100 * @param arguments The arguments of the method
101 * @param callback The callback object
103 * @return The method return value
105 public abstract Object
invokeMethod(Object object
, String methodName
,
106 Object
[] arguments
, InvocationCallback callback
);
109 * Attempts to invoke a dynamic static method with the specified name and arguments
110 * If successful the callback object is marked as invoked.
112 * @param object The instance to invoke on
113 * @param methodName The name of the method
114 * @param arguments The arguments of the method
115 * @param callBack The callback object
117 * @return The method return value
119 public abstract Object
invokeStaticMethod(Object object
, String methodName
,
120 Object
[] arguments
, InvocationCallback callBack
);
123 * Attempts to invoke a dynamic constructor. If successful the callback object
124 * is marked as invoked.
126 * @param arguments The arguments
127 * @param callBack The callback object
129 * @return The constructed instance
131 public Object
invokeConstructor(Object
[] arguments
, InvocationCallback callBack
);