Source Code Cross Referenced for XServiceModelNode.java in  » XML-UI » XUI » net » xoetrope » optional » service » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » XUI » net.xoetrope.optional.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.optional.service;
002:
003:        import java.util.Date;
004:
005:        import net.xoetrope.xui.data.XModel;
006:
007:        /**
008:         * Models a service as a model node. Getting the node value causes the service
009:         * to be invoked. The node attributes are used as the arguments for the service
010:         * call.
011:         * <p>Copyright: Copyright (c) Xoetrope Ltd. 2002-2003</p>
012:         * $Revision: 1.1 $
013:         */
014:        public class XServiceModelNode extends XModel {
015:            protected boolean dirty;
016:            protected long expires;
017:
018:            protected String serviceId;
019:            protected String fieldNames[];
020:            protected Object fieldValues[];
021:
022:            protected ServiceProxy callProxy;
023:
024:            public XServiceModelNode() {
025:                dirty = true;
026:            }
027:
028:            public void setupService(String methodName,
029:                    ServiceProxy routeService, String[] argNames) {
030:                serviceId = methodName;
031:                callProxy = routeService;
032:                fieldNames = argNames;
033:                if (argNames != null)
034:                    fieldValues = new String[argNames.length];
035:                dirty = true;
036:            }
037:
038:            /**
039:             * Get the service proxy that implements this service call
040:             * @return the service proxy
041:             */
042:            public ServiceProxy getServiceProxy() {
043:                return callProxy;
044:            }
045:
046:            /**
047:             * Get the service proxy that implements this service call
048:             * @return the service proxy
049:             */
050:            public ServiceProxy getServiceProxy(String reqdClass) {
051:                ServiceProxy target = callProxy;
052:                while (target != null) {
053:                    if (reqdClass.compareTo(target.getClass().getName()) != 0)
054:                        target = target.nextProxy;
055:                    else
056:                        return target;
057:                }
058:                return callProxy;
059:            }
060:
061:            public int hashCode() {
062:                return serviceId.hashCode();
063:            }
064:
065:            /**
066:             * Syncs the model with the service response is the request has been changed
067:             * or if the node has timed out.
068:             */
069:            protected void sync() {
070:                if (dirty || hasExpired()) {
071:                    get();
072:                    dirty = false;
073:                }
074:            }
075:
076:            public Object get() {
077:                try {
078:                    if (serviceId == null) {
079:                        return callProxy.call();
080:                    }
081:                    return callProxy.call(serviceId, fieldNames, fieldValues);
082:                } catch (ServiceProxyException ex) {
083:                    ex.printStackTrace();
084:                    return null;
085:                }
086:            }
087:
088:            public Object append(String id) {
089:                return null;
090:            }
091:
092:            public XModel get(int i) {
093:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
094:                throw new java.lang.UnsupportedOperationException(
095:                        "Method get() not yet implemented.");
096:            }
097:
098:            public void append(XModel newObject) {
099:                dirty = true;
100:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
101:            }
102:
103:            public void set(Object s) {
104:                dirty = true;
105:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
106:
107:                fireModelUpdated();
108:            }
109:
110:            public void set(String attribName, Object newObject) {
111:                dirty = true;
112:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
113:            }
114:
115:            public String getId() {
116:                return serviceId;
117:            }
118:
119:            /**
120:             * Get the name of an argument
121:             * @param i
122:             * @return the argument name
123:             */
124:            public String getAttribName(int i) {
125:                return fieldNames[i];
126:            }
127:
128:            /**
129:             * Look up an argument name
130:             * @param argName the argument name
131:             * @return the argument index or -1 if not found
132:             */
133:            public int getAttribute(String argName) {
134:                int numFields = fieldNames.length;
135:                for (int i = 0; i < numFields; i++) {
136:                    if (fieldNames[i].compareTo(argName) == 0)
137:                        return i;
138:                }
139:
140:                return -1;
141:            }
142:
143:            /**
144:             * Set the value of an argument
145:             * @param i the argument index
146:             * @param value the new argument value
147:             */
148:            public void setAttribValue(int i, Object value) {
149:                dirty = true;
150:                fieldValues[i] = value.toString();
151:            }
152:
153:            /**
154:             * Set the value of an argument
155:             * @param i the argument index
156:             * @param attribName the name of teh attribute
157:             * @param value the new argument value
158:             */
159:            public void setAttribValue(int i, String attribName, Object value) {
160:                dirty = true;
161:                fieldValues[i] = value.toString();
162:            }
163:
164:            public double getValueAsDouble(String elementName) {
165:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
166:                throw new java.lang.UnsupportedOperationException(
167:                        "Method getValueAsDouble() not yet implemented.");
168:            }
169:
170:            public int getAttribValueAsInt(int i) {
171:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
172:                throw new java.lang.UnsupportedOperationException(
173:                        "Method getAttribValueAsInt() not yet implemented.");
174:            }
175:
176:            public int getValueAsInt(String elementName) {
177:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
178:                throw new java.lang.UnsupportedOperationException(
179:                        "Method getValueAsInt() not yet implemented.");
180:            }
181:
182:            public String getAttribValueAsString(int i) {
183:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
184:                throw new java.lang.UnsupportedOperationException(
185:                        "Method getAttribValue() not yet implemented.");
186:            }
187:
188:            /**
189:             * Gets the value attribute of the specified node as a string.
190:             * @param elementName
191:             * @return the value as a string
192:             */
193:            public String getValueAsString(String elementName) {
194:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
195:                throw new java.lang.UnsupportedOperationException(
196:                        "Method getValueAsString() not yet implemented.");
197:            }
198:
199:            public Object getAttribValue(int i) {
200:                return fieldValues[i];
201:            }
202:
203:            public double getAttribValueAsDouble(int i) {
204:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
205:                throw new java.lang.UnsupportedOperationException(
206:                        "Method getAttribValueAsDouble() not yet implemented.");
207:            }
208:
209:            public void remove(XModel child) {
210:                /**@todo Implement this net.xoetrope.xui.data.XModel abstract method*/
211:                throw new java.lang.UnsupportedOperationException(
212:                        "Method remove() not yet implemented.");
213:            }
214:
215:            /**
216:             * Checks to see if the response has timed out or expired
217:             * @return true if the response is out-of-date
218:             */
219:            boolean hasExpired() {
220:                if ((expires > 0) && (new Date().getTime() > expires))
221:                    return true;
222:
223:                return false;
224:            }
225:
226:            public void setNumAttributes(int num) {
227:                num = Math.max(num, 2);
228:                Object[] temp = new Object[num];
229:                String[] tempNames = new String[num];
230:                if (fieldNames != null) {
231:                    if (num != fieldNames.length) {
232:                        int numAttributes = Math.min(num, fieldNames.length);
233:                        for (int i = 0; i < numAttributes; i++) {
234:                            tempNames[i] = fieldNames[i];
235:                            temp[i] = fieldValues[i];
236:                        }
237:                    } else
238:                        return;
239:                }
240:                fieldValues = temp;
241:                fieldNames = tempNames;
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.