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();
}
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();
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
Aggregations