001: /*
002: * Created on May 12, 2004
003: *
004: * To change the template for this generated file go to
005: * Window>Preferences>Java>Code Generation>Code and Comments
006: */
007: package org.xdev.base.xssl.reflection;
008:
009: import java.util.ArrayList;
010: import java.util.HashMap;
011: import java.util.List;
012:
013: import org.xdev.base.xssl.XSSLAction;
014: import org.xdev.base.xssl.XSSLActionIterator;
015:
016: import java.lang.reflect.*;
017:
018: /**
019: * @author AYegorov
020: *
021: * Company: xDev Group.org
022: *
023: * URL: <a>http://activexml.dev.java.net</a>
024: *
025: * File name: VirtualMethod.java
026: *
027: * <p>Is bound: true | false</p>
028: *
029: * <table>
030: * <tr>
031: * <td>Description:</td>
032: * <td>
033: * <!--Your description here-->
034: * </td>
035: * </tr>
036: * </table>
037: * <table>
038: * <tr>
039: * <td colspan="3">
040: * Properties
041: * </td>
042: * </tr>
043: * <tr>
044: * <td>Name</td>
045: * <td>Value</td>
046: * <td>Description</td>
047: * </tr>
048: * <tr>
049: * <td></td>
050: * <td></td>
051: * <td></td>
052: * </tr>
053: * </table>
054: */
055: public class VirtualMethod extends VirtualObject {
056:
057: /**
058: * @param id
059: */
060: public VirtualMethod(String id) {
061: super (id);
062: // XXX Auto-generated constructor stub
063: }
064:
065: /**
066: * @param id
067: * @param properties
068: */
069: public VirtualMethod(String id, HashMap properties) {
070: super (id, properties);
071: // XXX Auto-generated constructor stub
072: }
073:
074: /* (non-Javadoc)
075: * @see org.xdev.base.xssl.reflection.AbstractVirtual#reflect(java.lang.Class, java.lang.Class[], java.lang.Object[])
076: */
077: protected Object reflect(Class cls, Class[] parameterClasses,
078: Object[] parameterObjects) throws Exception {
079: Object obj = this .getEvaluatedReference();
080:
081: String referenceId = this .getReferenceId();
082:
083: if (obj != null) {
084: cls = obj.getClass();
085: } else if (cls != null && !"".equals(referenceId)) {
086:
087: List params = this .getTokenListProperty("class-params");
088:
089: Class[] paramClasses = null;
090:
091: Object[] paramObjects = null;
092:
093: if (params != null) {
094:
095: int sz = params.size();
096:
097: Object object = null;
098:
099: paramClasses = new Class[sz];
100:
101: paramObjects = new Object[sz];
102:
103: for (int i = 0; i < sz; i++) {
104: object = this .getPropertyAsObject((String) params
105: .get(i));
106:
107: paramClasses[i] = obj.getClass();
108:
109: paramObjects[i] = obj;
110: }
111: }
112:
113: obj = super .reflect(cls, paramClasses, paramObjects);
114:
115: this .setReference(referenceId, obj);
116: }
117:
118: Method m = (Method) this
119: .resolveSignature(cls, parameterClasses);
120:
121: return m.invoke(obj, parameterObjects);
122: }
123:
124: protected Object returnSignedObject(Class cls, Class[] variation)
125: throws Exception {
126: return cls.getMethod(this .getProperty("method"), variation);
127: }
128:
129: }
|