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


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.servicemix.saxon;
018:
019:        import java.io.File;
020:        import java.io.IOException;
021:        import java.net.URI;
022:        import java.net.URL;
023:        import java.util.Iterator;
024:        import java.util.Map;
025:
026:        import javax.jbi.messaging.MessageExchange;
027:        import javax.jbi.messaging.NormalizedMessage;
028:        import javax.xml.parsers.DocumentBuilder;
029:
030:        import org.w3c.dom.Document;
031:
032:        import net.sf.saxon.Configuration;
033:
034:        import org.apache.servicemix.common.endpoints.ProviderEndpoint;
035:        import org.apache.servicemix.expression.Expression;
036:        import org.apache.servicemix.jbi.jaxp.SourceTransformer;
037:        import org.springframework.core.io.DefaultResourceLoader;
038:        import org.springframework.core.io.FileSystemResource;
039:        import org.springframework.core.io.Resource;
040:        import org.springframework.core.io.UrlResource;
041:
042:        public abstract class SaxonEndpoint extends ProviderEndpoint {
043:
044:            public static final String RESULT_BYTES = "bytes";
045:            public static final String RESULT_STRING = "string";
046:            public static final String RESULT_DOM = "dom";
047:
048:            private Configuration configuration;
049:            private boolean copyProperties = true;
050:            private boolean copyAttachments = true;
051:            private boolean copySubject = true;
052:            private String result = RESULT_DOM;
053:            private Resource resource;
054:            private Expression expression;
055:            private Resource wsdlResource;
056:            private SourceTransformer sourceTransformer = new SourceTransformer();
057:            private Map parameters;
058:
059:            /**
060:             * @param sourceTransformer the sourceTransformer to set
061:             */
062:            protected void setSourceTransformer(
063:                    SourceTransformer sourceTransformer) {
064:                this .sourceTransformer = sourceTransformer;
065:            }
066:
067:            /**
068:             * @return the sourceTransformer
069:             */
070:            public SourceTransformer getSourceTransformer() {
071:                return sourceTransformer;
072:            }
073:
074:            /**
075:             * @return the wsdlResource
076:             */
077:            public Resource getWsdlResource() {
078:                return wsdlResource;
079:            }
080:
081:            /**
082:             * @param wsdlResource the wsdlResource to set
083:             */
084:            public void setWsdlResource(Resource wsdlResource) {
085:                this .wsdlResource = wsdlResource;
086:            }
087:
088:            /**
089:             * @return the expression
090:             */
091:            public Expression getExpression() {
092:                return expression;
093:            }
094:
095:            /**
096:             * @param expression the expression to set
097:             */
098:            public void setExpression(Expression expression) {
099:                this .expression = expression;
100:            }
101:
102:            /**
103:             * @return the resource
104:             */
105:            public Resource getResource() {
106:                return resource;
107:            }
108:
109:            /**
110:             * @param resource the resource to set
111:             */
112:            public void setResource(Resource resource) {
113:                this .resource = resource;
114:            }
115:
116:            /**
117:             * @return the result
118:             */
119:            public String getResult() {
120:                return result;
121:            }
122:
123:            /**
124:             * @param result the result to set
125:             */
126:            public void setResult(String result) {
127:                this .result = result;
128:            }
129:
130:            /**
131:             * @return the configuration
132:             */
133:            public Configuration getConfiguration() {
134:                return configuration;
135:            }
136:
137:            /**
138:             * @param configuration the configuration to set
139:             */
140:            public void setConfiguration(Configuration configuration) {
141:                this .configuration = configuration;
142:            }
143:
144:            /**
145:             * @return the copyAttachments
146:             */
147:            public boolean isCopyAttachments() {
148:                return copyAttachments;
149:            }
150:
151:            /**
152:             * @param copyAttachments the copyAttachments to set
153:             */
154:            public void setCopyAttachments(boolean copyAttachments) {
155:                this .copyAttachments = copyAttachments;
156:            }
157:
158:            /**
159:             * @return the copyProperties
160:             */
161:            public boolean isCopyProperties() {
162:                return copyProperties;
163:            }
164:
165:            /**
166:             * @param copyProperties the copyProperties to set
167:             */
168:            public void setCopyProperties(boolean copyProperties) {
169:                this .copyProperties = copyProperties;
170:            }
171:
172:            /**
173:             * @return the copySubject
174:             */
175:            public boolean isCopySubject() {
176:                return copySubject;
177:            }
178:
179:            /**
180:             * @param copySubject the copySubject to set
181:             */
182:            public void setCopySubject(boolean copySubject) {
183:                this .copySubject = copySubject;
184:            }
185:
186:            /**
187:             * @return the parameters
188:             */
189:            public Map getParameters() {
190:                return parameters;
191:            }
192:
193:            /**
194:             * @param parameters the parameters to set
195:             */
196:            public void setParameters(Map parameters) {
197:                this .parameters = parameters;
198:            }
199:
200:            // Interface methods
201:            // -------------------------------------------------------------------------
202:
203:            public void activate() throws Exception {
204:                if (wsdlResource != null) {
205:                    setDescription(parse(wsdlResource));
206:                }
207:                super .activate();
208:            }
209:
210:            // Implementation methods
211:            // -------------------------------------------------------------------------
212:
213:            /**
214:             * Transform the content and send it back
215:             */
216:            protected void processInOut(MessageExchange exchange,
217:                    NormalizedMessage in, NormalizedMessage out)
218:                    throws Exception {
219:                copyPropertiesAndAttachments(in, out);
220:                transform(exchange, in, out);
221:            }
222:
223:            /**
224:             * If enabled the properties and attachments are copied to the destination message
225:             */
226:            protected void copyPropertiesAndAttachments(
227:                    NormalizedMessage source, NormalizedMessage dest)
228:                    throws Exception {
229:                if (isCopyProperties()) {
230:                    for (Iterator it = source.getPropertyNames().iterator(); it
231:                            .hasNext();) {
232:                        String name = (String) it.next();
233:                        dest.setProperty(name, source.getProperty(name));
234:                    }
235:                }
236:                if (isCopyAttachments()) {
237:                    for (Iterator it = source.getAttachmentNames().iterator(); it
238:                            .hasNext();) {
239:                        String name = (String) it.next();
240:                        dest.addAttachment(name, source.getAttachment(name));
241:                    }
242:                }
243:                if (isCopySubject()) {
244:                    dest.setSecuritySubject(source.getSecuritySubject());
245:                }
246:            }
247:
248:            protected abstract void transform(MessageExchange exchange,
249:                    NormalizedMessage in, NormalizedMessage out)
250:                    throws Exception;
251:
252:            protected Resource getDynamicResource(MessageExchange exchange,
253:                    NormalizedMessage in) throws Exception {
254:                Object res = getExpression().evaluate(exchange, in);
255:                if (res == null) {
256:                    return null;
257:                }
258:                if (res instanceof  Resource) {
259:                    return (Resource) res;
260:                }
261:                if (res instanceof  File) {
262:                    return new FileSystemResource((File) res);
263:                }
264:                if (res instanceof  URL) {
265:                    return new UrlResource((URL) res);
266:                }
267:                if (res instanceof  URI) {
268:                    return new UrlResource(((URI) res).toURL());
269:                }
270:                return new DefaultResourceLoader().getResource(res.toString());
271:            }
272:
273:            protected Document parse(Resource res) throws Exception {
274:                URL url = null;
275:                try {
276:                    url = res.getURL();
277:                } catch (IOException e) {
278:                    // Ignore
279:                }
280:                DocumentBuilder builder = sourceTransformer
281:                        .createDocumentBuilder();
282:                return builder.parse(res.getInputStream(), url != null ? url
283:                        .toExternalForm() : null);
284:            }
285:
286:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.