Source Code Cross Referenced for Repository.java in  » Web-Services » wsif » com » myeis » repository » 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 » Web Services » wsif » com.myeis.repository 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         *
005:         * Copyright (c) 2002 The Apache Software Foundation.  All rights 
006:         * reserved.
007:         *
008:         * Redistribution and use in source and binary forms, with or without
009:         * modification, are permitted provided that the following conditions
010:         * are met:
011:         *
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions and the following disclaimer. 
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions and the following disclaimer in
017:         *    the documentation and/or other materials provided with the
018:         *    distribution.
019:         *
020:         * 3. The end-user documentation included with the redistribution,
021:         *    if any, must include the following acknowledgment:  
022:         *       "This product includes software developed by the
023:         *        Apache Software Foundation (http://www.apache.org/)."
024:         *    Alternately, this acknowledgment may appear in the software itself,
025:         *    if and wherever such third-party acknowledgments normally appear.
026:         *
027:         * 4. The names "WSIF" and "Apache Software Foundation" must
028:         *    not be used to endorse or promote products derived from this
029:         *    software without prior written permission. For written 
030:         *    permission, please contact apache@apache.org.
031:         *
032:         * 5. Products derived from this software may not be called "Apache",
033:         *    nor may "Apache" appear in their name, without prior written
034:         *    permission of the Apache Software Foundation.
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         * ====================================================================
049:         *
050:         * This software consists of voluntary contributions made by many
051:         * individuals on behalf of the Apache Software Foundation and was
052:         * originally based on software copyright (c) 2001, 2002, International
053:         * Business Machines, Inc., http://www.apache.org.  For more
054:         * information on the Apache Software Foundation, please see
055:         * <http://www.apache.org/>.
056:         */
057:
058:        package com.myeis.repository;
059:
060:        import java.io.InputStream;
061:        import java.io.StringReader;
062:        import java.util.*;
063:
064:        import javax.wsdl.*;
065:        import javax.xml.namespace.QName;
066:
067:        import org.apache.wsif.base.WSIFServiceImpl;
068:        import org.apache.wsif.providers.jca.toolplugin.*;
069:        import org.apache.wsif.util.WSIFUtils;
070:
071:        import com.ibm.wsdl.PortTypeImpl;
072:        import com.myeis.wsdl.extensions.j2c.myeis.MyEISExtensionRegistry;
073:        import com.ibm.wsdl.xml.*;
074:
075:        public class Repository {
076:
077:            public PortTypeArray getPortTypes(String queryString) {
078:                /*
079:                 * If the back end exposes business functions that allow the browsing of the metadata then getting the port types can
080:                 * be delegated directly. In this sample, the metadata is represented by the two WSDL files (CustomerInfo and PurchaseOrderInfo).
081:                 * Hence, we simply retrieve those files and return their corresponding port types.
082:                 */
083:                ArrayList portTypes = new ArrayList();
084:                try {
085:                    WSIFServiceImpl
086:                            .addExtensionRegistry(new MyEISExtensionRegistry());
087:                    WSIFServiceImpl
088:                            .addExtensionRegistry(new org.apache.wsif.wsdl.extensions.format.FormatExtensionRegistry());
089:                    WSIFServiceImpl
090:                            .addExtensionRegistry(new org.apache.wsif.wsdl.extensions.java.JavaExtensionRegistry());
091:                    // load all definitions
092:                    ArrayList definitions = new ArrayList();
093:                    Definition definition = WSIFUtils.readWSDL(null,
094:                            "com/myeis/services/CustomerInfo.wsdl", this 
095:                                    .getClass().getClassLoader());
096:                    definitions.add(definition);
097:                    definition = WSIFUtils.readWSDL(null,
098:                            "com/myeis/services/PurchaseOrderInfo.wsdl", this 
099:                                    .getClass().getClassLoader());
100:                    definitions.add(definition);
101:
102:                    Iterator definitionIterator = definitions.iterator();
103:                    while (definitionIterator.hasNext()) {
104:                        definition = (Definition) definitionIterator.next();
105:                        Iterator portTypeIterator = definition.getPortTypes()
106:                                .values().iterator();
107:                        while (portTypeIterator.hasNext()) {
108:                            PortType portType = (PortType) portTypeIterator
109:                                    .next();
110:                            if ((queryString.equals(""))
111:                                    || (queryString.equals("*"))
112:                                    || (portType.getQName().getLocalPart()
113:                                            .indexOf(queryString) != -1)) {
114:                                portTypes.add(portType);
115:                            }
116:                        }
117:                    }
118:                } catch (Exception e) {
119:                    e.printStackTrace();
120:                }
121:
122:                PortType[] portTypeA = new PortType[portTypes.size()];
123:                portTypes.toArray(portTypeA);
124:                PortTypeArray portTypeArray = new PortTypeArray();
125:                portTypeArray.setPortTypes(portTypeA);
126:
127:                return portTypeArray;
128:            }
129:
130:            public ImportDefinition getDefinition(
131:                    PortTypeSelection portTypeSelection) {
132:                /*
133:                 * If the back end exposes business functions that allow the browsing of the metadata then getting the definitions can
134:                 * be delegated directly. In this sample, the metadata is represented by the two WSDL files (CustomerInfo and PurchaseOrderInfo).
135:                 * Hence, we simply retrieve those files and filter their corresponding port types and operations based on the selection passed in.
136:                 */
137:                ArrayList importDefinitions = new ArrayList();
138:                ArrayList importDefinitionsResult = new ArrayList();
139:                try {
140:                    WSIFServiceImpl
141:                            .addExtensionRegistry(new MyEISExtensionRegistry());
142:                    WSIFServiceImpl
143:                            .addExtensionRegistry(new org.apache.wsif.wsdl.extensions.format.FormatExtensionRegistry());
144:                    WSIFServiceImpl
145:                            .addExtensionRegistry(new org.apache.wsif.wsdl.extensions.java.JavaExtensionRegistry());
146:                    // load all definitions
147:                    ImportDefinition importDefinition = new ImportDefinition();
148:                    importDefinition.setDefinition(WSIFUtils.readWSDL(null,
149:                            "com/myeis/services/CustomerInfo.wsdl", this 
150:                                    .getClass().getClassLoader()));
151:
152:                    ImportResource[] importResources = new ImportResource[1];
153:                    ImportResource importResource = new ImportResource();
154:                    importResource
155:                            .setLocation("com/myeis/services/MyEISFormatHandlerGenMetaData.eis");
156:                    String metaData = "MyEIS Resource Adapter version 1.0 meta data";
157:                    importResource.setContents(metaData.getBytes());
158:                    importResources[0] = importResource;
159:
160:                    ImportXSD[] importXSDs = new ImportXSD[1];
161:                    ImportXSD importXSD = new ImportXSD();
162:                    importXSD.setNamespace("http://services.myeis.ibm.com/");
163:                    importXSD
164:                            .setLocation("com/myeis/services/CustomerInfo.xsd");
165:
166:                    InputStream inputStream = this .getClass().getClassLoader()
167:                            .getResourceAsStream(
168:                                    "com/myeis/services/CustomerInfo.xsd");
169:                    byte[] inputBytes = new byte[inputStream.available()];
170:                    inputStream.read(inputBytes);
171:                    importXSD.setSource(new String(inputBytes));
172:
173:                    importXSDs[0] = importXSD;
174:                    importDefinition.setImportXSDs(importXSDs);
175:                    importDefinitions.add(importDefinition);
176:
177:                    importDefinition = new ImportDefinition();
178:                    importDefinition.setDefinition(WSIFUtils.readWSDL(null,
179:                            "com/myeis/services/PurchaseOrderInfo.wsdl", this 
180:                                    .getClass().getClassLoader()));
181:                    importXSDs = new ImportXSD[1];
182:                    importXSD = new ImportXSD();
183:                    importXSD.setNamespace("http://services.myeis.ibm.com/");
184:                    importXSD
185:                            .setLocation("com/myeis/services/PurchaseOrderInfo.xsd");
186:
187:                    inputStream = this .getClass().getClassLoader()
188:                            .getResourceAsStream(
189:                                    "com/myeis/services/PurchaseOrderInfo.xsd");
190:                    inputBytes = new byte[inputStream.available()];
191:                    inputStream.read(inputBytes);
192:                    importXSD.setSource(new String(inputBytes));
193:
194:                    importXSDs[0] = importXSD;
195:                    importDefinition.setImportXSDs(importXSDs);
196:                    importDefinition.setImportResources(importResources);
197:                    importDefinitions.add(importDefinition);
198:
199:                    for (int j = 0; j < importDefinitions.size(); j++) {
200:                        if (((ImportDefinition) importDefinitions.get(j))
201:                                .getDefinition().getPortTypes().containsKey(
202:                                        portTypeSelection.getPortTypeQName())) {
203:
204:                            ImportDefinition returnDefinition = (ImportDefinition) importDefinitions
205:                                    .get(j);
206:                            Definition def = returnDefinition.getDefinition();
207:
208:                            //Adjust the import statements to be relative paths
209:                            Iterator importIter = def.getImports().values()
210:                                    .iterator();
211:                            while (importIter.hasNext()) {
212:                                List imports = (List) importIter.next();
213:                                Iterator listIterator = imports.iterator();
214:                                while (listIterator.hasNext()) {
215:                                    javax.wsdl.Import imp = (javax.wsdl.Import) listIterator
216:                                            .next();
217:                                    if (imp.getLocationURI().startsWith(
218:                                            "/com/myeis/services/")) {
219:                                        imp.setLocationURI("."
220:                                                + imp.getLocationURI());
221:                                    }
222:                                }
223:
224:                            }
225:                            //Remove all the portTypes that were not part of the selection
226:
227:                            Iterator iter = def.getPortTypes().keySet()
228:                                    .iterator();
229:                            List unusedPortTypes = new ArrayList();
230:                            PortType selectedPortType = null;
231:                            while (iter.hasNext()) {
232:                                QName portTypeQName = (QName) iter.next();
233:                                if (!portTypeQName.equals(portTypeSelection
234:                                        .getPortTypeQName())) {
235:                                    unusedPortTypes.add(portTypeQName);
236:                                } else {
237:                                    selectedPortType = def
238:                                            .getPortType(portTypeQName);
239:                                }
240:                            }
241:                            iter = unusedPortTypes.iterator();
242:                            while (iter.hasNext()) {
243:                                def.removePortType((QName) iter.next());
244:                            }
245:
246:                            //Remove all the operations that were not part of the selection
247:                            List operationList = selectedPortType
248:                                    .getOperations();
249:                            List selectedOperationsList = new ArrayList();
250:                            for (int index = 0; index < portTypeSelection
251:                                    .getOperationSelection().length; index++) {
252:                                OperationSelection selection = portTypeSelection
253:                                        .getOperationSelection()[index];
254:                                Operation op = selectedPortType.getOperation(
255:                                        selection.getOperationName(), selection
256:                                                .getInputName(), selection
257:                                                .getOutputName());
258:                                if (op != null) {
259:                                    selectedOperationsList.add(op);
260:                                }
261:                            }
262:
263:                            iter = operationList.iterator();
264:                            List unusedOperationsList = new ArrayList();
265:
266:                            while (iter.hasNext()) {
267:                                Operation op = (Operation) iter.next();
268:                                if (!selectedOperationsList.contains(op)) {
269:                                    unusedOperationsList.add(op);
270:                                }
271:                            }
272:
273:                            iter = unusedOperationsList.iterator();
274:                            while (iter.hasNext()) {
275:                                Operation op = (Operation) iter.next();
276:                                operationList.remove(op);
277:                                Iterator bindingIterator = def.getBindings()
278:                                        .values().iterator();
279:                                while (bindingIterator.hasNext()) {
280:                                    Binding binding = (Binding) bindingIterator
281:                                            .next();
282:                                    String inputName = null;
283:                                    if (op.getInput() != null)
284:                                        inputName = op.getInput().getName();
285:
286:                                    String outputName = null;
287:                                    if (op.getOutput() != null)
288:                                        outputName = op.getOutput().getName();
289:                                    BindingOperation bindingOp = binding
290:                                            .getBindingOperation(op.getName(),
291:                                                    inputName, outputName);
292:                                    if (bindingOp != null)
293:                                        binding.getBindingOperations().remove(
294:                                                bindingOp);
295:                                }
296:                            }
297:
298:                            return returnDefinition;
299:                        }
300:                    }
301:                    //			}
302:                } catch (Exception e) {
303:                    e.printStackTrace();
304:                }
305:                return null;
306:            }
307:
308:            public byte[] getRawEISMetaData(String queryString) {
309:                /*
310:                 * This method is just for illustrative purposes, to demonstrate how an EIS can return a proprietary metadata format.
311:                 * This metadata can be cached in tool environments for performance improvements if several services are to be imported from 
312:                 * the same EIS system.
313:                 */
314:                String customerInfoData = "PortType: CustomerInfo\n Operation: getAddress\n Operation: getCustomer\n";
315:                String purchaseOrderData = "PortType: PurchaseOrderInfo\n Operation: getPurchaseOrder\n";
316:                String result = new String();
317:                if ((queryString.equals("")) || (queryString.equals("*"))) {
318:                    result = customerInfoData + purchaseOrderData;
319:
320:                } else {
321:                    if ("CustomerInfo".indexOf(queryString) != -1) {
322:                        result = result + customerInfoData;
323:                    }
324:                    if ("PurchaseOrderInfo".indexOf(queryString) != -1) {
325:                        result = result + purchaseOrderData;
326:                    }
327:
328:                }
329:                return result.getBytes();
330:            }
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.