Search in sources :

Example 46 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class OutgoingChainInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
    phases = new ArrayList<>();
    phases.add(new Phase(Phase.SEND, 1000));
    empty = new ArrayList<Interceptor<? extends Message>>();
    bus = control.createMock(Bus.class);
    PhaseManager pm = new PhaseManagerImpl();
    EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).anyTimes();
    service = control.createMock(Service.class);
    endpoint = control.createMock(Endpoint.class);
    binding = control.createMock(Binding.class);
    EasyMock.expect(endpoint.getBinding()).andStubReturn(binding);
    MessageImpl m = new MessageImpl();
    EasyMock.expect(binding.createMessage()).andStubReturn(m);
    EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
    EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty);
    EasyMock.expect(service.getOutInterceptors()).andReturn(empty);
    EasyMock.expect(bus.getOutInterceptors()).andReturn(empty);
    bopInfo = control.createMock(BindingOperationInfo.class);
    opInfo = control.createMock(OperationInfo.class);
    mInfo = control.createMock(MessageInfo.class);
    bmInfo = control.createMock(BindingMessageInfo.class);
    EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(3);
    EasyMock.expect(opInfo.getOutput()).andReturn(mInfo);
    EasyMock.expect(opInfo.isOneWay()).andReturn(false);
    EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo);
    control.replay();
}
Also used : Binding(org.apache.cxf.binding.Binding) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Phase(org.apache.cxf.phase.Phase) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) Service(org.apache.cxf.service.Service) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) MessageImpl(org.apache.cxf.message.MessageImpl) Before(org.junit.Before)

Example 47 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class AbstractFaultChainInitiatorObserver method onMessage.

public void onMessage(Message message) {
    assert null != message;
    Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
    ClassLoaderHolder origLoader = null;
    try {
        if (loader != null) {
            origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
        }
        Exchange exchange = message.getExchange();
        Message faultMessage = null;
        if (isOutboundObserver()) {
            Exception ex = message.getContent(Exception.class);
            if (!(ex instanceof Fault)) {
                ex = new Fault(ex);
            }
            FaultMode mode = message.get(FaultMode.class);
            faultMessage = exchange.getOutMessage();
            if (null == faultMessage) {
                faultMessage = new MessageImpl();
                faultMessage.setExchange(exchange);
                faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage);
            }
            faultMessage.setContent(Exception.class, ex);
            if (null != mode) {
                faultMessage.put(FaultMode.class, mode);
            }
            // CXF-3981
            if (message.get("javax.xml.ws.addressing.context.inbound") != null) {
                faultMessage.put("javax.xml.ws.addressing.context.inbound", message.get("javax.xml.ws.addressing.context.inbound"));
            }
            exchange.setOutMessage(null);
            exchange.setOutFaultMessage(faultMessage);
            if (message.get(BindingFaultInfo.class) != null) {
                faultMessage.put(BindingFaultInfo.class, message.get(BindingFaultInfo.class));
            }
        } else {
            faultMessage = message;
            exchange.setInMessage(null);
            exchange.setInFaultMessage(faultMessage);
        }
        // setup chain
        PhaseInterceptorChain chain = new PhaseInterceptorChain(getPhases());
        initializeInterceptors(faultMessage.getExchange(), chain);
        faultMessage.setInterceptorChain(chain);
        try {
            chain.doIntercept(faultMessage);
        } catch (RuntimeException exc) {
            LOG.log(Level.SEVERE, "ERROR_DURING_ERROR_PROCESSING", exc);
            throw exc;
        } catch (Exception exc) {
            LOG.log(Level.SEVERE, "ERROR_DURING_ERROR_PROCESSING", exc);
            throw new RuntimeException(exc);
        }
    } finally {
        if (origBus != bus) {
            BusFactory.setThreadDefaultBus(origBus);
        }
        if (origLoader != null) {
            origLoader.reset();
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Bus(org.apache.cxf.Bus) FaultMode(org.apache.cxf.message.FaultMode) PhaseInterceptorChain(org.apache.cxf.phase.PhaseInterceptorChain) Message(org.apache.cxf.message.Message) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder) MessageImpl(org.apache.cxf.message.MessageImpl) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 48 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class CachedOutputStream method readBusProperties.

private void readBusProperties() {
    Bus b = BusFactory.getThreadDefaultBus(false);
    if (b != null) {
        String v = getBusProperty(b, "bus.io.CachedOutputStream.Threshold", null);
        if (v != null && threshold == defaultThreshold) {
            threshold = Integer.parseInt(v);
        }
        v = getBusProperty(b, "bus.io.CachedOutputStream.MaxSize", null);
        if (v != null) {
            maxSize = Integer.parseInt(v);
        }
        v = getBusProperty(b, "bus.io.CachedOutputStream.CipherTransformation", null);
        if (v != null) {
            cipherTransformation = v;
        }
    }
}
Also used : Bus(org.apache.cxf.Bus)

Example 49 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class CachedWriter method readBusProperties.

private void readBusProperties() {
    Bus b = BusFactory.getThreadDefaultBus(false);
    if (b != null) {
        String v = getBusProperty(b, "bus.io.CachedOutputStream.Threshold", null);
        if (v != null && threshold == defaultThreshold) {
            threshold = Integer.parseInt(v);
        }
        v = getBusProperty(b, "bus.io.CachedOutputStream.MaxSize", null);
        if (v != null) {
            maxSize = Integer.parseInt(v);
        }
        v = getBusProperty(b, "bus.io.CachedOutputStream.CipherTransformation", null);
        if (v != null) {
            cipherTransformation = v;
        }
    }
}
Also used : Bus(org.apache.cxf.Bus)

Example 50 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class MessageImpl method calcContextCache.

private void calcContextCache() {
    Map<String, Object> o = new HashMap<String, Object>() {

        private static final long serialVersionUID = 7067290677790419348L;

        public void putAll(Map<? extends String, ? extends Object> m) {
            if (m != null && !m.isEmpty()) {
                super.putAll(m);
            }
        }
    };
    Exchange ex = getExchange();
    if (ex != null) {
        Bus b = ex.getBus();
        if (b != null) {
            o.putAll(b.getProperties());
        }
        Service sv = ex.getService();
        if (sv != null) {
            o.putAll(sv);
        }
        Endpoint ep = ex.getEndpoint();
        if (ep != null) {
            EndpointInfo ei = ep.getEndpointInfo();
            if (ei != null) {
                o.putAll(ep.getEndpointInfo().getBinding().getProperties());
                o.putAll(ep.getEndpointInfo().getProperties());
            }
            o.putAll(ep);
        }
    }
    o.putAll(ex);
    o.putAll(this);
    contextCache = o;
}
Also used : Bus(org.apache.cxf.Bus) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) HashMap(java.util.HashMap) Service(org.apache.cxf.service.Service) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Bus (org.apache.cxf.Bus)1144 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)800 URL (java.net.URL)748 QName (javax.xml.namespace.QName)436 Service (javax.xml.ws.Service)400 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)354 Test (org.junit.Test)219 HashMap (java.util.HashMap)63 Message (org.apache.cxf.message.Message)60 WebClient (org.apache.cxf.jaxrs.client.WebClient)50 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)48 Client (org.apache.cxf.endpoint.Client)43 Greeter (org.apache.hello_world.Greeter)42 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)41 SOAPService (org.apache.hello_world.services.SOAPService)41 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)40 Endpoint (org.apache.cxf.endpoint.Endpoint)38 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)36 STSClient (org.apache.cxf.ws.security.trust.STSClient)36 Document (org.w3c.dom.Document)36