Source Code Cross Referenced for SharkCORBAUtilities.java in  » Workflow-Engines » shark » org » enhydra » shark » corba » 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 » Workflow Engines » shark » org.enhydra.shark.corba 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.shark.corba;
002:
003:        import java.io.Serializable;
004:        import java.util.Iterator;
005:        import java.util.Map;
006:        import java.util.Properties;
007:
008:        import javax.transaction.Status;
009:        import javax.transaction.UserTransaction;
010:
011:        import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
012:        import org.enhydra.shark.utilities.SequencedHashMap;
013:        import org.omg.CORBA.Any;
014:        import org.omg.CORBA.BAD_OPERATION;
015:        import org.omg.CORBA.ORB;
016:        import org.omg.CORBA.TCKind;
017:        import org.omg.WfBase.NameValue;
018:        import org.omg.WfBase.NameValueInfo;
019:        import org.omg.WorkflowModel.WfActivity;
020:        import org.omg.WorkflowModel.WfAssignment;
021:        import org.omg.WorkflowModel.WfAssignmentEventAudit;
022:        import org.omg.WorkflowModel.WfDataEventAudit;
023:        import org.omg.WorkflowModel.WfEventAudit;
024:        import org.omg.WorkflowModel.WfProcess;
025:        import org.omg.WorkflowModel.WfProcessMgr;
026:        import org.omg.WorkflowModel.WfResource;
027:        import org.omg.WorkflowModel.WfStateEventAudit;
028:
029:        /**
030:         * The various utilities needed by engine.
031:         * 
032:         * @author Sasa Bojanic
033:         * @version 1.1
034:         */
035:        public class SharkCORBAUtilities {
036:
037:            static NameValueInfo makeCORBANameValueInfo(String attribute_name,
038:                    String type_name) {
039:                NameValueInfo nvic = new NameValueInfo();
040:                nvic.attribute_name = attribute_name;
041:                nvic.type_name = type_name;
042:                return nvic;
043:            }
044:
045:            static NameValueInfo[] makeCORBANameValueInfoArray(
046:                    org.enhydra.shark.api.client.wfservice.NameValue[] nvia) {
047:                int size = 0;
048:                if (nvia != null)
049:                    size = nvia.length;
050:                NameValueInfo[] nvica = new NameValueInfo[size];
051:                if (nvia != null) {
052:                    for (int i = 0; i < nvia.length; i++) {
053:                        org.enhydra.shark.api.client.wfservice.NameValue nv = nvia[i];
054:                        nvica[i] = makeCORBANameValueInfo(nv.getName(), nv
055:                                .getValue().toString());
056:                    }
057:                }
058:                return nvica;
059:            }
060:
061:            static NameValueInfo[] makeCORBANameValueInfoArray(Map nvia) {
062:                int size = 0;
063:                if (nvia != null)
064:                    size = nvia.size();
065:                NameValueInfo[] nvica = new NameValueInfo[size];
066:                int i = 0;
067:                if (nvia != null) {
068:                    for (Iterator it = nvia.entrySet().iterator(); it.hasNext(); i++) {
069:                        Map.Entry me = (Map.Entry) it.next();
070:                        nvica[i] = makeCORBANameValueInfo(me.getKey()
071:                                .toString(), me.getValue().toString());
072:                    }
073:                }
074:                return nvica;
075:            }
076:
077:            static NameValue makeCORBANameValue(ORB orb, String the_name,
078:                    java.lang.Object the_value) {
079:                NameValue nvc = new NameValue();
080:                nvc.the_name = the_name;
081:                nvc.the_value = createAnyFromValue(orb, the_value);
082:                return nvc;
083:            }
084:
085:            static NameValue[] makeCORBANameValueArray(ORB orb, Map nva) {
086:                int size = 0;
087:                if (nva != null)
088:                    size = nva.size();
089:                NameValue[] nvca = new NameValue[size];
090:                int i = 0;
091:                if (nva != null) {
092:                    for (Iterator it = nva.entrySet().iterator(); it.hasNext(); i++) {
093:                        Map.Entry me = (Map.Entry) it.next();
094:                        nvca[i] = makeCORBANameValue(orb, me.getKey()
095:                                .toString(), me.getValue());
096:                    }
097:                }
098:                return nvca;
099:            }
100:
101:            static NameValue[] makeCORBANameValueArray(ORB orb, String[][] nva) {
102:                int size = 0;
103:                if (nva != null)
104:                    size = nva.length;
105:                NameValue[] nvca = new NameValue[size];
106:                if (nva != null) {
107:                    for (int i = 0; i < size; i++) {
108:                        nvca[i] = makeCORBANameValue(orb, nva[i][0], nva[i][1]);
109:                    }
110:                }
111:                return nvca;
112:            }
113:
114:            static NameValue[] makeCORBANameValueArray(ORB orb, Properties props) {
115:                int size = 0;
116:                if (props != null)
117:                    size = props.size();
118:                NameValue[] nvca = new NameValue[size];
119:                if (props != null) {
120:                    Iterator it = props.entrySet().iterator();
121:                    int i = 0;
122:                    while (it.hasNext()) {
123:                        Map.Entry me = (Map.Entry) it.next();
124:                        nvca[i] = makeCORBANameValue(orb, (String) me.getKey(),
125:                                (String) me.getValue());
126:                        i++;
127:                    }
128:                }
129:                return nvca;
130:            }
131:
132:            static Map makeMap(NameValue[] nvca) {
133:                Map m = new SequencedHashMap();
134:                if (nvca != null) {
135:                    for (int i = 0; i < nvca.length; i++) {
136:                        m.put(nvca[i].the_name,
137:                                extractValueFromAny(nvca[i].the_value));
138:                    }
139:                }
140:                return m;
141:            }
142:
143:            static java.lang.Object extractValueFromAny(Any any) {
144:                java.lang.Object value = null;
145:                try {
146:                    int kind = any.type().kind().value();
147:                    if (kind == TCKind._tk_boolean) {
148:                        value = new Boolean(any.extract_boolean());
149:                    } else if (kind == TCKind._tk_wstring) {
150:                        value = new String(any.extract_wstring());
151:                    } else if (kind == TCKind._tk_long) {
152:                        value = new Integer(any.extract_long());
153:                    } else if (kind == TCKind._tk_longlong) {
154:                        value = new Long(any.extract_longlong());
155:                    } else if (kind == TCKind._tk_double) {
156:                        value = new Double(any.extract_double());
157:                    } else if (kind == TCKind._tk_value) {
158:                        value = any.extract_Value();
159:                    }
160:                } catch (BAD_OPERATION bo) {
161:                    System.out
162:                            .println("Extracting value failed - bo exception");
163:                    // bo.printStackTrace();
164:                    return null;
165:                }
166:                return value;
167:            }
168:
169:            static Any createAnyFromValue(ORB orb, java.lang.Object value) {
170:                Any any = orb.create_any();
171:
172:                try {
173:                    if (value instanceof  Boolean) {
174:                        any.insert_boolean(((Boolean) value).booleanValue());
175:                    } else if (value instanceof  String) {
176:                        any.insert_wstring((String) value);
177:                    } else if (value instanceof  Long) {
178:                        any.insert_longlong(((Long) value).longValue());
179:                    } else if (value instanceof  Double) {
180:                        any.insert_double(((Double) value).doubleValue());
181:                    } else if (value instanceof  Serializable) {
182:                        any.insert_Value((Serializable) value);
183:                    }
184:                } catch (BAD_OPERATION bo) {
185:                    System.out
186:                            .println("Creating any from val failed - bo exception");
187:                    // bo.printStackTrace();
188:                }
189:                return any;
190:            }
191:
192:            static WfProcessMgr[] makeCORBAProcessMgrs(Collective toJoin,
193:                    org.enhydra.shark.api.client.wfmodel.WfProcessMgr[] objs) {
194:                int size = 0;
195:                if (objs != null)
196:                    size = objs.length;
197:                WfProcessMgrCORBA[] cobjs = new WfProcessMgrCORBA[size];
198:                for (int i = 0; i < cobjs.length; i++) {
199:                    try {
200:                        cobjs[i] = new WfProcessMgrCORBA(toJoin, objs[i]);
201:                    } catch (Exception ex) {
202:                    }
203:                }
204:                return cobjs;
205:            }
206:
207:            static WfProcess[] makeCORBAProcesses(Collective toJoin,
208:                    org.enhydra.shark.api.client.wfmodel.WfProcess[] objs) {
209:                int size = 0;
210:                if (objs != null)
211:                    size = objs.length;
212:                WfProcessCORBA[] cobjs = new WfProcessCORBA[size];
213:                for (int i = 0; i < cobjs.length; i++) {
214:                    try {
215:                        cobjs[i] = new WfProcessCORBA(toJoin, objs[i]);
216:                    } catch (Exception ex) {
217:                    }
218:                }
219:                return cobjs;
220:            }
221:
222:            static WfActivity[] makeCORBAActivities(Collective toJoin,
223:                    org.enhydra.shark.api.client.wfmodel.WfActivity[] objs) {
224:                int size = 0;
225:                if (objs != null)
226:                    size = objs.length;
227:                WfActivityCORBA[] cobjs = new WfActivityCORBA[size];
228:                for (int i = 0; i < cobjs.length; i++) {
229:                    try {
230:                        cobjs[i] = new WfActivityCORBA(toJoin, objs[i]);
231:                    } catch (Exception ex) {
232:                    }
233:                }
234:                return cobjs;
235:            }
236:
237:            static WfAssignment[] makeCORBAAssignments(Collective toJoin,
238:                    org.enhydra.shark.api.client.wfmodel.WfAssignment[] objs) {
239:                int size = 0;
240:                if (objs != null)
241:                    size = objs.length;
242:                WfAssignmentCORBA[] cobjs = new WfAssignmentCORBA[size];
243:                for (int i = 0; i < cobjs.length; i++) {
244:                    try {
245:                        cobjs[i] = new WfAssignmentCORBA(toJoin, objs[i]);
246:                    } catch (Exception ex) {
247:                    }
248:                }
249:                return cobjs;
250:            }
251:
252:            static WfResource[] makeCORBAResources(Collective toJoin,
253:                    org.enhydra.shark.api.client.wfmodel.WfResource[] objs) {
254:                int size = 0;
255:                if (objs != null)
256:                    size = objs.length;
257:                WfResourceCORBA[] cobjs = new WfResourceCORBA[size];
258:                for (int i = 0; i < cobjs.length; i++) {
259:                    try {
260:                        cobjs[i] = new WfResourceCORBA(toJoin, objs[i]);
261:                    } catch (Exception ex) {
262:                    }
263:                }
264:                return cobjs;
265:            }
266:
267:            static WfEventAudit makeCORBAEventAudit(Collective toJoin,
268:                    org.enhydra.shark.api.client.wfmodel.WfEventAudit obj) {
269:                try {
270:                    if (obj instanceof  org.enhydra.shark.api.client.wfmodel.WfCreateProcessEventAudit) {
271:                        return new WfCreateProcessEventAuditCORBA(
272:                                toJoin,
273:                                (org.enhydra.shark.api.client.wfmodel.WfCreateProcessEventAudit) obj);
274:                    } else if (obj instanceof  org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit) {
275:                        return new WfAssignmentEventAuditCORBA(
276:                                toJoin,
277:                                (org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit) obj);
278:                    } else if (obj instanceof  org.enhydra.shark.api.client.wfmodel.WfDataEventAudit) {
279:                        return new WfDataEventAuditCORBA(
280:                                toJoin,
281:                                (org.enhydra.shark.api.client.wfmodel.WfDataEventAudit) obj);
282:                    } else if (obj instanceof  org.enhydra.shark.api.client.wfmodel.WfStateEventAudit) {
283:                        return new WfStateEventAuditCORBA(
284:                                toJoin,
285:                                (org.enhydra.shark.api.client.wfmodel.WfStateEventAudit) obj);
286:                    } else {
287:                        return null;
288:                    }
289:                } catch (Exception ex) {
290:                    return null;
291:                }
292:            }
293:
294:            static WfEventAudit[] makeCORBAEventAudits(Collective toJoin,
295:                    org.enhydra.shark.api.client.wfmodel.WfEventAudit[] objs) {
296:                int size = 0;
297:                if (objs != null)
298:                    size = objs.length;
299:                WfEventAudit[] cobjs = new WfEventAudit[size];
300:                for (int i = 0; i < cobjs.length; i++) {
301:                    cobjs[i] = makeCORBAEventAudit(toJoin, objs[i]);
302:                }
303:                return cobjs;
304:            }
305:
306:            static WfStateEventAudit[] makeCORBAStateEventAudits(
307:                    Collective toJoin,
308:                    org.enhydra.shark.api.client.wfmodel.WfEventAudit[] objs)
309:                    throws Exception {
310:                int size = 0;
311:                if (objs != null)
312:                    size = objs.length;
313:                WfStateEventAudit[] cobjs = new WfStateEventAuditCORBA[size];
314:                for (int i = 0; i < cobjs.length; i++) {
315:                    cobjs[i] = (WfStateEventAudit) makeCORBAEventAudit(toJoin,
316:                            objs[i]);
317:                }
318:                return cobjs;
319:            }
320:
321:            static WfDataEventAudit[] makeCORBADataEventAudits(
322:                    Collective toJoin,
323:                    org.enhydra.shark.api.client.wfmodel.WfEventAudit[] objs)
324:                    throws Exception {
325:                int size = 0;
326:                if (objs != null)
327:                    size = objs.length;
328:                WfDataEventAudit[] cobjs = new WfDataEventAuditCORBA[size];
329:                for (int i = 0; i < cobjs.length; i++) {
330:                    cobjs[i] = (WfDataEventAudit) makeCORBAEventAudit(toJoin,
331:                            objs[i]);
332:                }
333:                return cobjs;
334:            }
335:
336:            static WfAssignmentEventAudit[] makeCORBAAssignmentEventAudits(
337:                    Collective toJoin,
338:                    org.enhydra.shark.api.client.wfmodel.WfEventAudit[] objs)
339:                    throws Exception {
340:                int size = 0;
341:                if (objs != null)
342:                    size = objs.length;
343:                WfAssignmentEventAudit[] cobjs = new WfAssignmentEventAuditCORBA[size];
344:                for (int i = 0; i < cobjs.length; i++) {
345:                    cobjs[i] = (WfAssignmentEventAudit) makeCORBAEventAudit(
346:                            toJoin, objs[i]);
347:                }
348:                return cobjs;
349:            }
350:
351:            public static UserTransaction beginTransaction(boolean e)
352:                    throws Exception {
353:                UserTransaction ut = null;
354:                if (!e) {
355:                    ut = SharkInterfaceWrapper.getUserTransaction();
356:                    ut.begin();
357:                }
358:                return ut;
359:            }
360:
361:            public static void commitTransaction(UserTransaction ut, boolean e)
362:                    throws Exception {
363:                if (!e) {
364:                    ut.commit();
365:                }
366:            }
367:
368:            public static void rollbackTransaction(UserTransaction ut, boolean e) {
369:                if (!e) {
370:                    try {
371:                        if (ut.getStatus() != Status.STATUS_NO_TRANSACTION) {
372:                            ut.rollback();
373:                        }
374:                    } catch (Exception _) {
375:                    }
376:                }
377:            }
378:
379:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.