Source Code Cross Referenced for AutoRetrySchedule.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » runtime » scheduler » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.runtime.scheduler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         * 		Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2007 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id: AutoRetrySchedule.java 6905 2007-04-19 03:05:32Z mpreston $
023:         */
024:        package com.bostechcorp.cbesb.runtime.scheduler;
025:
026:        import javax.xml.namespace.QName;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.jdom.Element;
031:        import org.quartz.CronExpression;
032:
033:        public class AutoRetrySchedule implements  ISchedule {
034:
035:            private Log log = LogFactory.getLog(AutoRetrySchedule.class);
036:            private String startTime;
037:            private String endTime;
038:            private int retryInterval;
039:            private String dayOfMonth;
040:            private String month;
041:            private String dayOfWeek;
042:            private String holidaySchedule;
043:            private QName successNotificationService;
044:            private String successNotificationEndpoint;
045:            private QName failureNotificationService;
046:            private String failureNotificationEndpoint;
047:
048:            /**
049:             * @return the dayOfMonth
050:             */
051:            public String getDayOfMonth() {
052:                return dayOfMonth;
053:            }
054:
055:            /**
056:             * @param dayOfMonth the dayOfMonth to set
057:             */
058:            public void setDayOfMonth(String dayOfMonth) {
059:                this .dayOfMonth = dayOfMonth;
060:            }
061:
062:            /**
063:             * @return the dayOfWeek
064:             */
065:            public String getDayOfWeek() {
066:                return dayOfWeek;
067:            }
068:
069:            /**
070:             * @param dayOfWeek the dayOfWeek to set
071:             */
072:            public void setDayOfWeek(String dayOfWeek) {
073:                this .dayOfWeek = dayOfWeek;
074:            }
075:
076:            /**
077:             * @return the endTime
078:             */
079:            public String getEndTime() {
080:                return endTime;
081:            }
082:
083:            /**
084:             * @param endTime the endTime to set
085:             */
086:            public void setEndTime(String endTime) {
087:                this .endTime = endTime;
088:            }
089:
090:            /**
091:             * @return the failureNotificationEndpoint
092:             */
093:            public String getFailureNotificationEndpoint() {
094:                return failureNotificationEndpoint;
095:            }
096:
097:            /**
098:             * @param failureNotificationEndpoint the failureNotificationEndpoint to set
099:             */
100:            public void setFailureNotificationEndpoint(
101:                    String failureNotificationEndpoint) {
102:                this .failureNotificationEndpoint = failureNotificationEndpoint;
103:            }
104:
105:            /**
106:             * @return the failureNotificationService
107:             */
108:            public QName getFailureNotificationService() {
109:                return failureNotificationService;
110:            }
111:
112:            /**
113:             * @param failureNotificationService the failureNotificationService to set
114:             */
115:            public void setFailureNotificationService(
116:                    QName failureNotificationService) {
117:                this .failureNotificationService = failureNotificationService;
118:            }
119:
120:            /**
121:             * @return the holidaySchedule
122:             */
123:            public String getHolidaySchedule() {
124:                return holidaySchedule;
125:            }
126:
127:            /**
128:             * @param holidaySchedule the holidaySchedule to set
129:             */
130:            public void setHolidaySchedule(String holidaySchedule) {
131:                this .holidaySchedule = holidaySchedule;
132:            }
133:
134:            /**
135:             * @return the month
136:             */
137:            public String getMonth() {
138:                return month;
139:            }
140:
141:            /**
142:             * @param month the month to set
143:             */
144:            public void setMonth(String month) {
145:                this .month = month;
146:            }
147:
148:            /**
149:             * @return the retryInterval
150:             */
151:            public int getRetryInterval() {
152:                return retryInterval;
153:            }
154:
155:            /**
156:             * @param retryInterval the retryInterval to set
157:             */
158:            public void setRetryInterval(int retryInterval) {
159:                this .retryInterval = retryInterval;
160:            }
161:
162:            /**
163:             * @return the startTime
164:             */
165:            public String getStartTime() {
166:                return startTime;
167:            }
168:
169:            /**
170:             * @param startTime the startTime to set
171:             */
172:            public void setStartTime(String startTime) {
173:                this .startTime = startTime;
174:            }
175:
176:            /**
177:             * @return the successNotificationEndpoint
178:             */
179:            public String getSuccessNotificationEndpoint() {
180:                return successNotificationEndpoint;
181:            }
182:
183:            /**
184:             * @param successNotificationEndpoint the successNotificationEndpoint to set
185:             */
186:            public void setSuccessNotificationEndpoint(
187:                    String successNotificationEndpoint) {
188:                this .successNotificationEndpoint = successNotificationEndpoint;
189:            }
190:
191:            /**
192:             * @return the successNotificationService
193:             */
194:            public QName getSuccessNotificationService() {
195:                return successNotificationService;
196:            }
197:
198:            /**
199:             * @param successNotificationService the successNotificationService to set
200:             */
201:            public void setSuccessNotificationService(
202:                    QName successNotificationService) {
203:                this .successNotificationService = successNotificationService;
204:            }
205:
206:            public CronExpression getCronExpression() throws Exception {
207:                if (startTime == null) {
208:                    throw new Exception(
209:                            "AutoRetrySchedule - Start Time is null");
210:                }
211:                String[] startTimeArray = startTime.split(":");
212:                if (startTimeArray.length != 3) {
213:                    throw new Exception(
214:                            "AutoRetrySchedule - Start Time is invalid: "
215:                                    + startTime);
216:                }
217:                String cronStr = startTimeArray[2] + " " + startTimeArray[1]
218:                        + " " + startTimeArray[0] + " " + dayOfMonth + " "
219:                        + month + " " + dayOfWeek;
220:                CronExpression cronExpr = new CronExpression(cronStr);
221:                return cronExpr;
222:            }
223:
224:            /* (non-Javadoc)
225:             * @see com.bostechcorp.cbesb.runtime.scheduler.ISchedule#fromJDomElement()
226:             */
227:            public boolean fromJDomElement(Element autoRetryElem,
228:                    ComponentSchedule compSched) {
229:                String value = compSched.getChildTextValue(autoRetryElem,
230:                        ComponentSchedule.START_TIME);
231:                if (value != null) {
232:                    setStartTime(value);
233:                } else {
234:                    log.error("AutoRetrySchedule - Unable to load value of '"
235:                            + ComponentSchedule.START_TIME + "'");
236:                    return false;
237:                }
238:                value = compSched.getChildTextValue(autoRetryElem,
239:                        ComponentSchedule.END_TIME);
240:                if (value != null) {
241:                    setEndTime(value);
242:                } else {
243:                    log.error("AutoRetrySchedule - Unable to load value of '"
244:                            + ComponentSchedule.END_TIME + "'");
245:                    return false;
246:                }
247:                value = compSched.getChildTextValue(autoRetryElem,
248:                        ComponentSchedule.RETRY_INTERVAL);
249:                if (value != null) {
250:                    setRetryInterval(Integer.parseInt(value));
251:                } else {
252:                    log.error("AutoRetrySchedule - Unable to load value of '"
253:                            + ComponentSchedule.RETRY_INTERVAL + "'");
254:                    return false;
255:                }
256:                value = compSched.getChildTextValue(autoRetryElem,
257:                        ComponentSchedule.DAY_OF_MONTH);
258:                if (value != null) {
259:                    setDayOfMonth(value);
260:                } else {
261:                    log.error("AutoRetrySchedule - Unable to load value of '"
262:                            + ComponentSchedule.DAY_OF_MONTH + "'");
263:                    return false;
264:                }
265:                value = compSched.getChildTextValue(autoRetryElem,
266:                        ComponentSchedule.MONTH);
267:                if (value != null) {
268:                    setMonth(value);
269:                } else {
270:                    log.error("AutoRetrySchedule - Unable to load value of '"
271:                            + ComponentSchedule.MONTH + "'");
272:                    return false;
273:                }
274:                value = compSched.getChildTextValue(autoRetryElem,
275:                        ComponentSchedule.DAY_OF_WEEK);
276:                if (value != null) {
277:                    setDayOfWeek(value);
278:                } else {
279:                    log.error("AutoRetrySchedule - Unable to load value of '"
280:                            + ComponentSchedule.DAY_OF_WEEK + "'");
281:                    return false;
282:                }
283:                value = compSched.getChildTextValue(autoRetryElem,
284:                        ComponentSchedule.HOLIDAY_SCHEDULE);
285:                if (value != null) {
286:                    setHolidaySchedule(value);
287:                }
288:
289:                Element successNotification = compSched.getChild(autoRetryElem,
290:                        ComponentSchedule.SUCCESS_NOTIFICATION_EP);
291:                if (successNotification != null) {
292:                    value = compSched.getChildTextValue(successNotification,
293:                            ComponentSchedule.SERVICE_NAME);
294:                    if (value != null) {
295:                        setSuccessNotificationService(compSched
296:                                .prefixedNameToQName(value));
297:                    } else {
298:                        log
299:                                .error("AutoRetrySchedule - Unable to load value of '"
300:                                        + ComponentSchedule.SERVICE_NAME + "'");
301:                        return false;
302:                    }
303:                    value = compSched.getChildTextValue(successNotification,
304:                            ComponentSchedule.ENDPOINT_NAME);
305:                    if (value != null) {
306:                        setSuccessNotificationEndpoint(value);
307:                    } else {
308:                        log
309:                                .error("AutoRetrySchedule - Unable to load value of '"
310:                                        + ComponentSchedule.ENDPOINT_NAME + "'");
311:                        return false;
312:                    }
313:                }
314:                Element failureNotification = compSched.getChild(autoRetryElem,
315:                        ComponentSchedule.FAILURE_NOTIFICATION_EP);
316:                if (failureNotification != null) {
317:                    value = compSched.getChildTextValue(failureNotification,
318:                            ComponentSchedule.SERVICE_NAME);
319:                    if (value != null) {
320:                        setFailureNotificationService(compSched
321:                                .prefixedNameToQName(value));
322:                    } else {
323:                        log
324:                                .error("AutoRetrySchedule - Unable to load value of '"
325:                                        + ComponentSchedule.SERVICE_NAME + "'");
326:                        return false;
327:                    }
328:                    value = compSched.getChildTextValue(failureNotification,
329:                            ComponentSchedule.ENDPOINT_NAME);
330:                    if (value != null) {
331:                        setFailureNotificationEndpoint(value);
332:                    } else {
333:                        log
334:                                .error("AutoRetrySchedule - Unable to load value of '"
335:                                        + ComponentSchedule.ENDPOINT_NAME + "'");
336:                        return false;
337:                    }
338:                }
339:                return true;
340:            }
341:
342:            /* (non-Javadoc)
343:             * @see com.bostechcorp.cbesb.runtime.scheduler.ISchedule#toJDomElement()
344:             */
345:            public Element toJDomElement(ComponentSchedule compSched) {
346:                Element autoSchedElem = compSched
347:                        .createElement(ComponentSchedule.AUTO_RETRY_SCHEDULE);
348:
349:                Element childElem = compSched
350:                        .createElement(ComponentSchedule.START_TIME);
351:                childElem.setText(startTime);
352:                autoSchedElem.addContent(childElem);
353:
354:                childElem = compSched.createElement(ComponentSchedule.END_TIME);
355:                childElem.setText(endTime);
356:                autoSchedElem.addContent(childElem);
357:
358:                childElem = compSched
359:                        .createElement(ComponentSchedule.RETRY_INTERVAL);
360:                childElem.setText(Integer.toString(retryInterval));
361:                autoSchedElem.addContent(childElem);
362:
363:                childElem = compSched
364:                        .createElement(ComponentSchedule.DAY_OF_MONTH);
365:                childElem.setText(dayOfMonth);
366:                autoSchedElem.addContent(childElem);
367:
368:                childElem = compSched.createElement(ComponentSchedule.MONTH);
369:                childElem.setText(month);
370:                autoSchedElem.addContent(childElem);
371:
372:                childElem = compSched
373:                        .createElement(ComponentSchedule.DAY_OF_WEEK);
374:                childElem.setText(dayOfWeek);
375:                autoSchedElem.addContent(childElem);
376:
377:                if (holidaySchedule != null) {
378:                    childElem = compSched
379:                            .createElement(ComponentSchedule.HOLIDAY_SCHEDULE);
380:                    childElem.setText(holidaySchedule);
381:                    autoSchedElem.addContent(childElem);
382:                }
383:
384:                if (successNotificationService != null
385:                        && successNotificationEndpoint != null) {
386:                    childElem = compSched
387:                            .createElement(ComponentSchedule.SUCCESS_NOTIFICATION_EP);
388:
389:                    Element svcElem = compSched
390:                            .createElement(ComponentSchedule.SERVICE_NAME);
391:                    svcElem.setText(compSched
392:                            .QNameToPrefixedName(successNotificationService));
393:                    childElem.addContent(svcElem);
394:
395:                    Element epElem = compSched
396:                            .createElement(ComponentSchedule.ENDPOINT_NAME);
397:                    epElem.setText(successNotificationEndpoint);
398:                    childElem.addContent(epElem);
399:
400:                    autoSchedElem.addContent(childElem);
401:                }
402:
403:                if (failureNotificationService != null
404:                        && failureNotificationEndpoint != null) {
405:                    childElem = compSched
406:                            .createElement(ComponentSchedule.FAILURE_NOTIFICATION_EP);
407:
408:                    Element svcElem = compSched
409:                            .createElement(ComponentSchedule.SERVICE_NAME);
410:                    svcElem.setText(compSched
411:                            .QNameToPrefixedName(failureNotificationService));
412:                    childElem.addContent(svcElem);
413:
414:                    Element epElem = compSched
415:                            .createElement(ComponentSchedule.ENDPOINT_NAME);
416:                    epElem.setText(failureNotificationEndpoint);
417:                    childElem.addContent(epElem);
418:
419:                    autoSchedElem.addContent(childElem);
420:                }
421:                return autoSchedElem;
422:            }
423:
424:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.