Author: ffang
Date: Tue Dec 4 09:39:43 2012
New Revision: 1416846
URL: http://svn.apache.org/viewvc?rev=1416846&view=rev
Log:
[SMX4-1313]add EnableCORSInterceptor for cxf-jaxws-blueprint example
Added:
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
Modified:
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/pom.xml
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Modified:
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/pom.xml?rev=1416846&r1=1416845&r2=1416846&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/pom.xml
(original)
+++ servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/pom.xml Tue
Dec 4 09:39:43 2012
@@ -42,6 +42,11 @@
<artifactId>cxf-api</artifactId>
<version>${cxf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
</dependencies>
<build>
@@ -58,7 +63,8 @@
javax.wsdl,
javax.xml.namespace,
org.apache.cxf.helpers,
- org.osgi.service.blueprint
+ org.osgi.service.blueprint,
+ *
</Import-Package>
<Export-Package>
org.apache.servicemix.examples.cxf
Added:
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java?rev=1416846&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
(added)
+++
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
Tue Dec 4 09:39:43 2012
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.examples.cxf;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.transport.http.Headers;
+
+public class EnableCORSInterceptor extends AbstractPhaseInterceptor<Message> {
+
+ public EnableCORSInterceptor() {
+ super(Phase.PRE_PROTOCOL);
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault {
+ Map<String, List<String>> headers =
Headers.getSetProtocolHeaders(message);
+ try {
+ //Access-Control-Allow-Origin:*
Access-Control-Allow-Methods:POST,GET
+ headers.put("Access-Control-Allow-Origin", Arrays.asList("*"));
+ headers.put("Access-Control-Allow-Methods", Arrays.asList("POST",
"GET"));
+ } catch (Exception ce) {
+ throw new Fault(ce);
+ }
+ }
+}
Modified:
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1416846&r1=1416845&r2=1416846&view=diff
==============================================================================
---
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++
servicemix/smx4/features/trunk/examples/cxf/cxf-jaxws-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Tue Dec 4 09:39:43 2012
@@ -35,7 +35,9 @@ http://cxf.apache.org/blueprint/jaxws ht
<jaxws:endpoint id="helloWorld"
implementor="org.apache.servicemix.examples.cxf.HelloWorldImpl"
address="/HelloWorld">
-
+ <jaxws:outInterceptors>
+ <bean
class="org.apache.servicemix.examples.cxf.EnableCORSInterceptor"/>
+ </jaxws:outInterceptors>
</jaxws:endpoint>
</blueprint>