Search in sources :

Example 1 with ListenerRegistrationException

use of org.apache.cxf.endpoint.ListenerRegistrationException in project cxf by apache.

the class SoapBindingFactory method addListener.

@Override
public synchronized void addListener(Destination d, Endpoint e) {
    synchronized (d) {
        MessageObserver mo = d.getMessageObserver();
        if (d.getAddress() != null && d.getAddress().getAddress() != null && d.getAddress().getAddress().getValue() != null && d.getAddress().getAddress().getValue().startsWith("soap.udp")) {
            // soap.udp REQUIRES usage of WS-Addressing... we need to turn this on
            setupUDP(e, e.getEndpointInfo());
        }
        if (mo == null) {
            super.addListener(d, e);
            return;
        }
        if (mo instanceof ChainInitiationObserver) {
            ChainInitiationObserver cio = (ChainInitiationObserver) mo;
            Binding b = e.getBinding();
            Binding b2 = cio.getEndpoint().getBinding();
            if (b == b2) {
                // re-registering the same endpoint?
                return;
            }
            Object o = cio.getEndpoint().get("allow-multiplex-endpoint");
            if (o instanceof String) {
                o = Boolean.parseBoolean((String) o);
            } else if (o == null) {
                o = Boolean.FALSE;
            }
            if (b instanceof org.apache.cxf.binding.soap.SoapBinding && b2 instanceof org.apache.cxf.binding.soap.SoapBinding && ((org.apache.cxf.binding.soap.SoapBinding) b).getSoapVersion().equals(((org.apache.cxf.binding.soap.SoapBinding) b2).getSoapVersion()) && Boolean.FALSE.equals(o)) {
                throw new ListenerRegistrationException("Soap " + ((org.apache.cxf.binding.soap.SoapBinding) b).getSoapVersion().getVersion() + " endpoint already registered on address " + e.getEndpointInfo().getAddress());
            }
            MultipleEndpointObserver newMO = new MultipleEndpointObserver(getBus()) {

                @Override
                protected Message createMessage(Message message) {
                    return new SoapMessage(message);
                }
            };
            newMO.getBindingInterceptors().add(new AttachmentInInterceptor());
            newMO.getBindingInterceptors().add(new StaxInInterceptor());
            // This will not work if one of the endpoints disables message
            // processing. But, if you've disabled message processing, you
            // probably aren't going to use this feature.
            newMO.getBindingInterceptors().add(new ReadHeadersInterceptor(getBus(), (SoapVersion) null));
            newMO.getBindingInterceptors().add(new StartBodyInterceptor());
            newMO.getBindingInterceptors().add(new CheckFaultInterceptor());
            // Add in a default selection interceptor
            newMO.getRoutingInterceptors().add(new EndpointSelectionInterceptor());
            newMO.getEndpoints().add(cio.getEndpoint());
            mo = newMO;
        }
        if (mo instanceof MultipleEndpointObserver) {
            MultipleEndpointObserver meo = (MultipleEndpointObserver) mo;
            meo.getEndpoints().add(e);
        }
        d.setMessageObserver(mo);
    }
}
Also used : SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) Binding(org.apache.cxf.binding.Binding) ReadHeadersInterceptor(org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor) CheckFaultInterceptor(org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor) MessageObserver(org.apache.cxf.transport.MessageObserver) Message(org.apache.cxf.message.Message) ListenerRegistrationException(org.apache.cxf.endpoint.ListenerRegistrationException) StaxInInterceptor(org.apache.cxf.interceptor.StaxInInterceptor) EndpointSelectionInterceptor(org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor) StartBodyInterceptor(org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor) ChainInitiationObserver(org.apache.cxf.transport.ChainInitiationObserver) MultipleEndpointObserver(org.apache.cxf.transport.MultipleEndpointObserver) AttachmentInInterceptor(org.apache.cxf.interceptor.AttachmentInInterceptor)

Aggregations

Binding (org.apache.cxf.binding.Binding)1 CheckFaultInterceptor (org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor)1 EndpointSelectionInterceptor (org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor)1 ReadHeadersInterceptor (org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor)1 StartBodyInterceptor (org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor)1 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)1 ListenerRegistrationException (org.apache.cxf.endpoint.ListenerRegistrationException)1 AttachmentInInterceptor (org.apache.cxf.interceptor.AttachmentInInterceptor)1 StaxInInterceptor (org.apache.cxf.interceptor.StaxInInterceptor)1 Message (org.apache.cxf.message.Message)1 ChainInitiationObserver (org.apache.cxf.transport.ChainInitiationObserver)1 MessageObserver (org.apache.cxf.transport.MessageObserver)1 MultipleEndpointObserver (org.apache.cxf.transport.MultipleEndpointObserver)1