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


001:        /**
002:         * 
003:         */package com.bostechcorp.cbesb.common.util.generators;
004:
005:        import java.util.Iterator;
006:        import java.util.List;
007:        import org.jdom.Element;
008:        import org.jdom.Namespace;
009:
010:        import com.bostechcorp.cbesb.common.sa.service.AutoRetryScheduleRecord;
011:        import com.bostechcorp.cbesb.common.sa.service.StandardScheduleRecord;
012:
013:        /**
014:         * @author LPS
015:         *
016:         */
017:
018:        public class ComponentScheduleXMLGenerator extends AbstractDOMGenerator {
019:            private int namespacePrefixIndex = 0;
020:
021:            private String namespacePrefixtext = "nspf";
022:
023:            private static String COMPONENT_SCHEDULE_T = "componentSchedule";
024:
025:            private static String STANDARD_SCHEDULE_T = "standardSchedule";
026:
027:            private static String SECONDS_T = "seconds";
028:
029:            private static String MINUTES_T = "minutes";
030:
031:            private static String HOURS_T = "hours";
032:
033:            private static String DAY_OF_MONTH_T = "dayOfMonth";
034:
035:            private static String MONTH_T = "month";
036:
037:            private static String DAY_OF_WEEK_T = "dayOfWeek";
038:
039:            private static String HOLIDAY_SCHEDULE_T = "holidaySchedule";
040:
041:            private static String AUTO_RETRY_SCHEDULE_T = "autoRetrySchedule";
042:
043:            private static String START_TIME_T = "startTime";
044:
045:            private static String END_TIME_T = "endTime";
046:
047:            private static String RETRY_INTERVAL_T = "retryInterval";
048:
049:            private static String FAILURE_NOTIFICATION_EP_T = "failureNotificationEP";
050:
051:            private static String SERVICE_NAME_T = "serviceName";
052:
053:            private static String ENDPOINT_NAME_T = "endpointName";
054:
055:            private static String SUCCESS_NOTIFICATION_EP_T = "successNotificationEP";
056:
057:            private static String URI_CONSTANT_STRING = "http://bostechcorp.com/SU/";
058:
059:            //
060:            private String saName = "";
061:
062:            private String suName = "";
063:
064:            private String fileNameEnding = "schedule.xml";
065:
066:            public ComponentScheduleXMLGenerator(String path, String saName,
067:                    String suName) {
068:                super (path);
069:                this .saName = saName;
070:                this .suName = suName;
071:            }
072:
073:            /* (non-Javadoc)
074:             * @see com.bostechcorp.cbesb.common.util.AbstractDOMGenerator#buildDocumentStructure()
075:             */
076:            @Override
077:            protected void buildDocumentStructure() {
078:                rootElement = jdomFactory.element(COMPONENT_SCHEDULE_T);
079:                rootElement
080:                        .setNamespace(Namespace
081:                                .getNamespace("http://cbesb.bostechcorp.com/scheduler/1.0"));
082:            }
083:
084:            public void setSchedulues(
085:                    List<StandardScheduleRecord> standardSchedules,
086:                    List<AutoRetryScheduleRecord> autoRetrySchedules) {
087:                setStandardSchedules(standardSchedules);
088:                setAutoRetrySchedules(autoRetrySchedules);
089:            }
090:
091:            private void setAutoRetrySchedules(
092:                    List<AutoRetryScheduleRecord> autoRetrySchedules) {
093:                for (Object object : autoRetrySchedules) {
094:                    if (object instanceof  AutoRetryScheduleRecord) {
095:                        AutoRetryScheduleRecord autoRetrySchedule = (AutoRetryScheduleRecord) object;
096:                        //adding node to the XML schema
097:                        Element autoRetryElement = jdomFactory
098:                                .element(AUTO_RETRY_SCHEDULE_T);
099:                        rootElement.addContent(autoRetryElement);
100:                        autoRetryElement.addContent(jdomFactory.element(
101:                                START_TIME_T).addContent(
102:                                autoRetrySchedule.getStartTime()));
103:                        autoRetryElement.addContent(jdomFactory.element(
104:                                END_TIME_T).addContent(
105:                                autoRetrySchedule.getEndTime()));
106:                        autoRetryElement.addContent(jdomFactory.element(
107:                                RETRY_INTERVAL_T).addContent(
108:                                autoRetrySchedule.getRetryInterval()));
109:                        autoRetryElement.addContent(jdomFactory.element(
110:                                DAY_OF_MONTH_T).addContent(
111:                                autoRetrySchedule.getDayOfMonth()));
112:                        autoRetryElement.addContent(jdomFactory
113:                                .element(MONTH_T).addContent(
114:                                        autoRetrySchedule.getMonth()));
115:                        autoRetryElement.addContent(jdomFactory.element(
116:                                DAY_OF_WEEK_T).addContent(
117:                                autoRetrySchedule.getDayOfWeek()));
118:
119:                        if (!autoRetrySchedule.getHoliday().contains("None")) {
120:                            autoRetryElement.addContent(jdomFactory.element(
121:                                    HOLIDAY_SCHEDULE_T).addContent(
122:                                    autoRetrySchedule.getHoliday()));
123:                        }
124:                        if (autoRetrySchedule
125:                                .getSuccessNotificationServiceName() != null
126:                                && autoRetrySchedule
127:                                        .getSuccessNotificationServiceName()
128:                                        .indexOf("none") < 0) {
129:                            Namespace ns = getNamespaceDeclaration(autoRetrySchedule
130:                                    .getSuccessNotificationSuName());
131:                            Element messagElement = jdomFactory
132:                                    .element(SUCCESS_NOTIFICATION_EP_T);
133:
134:                            messagElement
135:                                    .addContent(jdomFactory
136:                                            .element(SERVICE_NAME_T)
137:                                            .addContent(
138:                                                    ns.getPrefix()
139:                                                            + ":"
140:                                                            + autoRetrySchedule
141:                                                                    .getSuccessNotificationServiceName()));
142:                            messagElement
143:                                    .addContent(jdomFactory
144:                                            .element(ENDPOINT_NAME_T)
145:                                            .addContent(
146:                                                    autoRetrySchedule
147:                                                            .getSuccessNotificationEndpointName()));
148:                            //also setting the Namespace
149:
150:                            if (rootElement.getNamespace(ns.getPrefix()) == null) {
151:                                rootElement.addNamespaceDeclaration(ns);
152:                            }
153:
154:                            autoRetryElement.addContent(messagElement);
155:
156:                        }
157:                        if (autoRetrySchedule
158:                                .getFailureNotificationServiceName() != null
159:                                && autoRetrySchedule
160:                                        .getFailureNotificationServiceName()
161:                                        .indexOf("none") < 0) {
162:                            Namespace ns = getNamespaceDeclaration(autoRetrySchedule
163:                                    .getFailureNotificationSuName());
164:
165:                            Element messagElement = jdomFactory
166:                                    .element(FAILURE_NOTIFICATION_EP_T);
167:
168:                            messagElement
169:                                    .addContent(jdomFactory
170:                                            .element(SERVICE_NAME_T)
171:                                            .addContent(
172:                                                    ns.getPrefix()
173:                                                            + ":"
174:                                                            + autoRetrySchedule
175:                                                                    .getFailureNotificationServiceName()));
176:                            messagElement
177:                                    .addContent(jdomFactory
178:                                            .element(ENDPOINT_NAME_T)
179:                                            .addContent(
180:                                                    autoRetrySchedule
181:                                                            .getFailureNotificationEndpointName()));
182:                            //also setting the Namespace
183:
184:                            if (rootElement.getNamespace(ns.getPrefix()) == null) {
185:                                rootElement.addNamespaceDeclaration(ns);
186:                            }
187:                            autoRetryElement.addContent(messagElement);
188:
189:                        }
190:                    }
191:                }
192:            }
193:
194:            private Namespace getNamespaceDeclaration(String suName) {
195:                String prefixString = "";
196:                // test wether the namespace exist
197:                List l = rootElement.getAdditionalNamespaces();
198:                for (Iterator nsIter = l.iterator(); nsIter.hasNext();) {
199:                    Object nsObject = nsIter.next();
200:                    if (nsObject instanceof  Namespace) {
201:                        Namespace nsElement = (Namespace) nsObject;
202:                        if (nsElement.getURI().equals(
203:                                URI_CONSTANT_STRING + suName)) {
204:                            return nsElement;
205:                        }
206:                    }
207:                }
208:                prefixString = namespacePrefixtext + namespacePrefixIndex;
209:                namespacePrefixIndex++;
210:                String uriString = URI_CONSTANT_STRING + suName;
211:                return Namespace.getNamespace(prefixString, uriString);
212:            }
213:
214:            private void setStandardSchedules(
215:                    List<StandardScheduleRecord> standardSchedules) {
216:                for (Object object : standardSchedules) {
217:                    if (object instanceof  StandardScheduleRecord) {
218:                        StandardScheduleRecord autoRetrySchedule = (StandardScheduleRecord) object;
219:                        // adding node to the XML schema
220:                        Element standardScheduleElement = jdomFactory
221:                                .element(STANDARD_SCHEDULE_T);
222:                        rootElement.addContent(standardScheduleElement);
223:                        standardScheduleElement.addContent(jdomFactory.element(
224:                                SECONDS_T).addContent(
225:                                autoRetrySchedule.getSeconds()));
226:                        standardScheduleElement.addContent(jdomFactory.element(
227:                                MINUTES_T).addContent(
228:                                autoRetrySchedule.getMinutes()));
229:                        standardScheduleElement.addContent(jdomFactory.element(
230:                                HOURS_T).addContent(
231:                                autoRetrySchedule.getHours()));
232:                        standardScheduleElement.addContent(jdomFactory.element(
233:                                DAY_OF_MONTH_T).addContent(
234:                                autoRetrySchedule.getDayOfMonth()));
235:                        standardScheduleElement.addContent(jdomFactory.element(
236:                                MONTH_T).addContent(
237:                                autoRetrySchedule.getMonth()));
238:                        standardScheduleElement.addContent(jdomFactory.element(
239:                                DAY_OF_WEEK_T).addContent(
240:                                autoRetrySchedule.getDayOfWeek()));
241:                        if (!autoRetrySchedule.getHoliday().contains("None")) {
242:                            standardScheduleElement.addContent(jdomFactory
243:                                    .element(HOLIDAY_SCHEDULE_T).addContent(
244:                                            autoRetrySchedule.getHoliday()));
245:                        }
246:                    }
247:                }
248:            }
249:
250:            /* (non-Javadoc)
251:             * @see com.bostechcorp.cbesb.common.util.AbstractDOMGenerator#getFileOut()
252:             */
253:            @Override
254:            protected String getFileOut() {
255:                if (this .filePath.endsWith("/")) {
256:                    return filePath + saName + "_" + suName + "_"
257:                            + fileNameEnding;
258:                } else {
259:                    return filePath + "/" + saName + "_" + suName + "_"
260:                            + fileNameEnding;
261:                }
262:            }
263:
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.