Source Code Cross Referenced for UtilsTransportServer.java in  » ESB » synapse » org » apache » synapse » transport » 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 » synapse » org.apache.synapse.transport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one
003:         *  or more contributor license agreements.  See the NOTICE file
004:         *  distributed with this work for additional information
005:         *  regarding copyright ownership.  The ASF licenses this file
006:         *  to you under the Apache License, Version 2.0 (the
007:         *  "License"); you may not use this file except in compliance
008:         *  with the License.  You may obtain a copy of the License at
009:         *
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing,
013:         *  software distributed under the License is distributed on an
014:         *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         *  KIND, either express or implied.  See the License for the
016:         *  specific language governing permissions and limitations
017:         *  under the License.
018:         */
019:
020:        package org.apache.synapse.transport;
021:
022:        import org.apache.axis2.description.*;
023:        import org.apache.axis2.Constants;
024:        import org.apache.axis2.engine.ListenerManager;
025:        import org.apache.synapse.transport.vfs.VFSTransportListener;
026:        import org.apache.axis2.context.ConfigurationContext;
027:        import org.apache.axis2.context.ConfigurationContextFactory;
028:        import org.apache.axis2.wsdl.WSDLConstants;
029:        import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
030:        import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
031:
032:        import javax.xml.namespace.QName;
033:        import java.io.File;
034:        import java.util.List;
035:        import java.util.Iterator;
036:
037:        /**
038:         * Base class for transport util servers used in unit testing
039:         */
040:        public abstract class UtilsTransportServer {
041:
042:            private ListenerManager listnMgr = null;
043:            private ConfigurationContext cfgCtx = null;
044:
045:            public void start(TransportInDescription trpInDesc,
046:                    TransportOutDescription trpDescOut) throws Exception {
047:
048:                // create a dummy repository
049:                File file = makeCleanPath("target/axis2/repository");
050:
051:                cfgCtx = ConfigurationContextFactory
052:                        .createConfigurationContextFromFileSystem(file
053:                                .getAbsolutePath());
054:
055:                // remove http transport
056:                cfgCtx.getAxisConfiguration().getTransportsIn().remove("http");
057:
058:                // start given transport
059:                listnMgr = new ListenerManager();
060:                listnMgr.init(cfgCtx);
061:                cfgCtx.setTransportManager(listnMgr);
062:                //listnMgr.addListener(trpInDesc, false);
063:
064:                trpDescOut.getSender().init(cfgCtx, trpDescOut);
065:                cfgCtx.getAxisConfiguration().addTransportOut(trpDescOut);
066:                //trpInDesc.getReceiver().init(cfgCtx, trpInDesc);        
067:                listnMgr.addListener(trpInDesc, false);
068:                listnMgr.start();
069:            }
070:
071:            public void start() throws Exception {
072:            }
073:
074:            public void stop() throws Exception {
075:                listnMgr.stop();
076:            }
077:
078:            /**
079:             * Deploy the standard Echo service with the custom parameters passed in
080:             * @param name the service name to assign
081:             * @param parameters the parameters for the service
082:             * @throws Exception
083:             */
084:            public void deployEchoService(String name, List parameters)
085:                    throws Exception {
086:
087:                AxisService service = new AxisService(name);
088:                service.setClassLoader(Thread.currentThread()
089:                        .getContextClassLoader());
090:                service.addParameter(new Parameter(Constants.SERVICE_CLASS,
091:                        Echo.class.getName()));
092:
093:                // add operation echoOMElement
094:                AxisOperation axisOp = new InOutAxisOperation(new QName(
095:                        "echoOMElement"));
096:                axisOp.setMessageReceiver(new RawXMLINOutMessageReceiver());
097:                axisOp.setStyle(WSDLConstants.STYLE_RPC);
098:                service.addOperation(axisOp);
099:                service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI
100:                        + "/echoOMElement", axisOp);
101:
102:                // add operation echoOMElementNoResponse
103:                axisOp = new InOutAxisOperation(new QName(
104:                        "echoOMElementNoResponse"));
105:                axisOp.setMessageReceiver(new RawXMLINOnlyMessageReceiver());
106:                axisOp.setStyle(WSDLConstants.STYLE_RPC);
107:                service.addOperation(axisOp);
108:                service.mapActionToOperation(Constants.AXIS2_NAMESPACE_URI
109:                        + "/echoOMElementNoResponse", axisOp);
110:
111:                Iterator iter = parameters.iterator();
112:                while (iter.hasNext()) {
113:                    service.addParameter((Parameter) iter.next());
114:                }
115:
116:                cfgCtx.getAxisConfiguration().addService(service);
117:            }
118:
119:            /**
120:             * Make sure the given path exists by creating it if required
121:             * @param path
122:             * @return
123:             * @throws Exception
124:             */
125:            protected File makePath(String path) throws Exception {
126:                File file = new File(path);
127:                if (!file.exists()) {
128:                    if (!file.mkdirs()) {
129:                        throw new Exception("Couldn't create directory : "
130:                                + file.getPath());
131:                    }
132:                }
133:                return file;
134:            }
135:
136:            /**
137:             * Delete the path if it exists and, create it
138:             * @param path
139:             * @return
140:             * @throws Exception
141:             */
142:            protected File makeCleanPath(String path) throws Exception {
143:                File file = new File(path);
144:                if (!file.exists()) {
145:                    if (!file.mkdirs()) {
146:                        throw new Exception("Couldn't create directory : "
147:                                + file.getPath());
148:                    }
149:                } else {
150:                    // delete any existing
151:                    recursivelydelete(file);
152:                    if (file.exists()) {
153:                        throw new Exception("Couldn't delete directory : "
154:                                + file.getPath());
155:                    }
156:                    if (!file.mkdirs()) {
157:                        throw new Exception("Couldn't create directory : "
158:                                + file.getPath());
159:                    }
160:                }
161:                return file;
162:            }
163:
164:            private void recursivelydelete(File file) {
165:
166:                File[] children = file.listFiles();
167:                if (children != null && children.length > 0) {
168:                    for (int i = 0; i < children.length; i++) {
169:                        recursivelydelete(children[i]);
170:                    }
171:                }
172:                file.delete();
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.