servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1416855 - in /servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing: pom.xml src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java src/main/resources/META-INF/spring/beans.xml
Date Tue, 04 Dec 2012 09:46:26 GMT
Author: ffang
Date: Tue Dec  4 09:46:25 2012
New Revision: 1416855

URL: http://svn.apache.org/viewvc?rev=1416855&view=rev
Log:
[SMX4-1313]add EnableCORSInterceptor for cxf-ws-addressing example

Added:
    servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
Modified:
    servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/pom.xml
    servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/resources/META-INF/spring/beans.xml

Modified: servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/pom.xml?rev=1416855&r1=1416854&r2=1416855&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/pom.xml Tue Dec  4 09:46:25
2012
@@ -39,12 +39,18 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.servicemix</groupId>
             <artifactId>servicemix-utils</artifactId>
+            <version>1.5.0</version>
         </dependency>
     </dependencies>
 
@@ -101,6 +107,8 @@
                             org.apache.cxf.ws.addressing,
                             org.apache.cxf.ws.addressing.soap,
                             org.apache.servicemix.util,
+                            org.apache.cxf.message, 
+                            org.apache.cxf.phase,
                             org.springframework.beans.factory.config
                         </Import-Package>
                         <Export-Package>

Added: servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java?rev=1416855&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
(added)
+++ servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/java/org/apache/servicemix/examples/cxf/EnableCORSInterceptor.java
Tue Dec  4 09:46:25 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-ws-addressing/src/main/resources/META-INF/spring/beans.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/resources/META-INF/spring/beans.xml?rev=1416855&r1=1416854&r2=1416855&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/resources/META-INF/spring/beans.xml
(original)
+++ servicemix/smx4/features/trunk/examples/cxf/cxf-ws-addressing/src/main/resources/META-INF/spring/beans.xml
Tue Dec  4 09:46:25 2012
@@ -42,6 +42,9 @@
             <jaxws:features>
                 <bean class="org.apache.cxf.feature.LoggingFeature"/>
             </jaxws:features>
+            <jaxws:outInterceptors>
+                <bean class="org.apache.servicemix.examples.cxf.EnableCORSInterceptor"/>
+            </jaxws:outInterceptors>
         </jaxws:endpoint>
 
        



Mime
View raw message