Source Code Cross Referenced for ServiceAssemblyDOMJbiXMLGenerator.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:         * ChainBuilder ESB
003:         * 		Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 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:$
023:         * 
024:         */
025:        package com.bostechcorp.cbesb.common.util.generators;
026:
027:        import java.util.HashMap;
028:        import java.util.Iterator;
029:        import java.util.Vector;
030:
031:        import org.jdom.Element;
032:        import org.jdom.Namespace;
033:
034:        import com.bostechcorp.cbesb.common.sa.component.AbstractComponent;
035:        import com.bostechcorp.cbesb.common.sa.component.CBRComponent;
036:        import com.bostechcorp.cbesb.common.sa.component.SequencerComponent;
037:        import com.bostechcorp.cbesb.common.sa.service.Connection;
038:
039:        /**
040:         * @author LPS
041:         * 
042:         */
043:        public class ServiceAssemblyDOMJbiXMLGenerator extends
044:                AbstractDOMGenerator {
045:
046:            private final String FILENAME = "/META-INF/jbi.xml";
047:
048:            // tags
049:            private final String JBI_T = "jbi";
050:            private final String JBI_VERSION_A = "version";
051:
052:            private final String SERVICE_ASSEMBLY_T = "service-assembly";
053:            private final String SERVICE_UNIT_T = "service-unit";
054:            private final String IDENTIFICATION_T = "identification";
055:            private final String NAME_T = "name";
056:            private final String DESCRIPTION_T = "description";
057:            private final String TARGET_T = "target";
058:            private final String ARTIFACTS_ZIP_T = "artifacts-zip";
059:            private final String COMPONENTS_NAME_T = "component-name";
060:
061:            private final String CONNECTIONS_T = "connections";
062:            private final String CONNECTION_T = "connection";
063:            private final String CONSUMER_T = "consumer";
064:            private final String SERVICE_NAME_A = "service-name";
065:            private final String ENDPOINT_NAME_A = "endpoint-name";
066:            private final String PROVIDER_T = "provider";
067:            private final String JBI_NAMESPACE_NS = "http://java.sun.com/xml/ns/jbi";
068:
069:            //
070:            Element serviceAssembly;
071:
072:            Element connectionsElement;
073:
074:            //
075:            private String saName = "";
076:
077:            private String saDescription = "";
078:
079:            //
080:            public ServiceAssemblyDOMJbiXMLGenerator(String path,
081:                    String saName, String saDescription) {
082:                super (path);
083:                this .saName = saName;
084:                this .saDescription = saDescription;
085:            }
086:
087:            /*
088:             * (non-Javadoc)
089:             * 
090:             * @see com.bostechcorp.cbesb.common.util.AbstractDOMGenerator#buildDocumentStructure()
091:             */
092:            @Override
093:            protected void buildDocumentStructure() {
094:                rootElement = jdomFactory.element(JBI_T);
095:                rootElement.setAttribute(JBI_VERSION_A, "1.0");
096:                serviceAssembly = jdomFactory.element(SERVICE_ASSEMBLY_T);
097:                rootElement.addContent(serviceAssembly);
098:            }
099:
100:            public void setContentFromLists(
101:                    Vector<AbstractComponent> componentList,
102:                    Vector<Connection> connections,
103:                    HashMap<String, AbstractComponent> componentMap) {
104:                //setting identification
105:                Element identification = jdomFactory.element(IDENTIFICATION_T);
106:                Element iname = jdomFactory.element(NAME_T);
107:                iname.addContent(saName);
108:                Element idescription = jdomFactory.element(DESCRIPTION_T);
109:                idescription.addContent(saDescription);
110:                identification.addContent(iname);
111:                identification.addContent(idescription);
112:                serviceAssembly.addContent(identification);
113:                //setting the rest of .. 
114:                setJbiNamespaces(componentList);
115:                setServiceUnits(componentList);
116:                setConnections(componentList, connections, componentMap);
117:            }
118:
119:            private void setConnections(
120:                    Vector<AbstractComponent> componentList,
121:                    Vector<Connection> connections,
122:                    HashMap<String, AbstractComponent> componentMap) {
123:                connectionsElement = jdomFactory.element(CONNECTIONS_T);
124:                serviceAssembly.addContent(connectionsElement);
125:
126:                Iterator connectionIt = connections.iterator();
127:                while (connectionIt.hasNext()) {
128:                    Connection connection = (Connection) connectionIt.next();
129:                    AbstractComponent consumer = (AbstractComponent) componentMap
130:                            .get(connection.getConsumerName());
131:                    AbstractComponent provider = (AbstractComponent) componentMap
132:                            .get(connection.getProviderName());
133:                    if ((consumer != null)
134:                            && (consumer instanceof  SequencerComponent))
135:                        continue;
136:                    if ((consumer != null)
137:                            && (consumer instanceof  CBRComponent))
138:                        continue;
139:
140:                    Element connectionElement = jdomFactory
141:                            .element(CONNECTION_T);
142:
143:                    if (consumer != null) {
144:                        String serviceName = consumer
145:                                .getServiceNameByRole(true);
146:                        String endpointName = consumer
147:                                .getConsumerEndpointName();
148:
149:                        Element consumerElement = jdomFactory
150:                                .element(CONSUMER_T);
151:                        consumerElement.setAttribute(SERVICE_NAME_A, "su"
152:                                + (consumer.getServiceUnitNumber() + 1) + ":"
153:                                + saName + "_" + serviceName);
154:                        consumerElement.setAttribute(ENDPOINT_NAME_A, saName
155:                                + "_" + endpointName);
156:
157:                        connectionElement.addContent(consumerElement);
158:                    }
159:                    if (provider != null) {
160:                        String serviceName = provider
161:                                .getServiceNameByRole(false);
162:                        String endpointName = provider
163:                                .getProviderEndpointName();
164:
165:                        Element providerElement = jdomFactory
166:                                .element(PROVIDER_T);
167:                        providerElement.setAttribute(SERVICE_NAME_A, "su"
168:                                + (provider.getServiceUnitNumber() + 1) + ":"
169:                                + saName + "_" + serviceName);
170:                        providerElement.setAttribute(ENDPOINT_NAME_A, saName
171:                                + "_" + endpointName);
172:                        connectionElement.addContent(providerElement);
173:                    }
174:                    this .connectionsElement.addContent(connectionElement);
175:                }
176:            }
177:
178:            private void setServiceUnits(Vector<AbstractComponent> componentList) {
179:                Iterator componentIt = componentList.iterator();
180:                while (componentIt.hasNext()) {
181:                    AbstractComponent component = (AbstractComponent) componentIt
182:                            .next();
183:
184:                    Element serviceunit = jdomFactory.element(SERVICE_UNIT_T);
185:                    serviceAssembly.addContent(serviceunit);
186:
187:                    //identification
188:                    Element identification = jdomFactory
189:                            .element(IDENTIFICATION_T);
190:                    Element iname = jdomFactory.element(NAME_T);
191:                    iname.addContent(saName + "_" + component.getName());
192:                    Element idescription = jdomFactory.element(DESCRIPTION_T);
193:                    idescription.addContent(component.getDescription());
194:                    identification.addContent(iname);
195:                    identification.addContent(idescription);
196:
197:                    //target
198:                    Element target = jdomFactory.element(TARGET_T);
199:                    Element artifacts = jdomFactory.element(ARTIFACTS_ZIP_T);
200:                    artifacts.addContent(saName + "_" + component.getName()
201:                            + ".zip");
202:                    Element componentNameT = jdomFactory
203:                            .element(COMPONENTS_NAME_T);
204:                    componentNameT.addContent(component.getComponentName());
205:                    target.addContent(artifacts);
206:                    target.addContent(componentNameT);
207:                    //
208:
209:                    serviceunit.addContent(identification);
210:                    serviceunit.addContent(target);
211:                }
212:
213:            }
214:
215:            private void setJbiNamespaces(
216:                    Vector<AbstractComponent> componentList) {
217:                rootElement.setNamespace(Namespace
218:                        .getNamespace(JBI_NAMESPACE_NS));
219:                if (componentList.size() > 0)
220:                    for (int i = 1; i <= componentList.size(); i++) {
221:                        AbstractComponent component = (AbstractComponent) componentList
222:                                .get(i - 1);
223:                        component.setServiceUnitNumber(i - 1);
224:
225:                        rootElement.addNamespaceDeclaration(Namespace
226:                                .getNamespace("su" + i,
227:                                        "http://bostechcorp.com/SU/" + saName
228:                                                + "_" + component.getName()));
229:                    }
230:
231:            }
232:
233:            /*
234:             * (non-Javadoc)
235:             * 
236:             * @see com.bostechcorp.cbesb.common.util.AbstractDOMGenerator#getFileOut()
237:             */
238:            @Override
239:            protected String getFileOut() {
240:                return filePath + FILENAME;
241:            }
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.