use of org.apache.cxf.transport.MessageObserver in project cxf by apache.
the class CorbaServerConduitTest method setupCorbaServerConduit.
protected CorbaServerConduit setupCorbaServerConduit(boolean send) {
target = EasyMock.createMock(EndpointReferenceType.class);
endpointInfo = EasyMock.createMock(EndpointInfo.class);
CorbaServerConduit corbaServerConduit = new CorbaServerConduit(endpointInfo, target, targetObject, null, orbConfig, corbaTypeMap);
if (send) {
// setMessageObserver
observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage = m;
}
};
corbaServerConduit.setMessageObserver(observer);
}
return corbaServerConduit;
}
use of org.apache.cxf.transport.MessageObserver 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);
}
}
use of org.apache.cxf.transport.MessageObserver in project cxf by apache.
the class CorbaDSIServantTest method testInvoke.
/*public void testCorbaDSIServant() throws Exception {
CorbaDestination destination = testUtils.getSimpleTypesTestDestination();
Service service = new ServiceImpl();
Endpoint endpoint = new EndpointImpl(bus, service, destination.getEndPointInfo());
MessageObserver observer = new ChainInitiationObserver(endpoint, bus);
destination.setMessageObserver(observer);
POA rootPOA = null;
CorbaDSIServant dsiServant = new CorbaDSIServant();
dsiServant.init(orb,
rootPOA,
destination,
observer);
assertNotNull("DSIServant should not be null", dsiServant != null);
assertNotNull("POA should not be null", dsiServant._default_POA() != null);
assertNotNull("Destination should not be null", dsiServant.getDestination() != null);
assertNotNull("ORB should not be null", dsiServant.getOrb() != null);
assertNotNull("MessageObserver should not be null", dsiServant.getObserver() != null);
byte[] objectId = new byte[10];
String[] interfaces = dsiServant._all_interfaces(rootPOA, objectId);
assertNotNull("Interfaces should not be null", interfaces != null);
assertEquals("Interface ID should be equal", interfaces[0], "IDL:Simple:1.0");
}*/
@Test
public void testInvoke() throws Exception {
CorbaDestination dest = new TestUtils().getComplexTypesTestDestination();
CorbaDSIServant dsiServant = new CorbaDSIServant();
dsiServant.init(orb, null, dest, null);
ServerRequest request = new ServerRequest() {
public String operation() {
return "greetMe";
}
public Context ctx() {
return null;
}
};
MessageObserver incomingObserver = new TestObserver();
dsiServant.setObserver(incomingObserver);
Map<String, QName> map = new HashMap<>(2);
map.put("greetMe", new QName("greetMe"));
dsiServant.setOperationMapping(map);
dsiServant.invoke(request);
}
use of org.apache.cxf.transport.MessageObserver in project cxf by apache.
the class JMSDestinationTest method testRoundTripDestination.
private Message testRoundTripDestination(boolean createSecurityContext) throws Exception {
EndpointInfo ei = setupServiceInfo("HelloWorldService", "HelloWorldPort");
JMSConduit conduit = setupJMSConduitWithObserver(ei);
conduit.getJmsConfig().setCreateSecurityContext(createSecurityContext);
final Message outMessage = createMessage();
final JMSDestination destination = setupJMSDestination(ei);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m);
verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
try {
backConduit = destination.getBackChannel(m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendOneWayMessage(backConduit, replyMessage);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
destination.setMessageObserver(observer);
sendMessageSync(conduit, outMessage);
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
verifyReceivedMessage(waitForReceiveInMessage());
// wait for a while for the jms session recycling
// Send a second message to check for an issue
// Where the session was closed the second time
sendMessageSync(conduit, outMessage);
Message inMessage = waitForReceiveInMessage();
verifyReceivedMessage(inMessage);
// wait for a while for the jms session recycling
// Thread.sleep(1000L);
conduit.close();
destination.shutdown();
return inMessage;
}
use of org.apache.cxf.transport.MessageObserver in project cxf by apache.
the class AbstractJMSTester method setupJMSConduitWithObserver.
protected JMSConduit setupJMSConduitWithObserver(EndpointInfo ei) throws IOException {
JMSConduit jmsConduit = setupJMSConduit(ei);
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage.set(m);
synchronized (inMessage) {
inMessage.notifyAll();
}
}
};
jmsConduit.setMessageObserver(observer);
return jmsConduit;
}
Aggregations