Source Code Cross Referenced for XSSLReturn.java in  » XML » activexml » org » xdev » base » xssl » 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 » activexml » org.xdev.base.xssl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Jul 14, 2003
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;
008:
009:        import java.util.ArrayList;
010:        import java.util.HashMap;
011:
012:        import org.xdev.base.core.AbstractPersistance;
013:        import org.xdev.base.util.ServerUtilities;
014:        import org.xdev.base.util.Tools;
015:        import org.xdev.base.xssl.manage.*;
016:
017:        /**
018:         <table class="componentInformation">
019:         <th class="fieldSetItem" colspan="2">Information: org.xdev.base.xssl.XSSLReturn</th>
020:         <tr class="fieldSetItem">
021:         <td>XML Name(s)</td>
022:         <td>no name</td>
023:         </tr>
024:         <tr class="fieldSetItem">
025:         <td>Author(s)</td>
026:         <td>Artem D. Yegorov</td>
027:         </tr>
028:         <tr class="fieldSetItem">
029:         <td class="fieldSetItem" colspan="2" style="background-color: #C1C9C9;">
030:         <p>&nbsp;</p>
031:        
032:         <div colspan="2" style="margin: 15 0 15 0;">
033:         <div class="componentDescriptionHead">
034:         Component Description
035:         </div>
036:         <div class="componentDescriptionBody">
037:         Abstracted core component, that cannot be used within XDD and serves as base for the rest of XJCs, 
038:         adding capabilities of variable persistence, referencing and value association. 
039:         </div>
040:         </div>
041:        
042:         <p/>
043:        
044:         <table class="fieldSetTable">
045:         <tr class="fieldSetItem">
046:         <th class="fieldSetItem" colspan="3">Properties</th>
047:         </tr>
048:         <tr class="fieldSetItem">
049:         <th class="fieldSetItem">Property Name</th>
050:         <th class="fieldSetItem">Property Value</th>
051:         <th class="fieldSetItem">Property Description</th>
052:         </tr>
053:         <tr class="fieldSetItem">
054:         <td class="fieldSetItem">scope</td>
055:         <td class="fieldSetItem">root, parent, find</td>	
056:         <td class="fieldSetItem">Defines a scope of a variable definition or referral. Default is root.</td>
057:         </tr>
058:         <tr class="fieldSetItem">
059:         <td class="fieldSetItem">define</td>
060:         <td class="fieldSetItem">true, false</td>
061:         <td class="fieldSetItem">Specifies whether a given component will be defined as a variable. Default is false.</td>
062:         </tr>
063:         <tr class="fieldSetItem">
064:         <td class="fieldSetItem">object-id</td>
065:         <td class="fieldSetItem">any value</td>
066:         <td class="fieldSetItem">Specifies a name for the variable which a given component will be defined under.</td>
067:         </tr>
068:         <tr class="fieldSetItem">
069:         <td class="fieldSetItem">reference-id</td>
070:         <td class="fieldSetItem">any value</td>
071:         <td class="fieldSetItem">Specifies a name for the variable which a given component will be referring to.</td>
072:         </tr>
073:         <tr class="fieldSetItem">
074:         <td class="fieldSetItem">global</td>
075:         <td class="fieldSetItem">true, false</td>
076:         <td class="fieldSetItem">Defines whether to use a static variable persistence or not. Default is false;</td>
077:         </tr>
078:         <tr class="fieldSetItem">
079:         <td class="fieldSetItem">store</td>
080:         <td class="fieldSetItem">any xpath expression</td>
081:         <td class="fieldSetItem">Identifies a target persistence which will be used for the variable definition or referral. Used in conjunction with scope=find</td>
082:         </tr>
083:         </table>
084:        
085:         <p/>
086:        
087:         <table class="fieldSetTable">
088:         <tr class="fieldSetItem">
089:         <th class="fieldSetItem" colspan="3">Event Triggers</th>
090:         </tr>
091:         <tr class="fieldSetItem">
092:         <th class="fieldSetItem">Event Name</th>
093:         <th class="fieldSetItem">Event Code</th>
094:         <th class="fieldSetItem">Event Description</th>
095:         </tr>
096:         <tr class="fieldSetItem">
097:         <td class="fieldSetItem">DEFINE_START_EVENT</td>
098:         <td class="fieldSetItem">30</td>
099:         <td class="fieldSetItem">Ready to start defining the component</td>
100:         </tr>
101:         <tr class="fieldSetItem">
102:         <td class="fieldSetItem">DEFINE_PERSISTANCE_EVENT</td>
103:         <td class="fieldSetItem">31</td>
104:         <td class="fieldSetItem">Ready to identify persistence.</td>
105:         </tr>
106:         <tr class="fieldSetItem">
107:         <td class="fieldSetItem">DEFINE_DEFINED_EVENT</td>
108:         <td class="fieldSetItem">32</td>
109:         <td class="fieldSetItem">Component has been defined</td>
110:         </tr>
111:         <tr class="fieldSetItem">
112:         <td class="fieldSetItem">DEFINE_END_EVENT</td>
113:         <td class="fieldSetItem">33</td>
114:         <td class="fieldSetItem">Define process has finished</td>
115:         </tr>
116:         <tr class="fieldSetItem">
117:         <td class="fieldSetItem">GET_REFERENCE_START_EVENT</td>
118:         <td class="fieldSetItem">34</td>
119:         <td class="fieldSetItem">Ready to reference the component</td>
120:         </tr>
121:         <tr class="fieldSetItem">
122:         <td class="fieldSetItem">GET_REFERENCE_END_EVENT</td>
123:         <td class="fieldSetItem">35</td>
124:         <td class="fieldSetItem">Reference process has finished</td>
125:         </tr>
126:         </table>
127:        
128:         <p/>	
129:        
130:         <div>
131:         <div class="codeExamplesHead">
132:         Code Examples
133:         </div>
134:         <div class="codeExamplesBody">
135:         <div style="margin: 15px 0px 15px 0px;">
136:         <div class="exampleHead" style="width: 180px;">
137:         Simple Java example
138:         </div>
139:         <div class="exampleBody">
140:         public class TestComponent extends XSSLReturn {
141:         <ul class="noMarkerList">
142:         <li>
143:         private Object returnValue = null;
144:         </li>
145:         <li/>
146:         <li>
147:         protected void set() throws Exception {
148:         <ul class="noMarkerList">
149:         <li>this.returnValue = "test component";</li>
150:         </ul>
151:         }
152:         </li>
153:         <li>	
154:         public Object getValue() {
155:         <ul class="noMarkerList">	
156:         <li>return this.returnValue;</li>
157:         </ul>
158:         }
159:         </li>
160:         </ul>
161:         }
162:         </div>
163:         </div>
164:        
165:         <p/>
166:        
167:         <div style="margin: 15px 0px 15px 0px;">
168:         <div class="exampleHead">
169:         Simple XML example (Given that the class TestComponent is bound to XML name &lt;test&gt;)
170:         </div>
171:         <div class="exampleBody">
172:         <p>&lt;test/&gt;</p>
173:         <p>Execution of such will return &quot;test component&quot; to console</p>
174:         </div>
175:         </div>
176:         </div>
177:         </div>
178:         </td>
179:         </tr>
180:         </table>
181:         */
182:        public abstract class XSSLReturn extends XSSLAction implements 
183:                ITransactionDefinable {
184:            public static final int PARENT_SCOPE = 0;
185:            public static final int ROOT_SCOPE = 1;
186:            public static final int FIND_SCOPE = 2;
187:
188:            public static final int DEFINE_START_EVENT = 30;
189:            public static final int DEFINE_PERSISTANCE_EVENT = 31;
190:            public static final int DEFINE_DEFINED_EVENT = 32;
191:            public static final int DEFINE_END_EVENT = 33;
192:            public static final int GET_REFERENCE_START_EVENT = 34;
193:            public static final int GET_REFERENCE_END_EVENT = 35;
194:
195:            public static final String SCOPE = "scope";
196:            public static final String REFERENCE_ID = "reference-id";
197:            public static final String DEFAULT_TX_RS_TAG_NAME = "result";
198:            public static final String INDEXED_COMPONENT_ID = "store";
199:
200:            /**
201:             * @param id
202:             */
203:            public XSSLReturn(String id) {
204:                super (id);
205:                // TODO Auto-generated constructor stub
206:            }
207:
208:            /**
209:             * @param id
210:             * @param properties
211:             */
212:            public XSSLReturn(String id, HashMap properties) {
213:                super (id, properties);
214:                // TODO Auto-generated constructor stub
215:            }
216:
217:            public void setValue(Object value) {
218:                this .setProperty("value", value);
219:            }
220:
221:            protected void invoke() throws Exception {
222:                if (this .getBooleanProperty("define")) {
223:                    this .define();
224:                }
225:            }
226:
227:            abstract public Object getObjectValue();
228:
229:            public void setReturnValue(Object value) {
230:                this .setValue(value);
231:            }
232:
233:            protected Object getStoreValue() {
234:                return this .getObjectValue();
235:            }
236:
237:            /* (non-Javadoc)
238:             * @see org.xdev.base.transaction.AbstractTransaction#rollback()
239:             */
240:            public void rollback() throws Exception {
241:            }
242:
243:            /* (non-Javadoc)
244:             * @see org.xdev.base.transaction.AbstractTransaction#commit()
245:             */
246:            public void commit() throws Exception {
247:            }
248:
249:            protected void close() throws Exception {
250:            }
251:
252:            protected String setTagName() {
253:                return XSSLReturn.DEFAULT_TX_RS_TAG_NAME;
254:            }
255:
256:            public void define() throws Exception {
257:                this .define(XSSLReturn.ROOT_SCOPE);
258:            }
259:
260:            public void define(int globalScope) throws Exception {
261:
262:                this .issueTrigger(XSSLReturn.DEFINE_START_EVENT);
263:
264:                int scope = -1;
265:
266:                this .logDebug("Definable global scope is: " + globalScope);
267:
268:                if (!this .hasProperty(XSSLReturn.SCOPE)) {
269:                    scope = globalScope;
270:                } else {
271:                    scope = this .evaluateScope(this 
272:                            .getProperty(XSSLReturn.SCOPE));
273:                }
274:
275:                this .logDebug("Component " + this .getClass()
276:                        + " is defining itself.");
277:                this .logDebug("Definable scope is: " + scope);
278:
279:                String id = this .getProperty(XSSLAction.OBJECT_ID);
280:
281:                this .logDebug("Definable object id is: " + id);
282:
283:                if (id != null && !"".equals(id)) {
284:                    XSSLAction target = this .evaluateTarget(scope);
285:
286:                    this .logDebug("Definable target evaluated as: " + target);
287:
288:                    AbstractPersistance persistance = target
289:                            .getPersistance(this .getBooleanProperty("global"));
290:
291:                    this .issueTrigger(XSSLReturn.DEFINE_PERSISTANCE_EVENT,
292:                            persistance);
293:
294:                    this .logDebug("Definable persistance evaluated as: "
295:                            + persistance);
296:
297:                    persistance.storeObject(id, this );
298:
299:                    this .issueTrigger(XSSLReturn.DEFINE_DEFINED_EVENT,
300:                            persistance);
301:
302:                    this .logDebug("Component has defined itself successfuly.");
303:                }
304:
305:                this .issueTrigger(XSSLReturn.DEFINE_END_EVENT);
306:
307:            }
308:
309:            public XSSLAction evaluateTarget(int scope) {
310:                XSSLAction target = null;
311:                switch (scope) {
312:                case XSSLReturn.PARENT_SCOPE:
313:                    target = (XSSLAction) this .getParentComponent();
314:
315:                    if (target instanceof  TransactionDefine
316:                            && !target.equals(this .getRoot())) {
317:                        target = (XSSLAction) target.getParentComponent();
318:                    }
319:                    break;
320:                case XSSLReturn.ROOT_SCOPE:
321:                    target = (XSSLAction) this .getRoot();
322:                    break;
323:                case XSSLReturn.FIND_SCOPE:
324:                    target = (XSSLAction) this .getRoot().getIndexedComponent(
325:                            this .getProperty(XSSLReturn.INDEXED_COMPONENT_ID));
326:                    break;
327:                }
328:
329:                target = target == null ? this  : target;
330:
331:                return target;
332:            }
333:
334:            public int evaluateScope(String scope) {
335:                int s = -1;
336:
337:                this .logDebug("Scope code to be evaluated: " + scope);
338:
339:                if ("root".equalsIgnoreCase(scope) || "".equals(scope)
340:                        || scope == null) {
341:                    s = XSSLReturn.ROOT_SCOPE;
342:                } else if ("parent".equalsIgnoreCase(scope)) {
343:                    s = XSSLReturn.PARENT_SCOPE;
344:                } else if ("find".equalsIgnoreCase(scope)) {
345:                    s = XSSLReturn.FIND_SCOPE;
346:                }
347:
348:                this .logDebug("Scope code evaluated to: " + s);
349:
350:                return s;
351:            }
352:
353:            protected Object getReference(String referenceId) {
354:                AbstractPersistance persistance = this .getPersistance();
355:
356:                this .logDebug("Getting reference: " + referenceId);
357:
358:                this .logDebug("Local Self persistance: " + persistance);
359:
360:                Object obj = null;
361:
362:                if (!persistance.exists(referenceId)) {
363:                    persistance = this .getGlobalPersistance();
364:
365:                    this .logDebug("Global Self persistance: " + persistance);
366:
367:                    if (!persistance.exists(referenceId)) {
368:                        XSSLAction target = this .getPersistanceTarget();
369:
370:                        persistance = target.getPersistance();
371:
372:                        this .logDebug("Target reference container: " + target);
373:
374:                        this .logDebug("Local Target persistance: "
375:                                + persistance);
376:
377:                        if (!persistance.exists(referenceId)) {
378:                            persistance = target.getGlobalPersistance();
379:                            this .logDebug("Global Target persistance: "
380:                                    + persistance);
381:                        }
382:                    }
383:                }
384:
385:                obj = persistance.get(referenceId);
386:
387:                Object temp = obj;
388:
389:                while (temp instanceof  XSSLReturn) {
390:                    temp = ((XSSLReturn) temp).getObjectValue();
391:
392:                    if (temp instanceof  XSSLReturn) {
393:                        obj = temp;
394:                    }
395:
396:                    this .logDebug("Referenced object received: " + obj);
397:                }
398:
399:                this .logDebug("Referenced object received: " + obj);
400:
401:                return obj;
402:            }
403:
404:            protected XSSLAction getPersistanceTarget() {
405:                int scope = this .evaluateScope(this 
406:                        .getProperty(XSSLReturn.SCOPE));
407:
408:                this .logDebug("Reference scope: " + scope);
409:
410:                return this .evaluateTarget(scope);
411:            }
412:
413:            public boolean isPersisted(boolean global) {
414:                XSSLAction target = this .getPersistanceTarget();
415:
416:                AbstractPersistance persistance = null;
417:
418:                if (global) {
419:                    persistance = target.getGlobalPersistance();
420:                } else {
421:                    persistance = target.getPersistance();
422:                }
423:
424:                boolean persisted = persistance.exists(this .getObjectId());
425:                ;
426:
427:                this .logDebug("Checking if object " + this  + " with id "
428:                        + this .getObjectId() + " is persisted in "
429:                        + persistance + ": " + persisted);
430:
431:                return persisted;
432:            }
433:
434:            protected Object getObject(String referenceId) {
435:                Object obj = null;
436:
437:                if (referenceId != null && !"".equals(referenceId)) {
438:                    Object reference = this .getReference(referenceId);
439:
440:                    if (reference instanceof  XSSLReturn) {
441:                        obj = ((XSSLReturn) reference).getObjectValue();
442:                    } else {
443:                        obj = reference;
444:                    }
445:                }
446:
447:                return obj;
448:
449:            }
450:
451:            protected Object getObject() {
452:                return this .getObject(this .getReferenceId());
453:            }
454:
455:            protected Object getReference() {
456:                return this .getReference(this .getReferenceId());
457:            }
458:
459:            protected Object getEvaluatedReference() {
460:                Object obj = this .getReference();
461:
462:                while (obj instanceof  XSSLReturn) {
463:                    obj = ((XSSLReturn) obj).getObjectValue();
464:                }
465:
466:                this .logDebug("Evaluated reference receveived: " + obj);
467:
468:                return obj;
469:            }
470:
471:            protected String getReferenceId() {
472:                String ref = this .getProperty(XSSLReturn.REFERENCE_ID);
473:
474:                if (ref == null || "".equals(ref)) {
475:                    ref = ServerUtilities.getShortGuid();
476:                }
477:
478:                return ref;
479:            }
480:
481:            public String getObjectId() {
482:                return this .getProperty(XSSLAction.OBJECT_ID);
483:            }
484:
485:            protected void setReference(Object obj) {
486:
487:                this .logDebug("Setting reference " + this .getObjectId()
488:                        + " for object " + obj.getClass() + ": " + obj);
489:
490:                this .setReference(this .getObjectId(), obj);
491:            }
492:
493:            protected void setReference(String id, Object obj) {
494:                this .getPersistanceTarget().getPersistance().storeObject(id,
495:                        obj);
496:            }
497:
498:            protected Object resolveKeyword(Object key) {
499:                Object obj = null;
500:
501:                if (key instanceof  String) {
502:                    String keyword = key.toString();
503:
504:                    String[] strs = keyword.split("[\\_\\{]|[\\}]");
505:
506:                    if (strs.length > 1) {
507:                        for (int i = 0; i < strs.length; i++) {
508:
509:                            if ("".equals(strs[i])) {
510:                                continue;
511:                            }
512:
513:                            try {
514:
515:                                Object propertyValue = this .getObject(strs[i]);
516:
517:                                keyword = Tools.replaceString(keyword, "_{"
518:                                        + strs[i] + "}",
519:                                        propertyValue == null ? ""
520:                                                : propertyValue.toString());
521:                            } catch (Exception ex) {
522:                                this .logError(ex);
523:                            }
524:                        }
525:                    }
526:
527:                    key = keyword;
528:                }
529:
530:                if (key instanceof  String && ((String) key).startsWith("_")
531:                        && !"_".equals(key)) {
532:                    obj = this .getObject(((String) key).substring(1,
533:                            ((String) key).length()));
534:                } else {
535:                    obj = super .resolveKeyword(key);
536:                }
537:
538:                try {
539:                    if (obj instanceof  XSSLReturn) {
540:                        ((XSSLReturn) obj).execute();
541:
542:                        obj = ((XSSLReturn) obj).getObjectValue();
543:                    }
544:                } catch (Exception ex) {
545:                    this .log(ex);
546:                }
547:
548:                return obj;
549:            }
550:
551:            /**
552:             * @return Returns the dEFINE_DEFINED_EVENT.
553:             */
554:            public static int getDEFINE_DEFINED_EVENT() {
555:                return DEFINE_DEFINED_EVENT;
556:            }
557:
558:            /**
559:             * @return Returns the dEFINE_END_EVENT.
560:             */
561:            public static int getDEFINE_END_EVENT() {
562:                return DEFINE_END_EVENT;
563:            }
564:
565:            /**
566:             * @return Returns the dEFINE_PERSISTANCE_EVENT.
567:             */
568:            public static int getDEFINE_PERSISTANCE_EVENT() {
569:                return DEFINE_PERSISTANCE_EVENT;
570:            }
571:
572:            /**
573:             * @return Returns the dEFINE_START_EVENT.
574:             */
575:            public static int getDEFINE_START_EVENT() {
576:                return DEFINE_START_EVENT;
577:            }
578:
579:            /**
580:             * @return Returns the gET_REFERENCE_END_EVENT.
581:             */
582:            public static int getGET_REFERENCE_END_EVENT() {
583:                return GET_REFERENCE_END_EVENT;
584:            }
585:
586:            /**
587:             * @return Returns the gET_REFERENCE_START_EVENT.
588:             */
589:            public static int getGET_REFERENCE_START_EVENT() {
590:                return GET_REFERENCE_START_EVENT;
591:            }
592:
593:            public boolean hasReference() {
594:                return (this .getReferenceId() != null && !"".equals(this
595:                        .getReferenceId()));
596:            }
597:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.