cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r532823 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/phase/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/java/org/apache/cxf/service/invoker/ rt/ws/addr/src/main...
Date Thu, 26 Apr 2007 17:46:37 GMT
Author: andreasmyth
Date: Thu Apr 26 10:46:35 2007
New Revision: 532823

URL: http://svn.apache.org/viewvc?view=rev&rev=532823
Log:
* Enable outbound server side MAPCodec to process faults thrown on inbound interceptor chain before MAPAggregator.
* Allow interceptors to distinguish between application and runtime faults.

Added:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml   (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java   (with props)
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageUtils.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseComparator.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/Server.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl

Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java (added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,37 @@
+/**
+ * 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.cxf.message;
+
+/**
+ * 
+ */
+public enum FaultMode {
+    
+    RUNTIME_FAULT ("org.apache.cxf.runtime.fault"),
+    LOGICAL_RUNTIME_FAULT ("org.apache.cxf.runtime.fault.logical"),
+    CHECKED_APPLICATION_FAULT ("org.apache.cxf.application.fault.checked"),
+    UNCHECKED_APPLICATION_FAULT ("org.apache.cxf.application.fault.unchecked");
+    
+    String mode;
+    
+    FaultMode(String m) {
+        mode = m;
+    }
+}

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/FaultMode.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageUtils.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageUtils.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageUtils.java Thu Apr 26 10:46:35 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.message;
 
+
 /**
  * Holder for utility methods relating to messages.
  */
@@ -53,6 +54,27 @@
                && message.getExchange() != null
                && (message == message.getExchange().getInFaultMessage() || message == message.getExchange()
                    .getOutFaultMessage());
+    }
+    
+    /**
+     * Determine the fault mode for the underlying (fault) message 
+     * (for use on server side only).
+     * 
+     * @param message the fault message
+     * @return the FaultMode
+     */
+    public static FaultMode getFaultMode(Message message) {
+        if (message != null
+            && message.getExchange() != null
+            && message == message.getExchange().getOutFaultMessage()) {
+            FaultMode mode = message.get(FaultMode.class);
+            if (null != mode) {
+                return mode;
+            } else {
+                return FaultMode.RUNTIME_FAULT;
+            }
+        }
+        return null;    
     }
 
     /**

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseComparator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseComparator.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseComparator.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseComparator.java Thu Apr 26 10:46:35 2007
@@ -21,7 +21,7 @@
 
 import java.util.Comparator;
 
-class PhaseComparator implements Comparator<Phase> {
+public class PhaseComparator implements Comparator<Phase> {
 
     public int compare(Phase o1, Phase o2) {
         return o1.getPriority() - o2.getPriority();

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java Thu Apr 26 10:46:35 2007
@@ -27,6 +27,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
@@ -44,7 +45,7 @@
 
     public void onMessage(Message message) {
       
-        assert  null != message;
+        assert null != message;
         Exchange exchange = message.getExchange();
 
         Message faultMessage = null;
@@ -57,12 +58,16 @@
             if (!(ex instanceof Fault)) {
                 ex = new Fault(ex);
             }
+            FaultMode mode = (FaultMode)message.get(FaultMode.class);
             
             faultMessage = exchange.getOutMessage();
             if (null == faultMessage) {
                 faultMessage = exchange.get(Endpoint.class).getBinding().createMessage();
             }
             faultMessage.setContent(Exception.class, ex);
+            if (null != mode) {
+                faultMessage.put(FaultMode.class, mode);
+            }
             assert exchange.get(Exception.class) == ex;
             exchange.setOutMessage(null);
             exchange.setOutFaultMessage(faultMessage);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/AbstractInvoker.java Thu Apr 26 10:46:35 2007
@@ -29,6 +29,7 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingOperationInfo;
 
@@ -80,8 +81,10 @@
             if (t == null) {
                 t = e;
             }
+            exchange.getInMessage().put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT);
             throw new Fault(t);
         } catch (Exception e) {
+            exchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
             throw new Fault(e);
         }
     }

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Thu Apr 26 10:46:35 2007
@@ -36,6 +36,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -249,6 +250,8 @@
             boolean isOneway = message.getExchange().isOneWay();
             continueProcessing = validateIncomingMAPs(maps, message);
             if (continueProcessing) {
+                // any faults thrown from here on can be correlated with this message
+                message.put(FaultMode.class, FaultMode.LOGICAL_RUNTIME_FAULT);
                 if (isOneway
                     || !ContextUtils.isGenericAddress(maps.getReplyTo())) {
                     ContextUtils.rebaseResponse(maps.getReplyTo(),

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Thu Apr 26 10:46:35 2007
@@ -569,7 +569,7 @@
      * @param maps the addressing properties
      */
     private void restoreExchange(SoapMessage message, AddressingProperties maps) {
-        if (maps.getRelatesTo() != null) {
+        if (maps != null && maps.getRelatesTo() != null) {
             Exchange correlatedExchange =
                 uncorrelatedExchanges.remove(maps.getRelatesTo().getValue());
             if (correlatedExchange != null) {
@@ -595,7 +595,7 @@
      * @param message the current message
      */
     private void markPartialResponse(SoapMessage message, AddressingProperties maps) {
-        if (ContextUtils.isRequestor(message) && null == maps.getRelatesTo()) {
+        if (ContextUtils.isRequestor(message) && null != maps && null == maps.getRelatesTo()) {
             message.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
         } 
     }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,60 @@
+/**
+ * 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.cxf.systest.interceptor;
+
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultDetail;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.FaultMode;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+public class FaultHandlingInterceptor extends AbstractPhaseInterceptor {
+    
+    public FaultHandlingInterceptor() {
+        super.setPhase(Phase.USER_LOGICAL);
+    }
+    
+    public synchronized void handleMessage(Message message) throws Fault {
+        FaultMode mode = MessageUtils.getFaultMode(message);
+        System.out.println("FaultMode: " + mode);
+        if (null != mode) {
+            Throwable cause = message.getContent(Exception.class).getCause();
+            
+            if (FaultMode.CHECKED_APPLICATION_FAULT == mode) {
+                PingMeFault original = (PingMeFault)cause;                
+                FaultDetail detail = new FaultDetail();
+                detail.setMajor((short)20);
+                detail.setMinor((short)10);
+                PingMeFault replaced = new PingMeFault(original.getMessage(), detail);
+                message.setContent(Exception.class, new Fault(replaced));
+            } else {
+                RuntimeException original = (RuntimeException)cause;
+                RuntimeException replaced = new RuntimeException(original.getMessage().toUpperCase());
+                message.setContent(Exception.class, new Fault(replaced));                
+            }
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/FaultHandlingInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,36 @@
+/**
+ * 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.cxf.systest.interceptor;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.greeter_control.AbstractGreeterImpl;
+
+/**
+ * 
+ */
+
+@WebService(serviceName = "BasicGreeterService",
+            portName = "GreeterPort",
+            endpointInterface = "org.apache.cxf.greeter_control.Greeter",
+            targetNamespace = "http://cxf.apache.org/greeter_control",
+            wsdlLocation = "testutils/greeter_control.wsdl")
+public class GreeterImpl extends AbstractGreeterImpl {
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/GreeterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,350 @@
+/**
+ * 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.cxf.systest.interceptor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.greeter_control.Control;
+import org.apache.cxf.greeter_control.ControlImpl;
+import org.apache.cxf.greeter_control.ControlService;
+import org.apache.cxf.greeter_control.FaultThrowingInterceptor;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.GreeterService;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultLocation;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseComparator;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.cxf.ws.addressing.MAPAggregator;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class InterceptorFaultTest extends AbstractBusClientServerTestBase {
+    private static final Logger LOG = Logger.getLogger(InterceptorFaultTest.class.getName());
+
+    private static final QName SOAP_FAULT_CODE = new QName("http://schemas.xmlsoap.org/soap/envelope/",
+                                                           "Server");
+    private static final String FAULT_CODE = "COULD_NOT_SEND";
+    private static final String FAULT_MESSAGE = "Could not send Message.";
+    
+    private static final String CONTROL_PORT_ADDRESS = 
+        "http://localhost:9001/SoapContext/ControlPort";
+    
+    private static int decoupledEndpointPort = 10000;
+    private static String decoupledEndpoint;
+    
+
+    /**
+     * Tests that a fault thrown by a server side interceptor is reported back to
+     * the client in appropriate form (plain Fault in case of one way requests, 
+     * SoapFault in case of two way requests).
+     * Also demonstrates how an interceptor on the server out fault chain can 
+     * distinguish different fault modes (the capability to do so is crucial to
+     * QOS interceptors such as the RM, addressing and policy interceptors).
+     *
+     */
+    public static class Server extends AbstractBusTestServerBase {
+
+        protected void run() {
+            SpringBusFactory factory = new SpringBusFactory();
+            Bus bus = factory.createBus();
+            BusFactory.setDefaultBus(bus);
+            setBus(bus);
+
+            ControlImpl implementor = new ControlImpl();
+            GreeterImpl greeterImplementor = new GreeterImpl();
+            greeterImplementor.setThrowAlways(true);
+            implementor.setImplementor(greeterImplementor);
+            Endpoint.publish(CONTROL_PORT_ADDRESS, implementor);
+            LOG.fine("Published control endpoint.");
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+    
+    private Bus controlBus;
+    private Control control;
+    private Bus greeterBus;
+    private Greeter greeter;
+    private List<Phase> inPhases;
+    private PhaseComparator comparator;
+    private Phase preLogicalPhase;
+    
+    
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(Server.class));
+    }
+    
+    @After
+    public void tearDown() {
+        if (null != greeter) {
+            assertTrue("Failed to stop greeter.", control.stopGreeter());
+            greeterBus.shutdown(true);
+            greeterBus = null;
+        }
+        if (null != control) {  
+            assertTrue("Failed to stop greeter", control.stopGreeter());
+            controlBus.shutdown(true);
+        }
+    }
+
+    @Test
+    public void testWithoutAddressing() throws Exception {
+        
+        setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false);
+
+        // all interceptors pass
+
+        greeter.greetMeOneWay("one");
+        assertEquals("one", greeter.greetMe("two"));
+        try {
+            greeter.pingMe();
+            fail("Expected PingMeFault not thrown.");
+        } catch (PingMeFault f) {
+            assertEquals(20, (int)f.getFaultInfo().getMajor());
+            assertEquals(10, (int)f.getFaultInfo().getMinor());
+        }
+
+        // behaviour is identicial for all phases
+        
+        Iterator<Phase> it = inPhases.iterator();
+        Phase p = null;
+        FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory()
+            .createFaultLocation();        
+        
+        while (it.hasNext()) {
+            p = it.next();
+            location.setPhase(p.getName());
+            if (Phase.INVOKE.equals(p.getName())) {
+                break;
+            }             
+            testFail(location);
+        }
+    }
+    
+    @Test
+    public void testWithAddressingAnonymousReplies() throws Exception {
+        setupGreeter("org/apache/cxf/systest/interceptor/addr.xml", false);
+
+        // all interceptors pass
+
+        greeter.greetMeOneWay("one");
+        assertEquals("one", greeter.greetMe("two"));
+        try {
+            greeter.pingMe();
+            fail("Expected PingMeFault not thrown.");
+        } catch (PingMeFault f) {
+            assertEquals(20, (int)f.getFaultInfo().getMajor());
+            assertEquals(10, (int)f.getFaultInfo().getMinor());
+        }
+        
+        // test failure in phases before Phase.PRE_LOGICAL
+        
+        Iterator<Phase> it = inPhases.iterator();
+        Phase p = null;
+        FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory()
+            .createFaultLocation();
+        location.setAfter(MAPAggregator.class.getName());
+        
+        // test failure occuring before logical addressing interceptor 
+
+        while (it.hasNext()) {
+            p = it.next();
+            location.setPhase(p.getName());
+            if (Phase.PRE_LOGICAL.equals(p.getName())) {
+                break;
+            }   
+            testFail(location, true);
+        }
+        
+        // test failure occuring after logical addressing interceptor -
+        // won't get a fault in case of oneways (partial response already sent)
+        
+        do {  
+            location.setPhase(p.getName());
+            if (Phase.INVOKE.equals(p.getName())) {
+                break;
+            }             
+            testFail(location, true);
+            p = it.hasNext() ? it.next() : null;
+        } while (null != p);
+    }
+    
+    @Ignore
+    @Test
+    public void testWithAddressingNonAnonymousReplies() {
+    }
+    
+    private void testFail(FaultLocation location) throws PingMeFault {
+        testFail(location, false);
+    }
+   
+    private void testFail(FaultLocation location, boolean usingAddressing) throws PingMeFault {
+        // System.out.print("Test interceptor failing in phase: " + location.getPhase()); 
+        
+        control.setFaultLocation(location);       
+       
+        String expectedMsg = getExpectedInterceptorFaultMessage(location.getPhase());
+
+        // oneway reports a plain fault (although server sends a soap fault)
+
+        boolean expectOnewayFault = !usingAddressing 
+            || comparator.compare(preLogicalPhase, getPhase(location.getPhase())) > 0;
+        
+        try {
+            greeter.greetMeOneWay("oneway");
+            if (expectOnewayFault) {
+                fail("Oneway operation unexpectedly succeded.");
+            }
+        } catch (WebServiceException ex) {
+            if (!expectOnewayFault) {
+                fail("Oeway operation unexpectedly failed.");
+            }
+            Throwable cause = ex.getCause();
+            Fault f = (Fault)cause;
+            assertEquals(FAULT_CODE, f.getCode());
+            assertEquals(FAULT_MESSAGE, f.getMessage());
+        }
+        
+        try {
+            greeter.greetMe("cxf");
+            fail("Twoway operation unexpectedly succeded.");
+        } catch (WebServiceException ex) {
+            Throwable cause = ex.getCause();
+            SoapFault sf = (SoapFault)cause;
+            assertEquals(expectedMsg, sf.getReason());
+            assertEquals(SOAP_FAULT_CODE, sf.getFaultCode());
+            assertNull(sf.getDetail());
+        }
+        
+        try {
+            greeter.pingMe();
+            fail("Expected PingMeFault not thrown.");
+        } catch (WebServiceException ex) {
+            Throwable cause = ex.getCause();
+            SoapFault sf = (SoapFault)cause;
+            assertEquals(expectedMsg, sf.getReason());
+            assertEquals(SOAP_FAULT_CODE, sf.getFaultCode());
+            assertNull(sf.getDetail());
+        }  
+    }
+   
+    
+    
+    private void setupGreeter(String cfgResource, boolean useDecoupledEndpoint) {
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        
+        controlBus = bf.createBus();
+        BusFactory.setDefaultBus(controlBus);
+
+        ControlService cs = new ControlService();
+        control = cs.getControlPort();
+        
+        assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
+        
+        greeterBus = bf.createBus(cfgResource);
+        BusFactory.setDefaultBus(greeterBus);
+        LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
+        
+        if (null == comparator) {
+            comparator = new PhaseComparator();
+        }
+        if (null == inPhases) {
+            inPhases = new ArrayList<Phase>();
+            inPhases.addAll(greeterBus.getExtension(PhaseManager.class).getInPhases());
+            Collections.sort(inPhases, comparator);
+        }        
+        if (null == preLogicalPhase) {
+            preLogicalPhase = getPhase(Phase.PRE_LOGICAL);
+        }
+       
+        GreeterService gs = new GreeterService();
+
+        greeter = gs.getGreeterPort();
+        LOG.fine("Created greeter client.");
+       
+        if (!useDecoupledEndpoint) {
+            return;
+        }
+
+        // programatically configure decoupled endpoint that is guaranteed to
+        // be unique across all test cases
+        
+        decoupledEndpointPort--;
+        decoupledEndpoint = "http://localhost:" + decoupledEndpointPort + "/decoupled_endpoint";
+
+        Client c = ClientProxy.getClient(greeter);
+        HTTPConduit hc = (HTTPConduit)(c.getConduit());
+        HTTPClientPolicy cp = hc.getClient();
+        cp.setDecoupledEndpoint(decoupledEndpoint);
+
+        LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
+    }
+
+    private String getExpectedInterceptorFaultMessage(String phase) {
+        return FaultThrowingInterceptor.MESSAGE_FORMAT.format(new Object[] {phase}).toUpperCase();
+    }
+    
+    private Phase getPhase(String name) {
+        for (Phase p : inPhases) {
+            if (p.getName().equals(name)) {
+                return p;
+            }
+        }
+        return null;
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml Thu Apr 26 10:46:35 2007
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="mapAggregator" class="org.apache.cxf.ws.addressing.MAPAggregator"/>
+    <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
+    <bean id="logIn" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+    <bean id="logOut" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+    <bean id="catcher" class="org.apache.cxf.systest.interceptor.FaultHandlingInterceptor"/>
+    
+    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
+        <property name="inInterceptors">
+            <list>
+                <ref bean="logIn"/>
+                <ref bean="mapCodec"/>
+                <ref bean="mapAggregator"/>
+            </list>
+        </property>
+        <property name="outInterceptors">
+            <list>
+                <ref bean="logOut"/>
+                <ref bean="mapCodec"/>
+                <ref bean="mapAggregator"/>
+            </list>
+        </property>
+        <property name="outFaultInterceptors">
+            <list>
+                <ref bean="logOut"/>
+                <ref bean="catcher"/>
+                <ref bean="mapCodec"/>
+                <ref bean="mapAggregator"/>
+            </list>
+        </property>
+        <property name="inFaultInterceptors">
+            <list>
+                <ref bean="mapCodec"/>
+                <ref bean="mapAggregator"/>
+            </list>
+        </property>
+    </bean>
+    
+</beans>

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/addr.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml Thu Apr 26 10:46:35 2007
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    
+    <bean id="logIn" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+    <bean id="logOut" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+    <bean id="catcher" class="org.apache.cxf.systest.interceptor.FaultHandlingInterceptor"/>
+    
+    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
+        <property name="inInterceptors">
+            <list>
+                <ref bean="logIn"/>
+            </list>
+        </property>
+        <property name="outInterceptors">
+            <list>
+                <ref bean="logOut"/>
+            </list>
+        </property>
+        <property name="outFaultInterceptors">
+            <list>
+                <ref bean="logOut"/>
+                <ref bean="catcher"/>
+            </list>
+        </property>
+    </bean>
+    
+</beans>

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/interceptor/no-addr.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java Thu Apr 26 10:46:35 2007
@@ -20,51 +20,27 @@
 
 package org.apache.cxf.systest.ws.rm;
 
-import java.util.concurrent.Future;
 import java.util.logging.Logger;
 
 import javax.jws.WebService;
-import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Endpoint;
-import javax.xml.ws.Response;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.greeter_control.Control;
-import org.apache.cxf.greeter_control.types.StartGreeterResponse;
-import org.apache.cxf.greeter_control.types.StopGreeterResponse;
-import org.apache.cxf.systest.ws.util.InMessageRecorder;
-import org.apache.cxf.systest.ws.util.OutMessageRecorder;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.ws.rm.RMManager;
 
-
 @WebService(serviceName = "ControlService", 
             portName = "ControlPort", 
             endpointInterface = "org.apache.cxf.greeter_control.Control", 
             targetNamespace = "http://cxf.apache.org/greeter_control")
-public class ControlImpl implements Control {
+public class ControlImpl  extends org.apache.cxf.greeter_control.ControlImpl {
     
     private static final Logger LOG = Logger.getLogger(ControlImpl.class.getName());
-    private Endpoint endpoint;
-    private Bus greeterBus;
     
-    public boolean startGreeter(String cfgResource) {
-       
-        SpringBusFactory bf = new SpringBusFactory();
-        greeterBus = bf.createBus(cfgResource);
-        BusFactory.setDefaultBus(greeterBus);
-        LOG.info("Initialised bus with cfg file resource: " + cfgResource);
-        greeterBus.getOutInterceptors().add(new OutMessageRecorder());
-        greeterBus.getInInterceptors().add(new InMessageRecorder());
-        
-        GreeterImpl implementor = new GreeterImpl();
-        String address = "http://localhost:9020/SoapContext/GreeterPort";
-        endpoint = Endpoint.publish(address, implementor);
-        LOG.info("Published greeter endpoint.");
-        return true;        
-    }
-
+    @Override
     public boolean stopGreeter() {  
         
         if (null != endpoint) {
@@ -81,27 +57,24 @@
         }
         return true;
     }
-    
-    public Future<?> startGreeterAsync(String requestType, AsyncHandler<StartGreeterResponse> asyncHandler) {
-        // never called
-        return null;
-    }
-
-    public Response<StartGreeterResponse> startGreeterAsync(String requestType) {
-        // never called
-        return null;
-    }
 
-    public Response<StopGreeterResponse> stopGreeterAsync() {
-        // never called
-        return null;
-    }
-
-    public Future<?> stopGreeterAsync(AsyncHandler<StopGreeterResponse> asyncHandler) {
-        // never called
-        return null;
+    @Override
+    public boolean startGreeter(String cfgResource) {
+        SpringBusFactory bf = new SpringBusFactory();
+        greeterBus = bf.createBus(cfgResource);
+        BusFactory.setDefaultBus(greeterBus);
+        LOG.info("Initialised bus with cfg file resource: " + cfgResource);
+        
+        Interceptor logIn = new LoggingInInterceptor();
+        Interceptor logOut = new LoggingOutInterceptor();
+        greeterBus.getInInterceptors().add(logIn);
+        greeterBus.getOutInterceptors().add(logOut);
+        greeterBus.getOutFaultInterceptors().add(logOut);
+        
+        Endpoint.publish(address, implementor);
+        LOG.info("Published greeter endpoint.");
+        
+        return true;        
     }
-    
-    
     
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/Server.java?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/Server.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/Server.java Thu Apr 26 10:46:35 2007
@@ -39,6 +39,8 @@
         setBus(bus);
 
         ControlImpl implementor = new ControlImpl();
+        GreeterImpl greeterImplementor = new GreeterImpl();
+        implementor.setImplementor(greeterImplementor);
         Endpoint.publish(ADDRESS, implementor);
     }
 

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,160 @@
+/**
+ * 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.cxf.greeter_control;
+
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.logging.Logger;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Response;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.greeter_control.types.FaultLocation;
+import org.apache.cxf.greeter_control.types.StartGreeterResponse;
+import org.apache.cxf.greeter_control.types.StopGreeterResponse;
+import org.apache.cxf.interceptor.Interceptor;
+
+@WebService(serviceName = "ControlService", 
+            portName = "ControlPort", 
+            endpointInterface = "org.apache.cxf.greeter_control.Control", 
+            targetNamespace = "http://cxf.apache.org/greeter_control")
+public class ControlImpl implements Control {
+    
+    private static final Logger LOG = Logger.getLogger(ControlImpl.class.getName());
+    protected Object implementor;
+    protected String address;
+    protected Endpoint endpoint;
+    protected Bus greeterBus;
+
+    public void setImplementor(Object i) {
+        implementor = i;
+    }
+ 
+    public Object getImplementor() {
+        return implementor;
+    }
+
+    public void setAddress(String a) {
+        address = a;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+    
+    public boolean startGreeter(String cfgResource) {
+        LOG.fine("Starting greeter with cfgResource: " + cfgResource);
+        greeterBus = null;
+        BusFactory.setDefaultBus(null);
+        String original = System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+        try {
+            if (cfgResource != null && cfgResource.length() > 0) {
+                System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, cfgResource);
+            }
+    
+            String a = address == null ? "http://localhost:9020/SoapContext/GreeterPort" : address;
+            Object i = implementor == null ? new GreeterImpl() : implementor;
+            endpoint = Endpoint.publish(a, i);
+            LOG.info("Published greeter endpoint on bus with cfg file resource: " + cfgResource);
+            greeterBus = BusFactory.getDefaultBus();
+        } finally {
+            System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+            if (null != original) {
+                System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, cfgResource);
+            }
+        }
+        return null != greeterBus; 
+    }
+
+    public boolean stopGreeter() {  
+        LOG.fine("Stopping greeter");
+        
+        if (null != endpoint) {
+            LOG.info("Stopping Greeter endpoint");
+            endpoint.stop();
+        } else {
+            LOG.info("No endpoint active.");
+        }
+        endpoint = null;
+        if (null != greeterBus) {
+            greeterBus.shutdown(true);
+        }
+        greeterBus = null;
+        return true;
+    }
+
+    public void setFaultLocation(FaultLocation fl) {
+        List<Interceptor> interceptors = greeterBus.getInInterceptors();
+        FaultThrowingInterceptor fi = null;
+        for (Interceptor i : interceptors) {
+            if (i instanceof FaultThrowingInterceptor) {
+                interceptors.remove(i);
+                LOG.fine("Removed existing FaultThrowingInterceptor");
+                break;
+            }
+        }
+        
+        fi = new FaultThrowingInterceptor(fl.getPhase());
+        if (null != fl.getBefore() && !"".equals(fl.getBefore())) {
+            fi.addBefore(fl.getBefore()); 
+        }
+        if (null != fl.getAfter() && !"".equals(fl.getAfter())) {
+            fi.addAfter(fl.getAfter()); 
+        }
+
+        interceptors.add(fi);
+        LOG.fine("Added FaultThrowingInterceptor to phase " + fl.getPhase());
+    }
+    
+    public Future<?> startGreeterAsync(String requestType, AsyncHandler<StartGreeterResponse> asyncHandler) {
+        // never called
+        return null;
+    }
+
+    public Response<StartGreeterResponse> startGreeterAsync(String requestType) {
+        // never called
+        return null;
+    }
+
+    public Response<StopGreeterResponse> stopGreeterAsync() {
+        // never called
+        return null;
+    }
+
+    public Future<?> stopGreeterAsync(AsyncHandler<StopGreeterResponse> asyncHandler) {
+        // never called
+        return null;
+    }
+
+    @WebService(serviceName = "GreeterService",
+            portName = "GreeterPort",
+            endpointInterface = "org.apache.cxf.greeter_control.Greeter",
+            targetNamespace = "http://cxf.apache.org/greeter_control")
+    class GreeterImpl extends AbstractGreeterImpl {
+    } 
+    
+}
+

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/ControlImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java?view=auto&rev=532823
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java (added)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java Thu Apr 26 10:46:35 2007
@@ -0,0 +1,57 @@
+/**
+ * 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.cxf.greeter_control;
+
+import java.text.MessageFormat;
+import java.util.logging.Logger;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+public class FaultThrowingInterceptor extends AbstractPhaseInterceptor {
+
+    public static final MessageFormat MESSAGE_FORMAT
+        = new MessageFormat("Interceptor fault in phase {0}.");
+    private static final Logger LOG = Logger.getLogger(FaultThrowingInterceptor.class.getName());
+    
+    public FaultThrowingInterceptor() {
+        super.setPhase(Phase.USER_LOGICAL);
+    }
+    
+    
+    public FaultThrowingInterceptor(String phase) {
+        super.setPhase(phase);
+    }
+
+    public synchronized void handleMessage(Message message) throws Fault {
+        if (MessageUtils.isRequestor(message)) {
+            return;
+        }
+        String msg = MESSAGE_FORMAT.format(new Object[] {getPhase()});
+        LOG.fine(msg);
+        throw new Fault(new RuntimeException(msg));
+    }
+}

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/greeter_control/FaultThrowingInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl?view=diff&rev=532823&r1=532822&r2=532823
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/greeter_control.wsdl Thu Apr 26 10:46:35 2007
@@ -97,6 +97,15 @@
                     </sequence>
                 </complexType>
             </element>
+            <element name="faultLocation">
+                <complexType>
+                    <sequence>
+                        <element name="phase" type="xsd:string"/>
+                        <element name="before" type="xsd:string"/>
+                        <element name="after" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
 
         </schema>
     </wsdl:types>
@@ -139,6 +148,9 @@
     <wsdl:message name="stopGreeterResponse">
         <wsdl:part element="x1:stopGreeterResponse" name="out"/>
     </wsdl:message>
+    <wsdl:message name="setFaultLocationRequest">
+        <wsdl:part element="x1:faultLocation" name="in"/>
+    </wsdl:message>
     
     <wsdl:portType name="Greeter">
         <wsdl:operation name="sayHi">
@@ -172,6 +184,10 @@
             <wsdl:input message="tns:stopGreeterRequest" name="stopGreeterRequest"/>
             <wsdl:output message="tns:stopGreeterResponse" name="stopGreeterResponse"/>
         </wsdl:operation>
+
+        <wsdl:operation name="setFaultLocation">
+            <wsdl:input message="tns:setFaultLocationRequest" name="setFaultLocationRequest"/>
+        </wsdl:operation>
     </wsdl:portType>
 
     <wsdl:binding name="GreeterSOAPBinding" type="tns:Greeter">
@@ -238,6 +254,12 @@
             <wsdl:output name="stopGreeterResponse">
                 <soap:body use="literal"/>
             </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="setFaultLocation">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="setFaultLocationRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
         </wsdl:operation>
     </wsdl:binding>
 



Mime
View raw message