use of org.omg.CORBA.ServerRequest 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.omg.CORBA.ServerRequest in project cxf by apache.
the class CorbaServerConduit method buildRequestResult.
public void buildRequestResult(CorbaMessage msg) {
Exchange exg = msg.getExchange();
ServerRequest request = exg.get(ServerRequest.class);
try {
if (!exg.isOneWay()) {
CorbaMessage inMsg = (CorbaMessage) msg.getExchange().getInMessage();
NVList list = inMsg.getList();
if (msg.getStreamableException() != null) {
Any exAny = CorbaAnyHelper.createAny(orb);
CorbaStreamable exception = msg.getStreamableException();
exAny.insert_Streamable(exception);
request.set_exception(exAny);
if (msg.getExchange() != null) {
msg.getExchange().setOutFaultMessage(msg);
}
} else {
CorbaStreamable[] arguments = msg.getStreamableArguments();
if (arguments != null) {
for (int i = 0; i < arguments.length; ++i) {
if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
arguments[i].getObject().setIntoAny(list.item(i).value(), arguments[i], true);
}
}
}
CorbaStreamable resultValue = msg.getStreamableReturn();
if (resultValue != null) {
Any resultAny = CorbaAnyHelper.createAny(orb);
resultValue.getObject().setIntoAny(resultAny, resultValue, true);
request.set_result(resultAny);
}
}
}
} catch (java.lang.Exception ex) {
throw new CorbaBindingException("Exception during buildRequestResult", ex);
}
}
use of org.omg.CORBA.ServerRequest in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method setSystemException.
protected void setSystemException(CorbaMessage message, Throwable ex, CorbaDestination dest) {
SystemException sysEx = (SystemException) ex;
message.setSystemException(sysEx);
ServerRequest request = message.getExchange().get(ServerRequest.class);
Any exAny = dest.getOrbConfig().createSystemExceptionAny(orb, sysEx);
request.set_exception(exAny);
}
use of org.omg.CORBA.ServerRequest in project cxf by apache.
the class CorbaStreamInInterceptor method handleRequest.
private void handleRequest(Message msg) {
ORB orb;
ServiceInfo service;
CorbaDestination destination;
if (msg.getDestination() != null) {
destination = (CorbaDestination) msg.getDestination();
} else {
destination = (CorbaDestination) msg.getExchange().getDestination();
}
service = destination.getBindingInfo().getService();
CorbaMessage message = (CorbaMessage) msg;
Exchange exchange = message.getExchange();
CorbaTypeMap typeMap = message.getCorbaTypeMap();
BindingInfo bInfo = destination.getBindingInfo();
InterfaceInfo info = bInfo.getInterface();
String opName = exchange.get(String.class);
Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
OperationType opType = null;
BindingOperationInfo bopInfo = null;
QName opQName = null;
while (i.hasNext()) {
bopInfo = i.next();
if (bopInfo.getName().getLocalPart().equals(opName)) {
opType = bopInfo.getExtensor(OperationType.class);
opQName = bopInfo.getName();
break;
}
}
if (opType == null) {
throw new RuntimeException("Couldn't find the binding operation for " + opName);
}
orb = exchange.get(ORB.class);
ServerRequest request = exchange.get(ServerRequest.class);
NVList list = prepareArguments(message, info, opType, opQName, typeMap, destination, service);
request.arguments(list);
message.setList(list);
HandlerIterator paramIterator = new HandlerIterator(message, true);
CorbaTypeEventProducer eventProducer = null;
BindingMessageInfo msgInfo = bopInfo.getInput();
boolean wrap = false;
if (bopInfo.isUnwrappedCapable()) {
wrap = true;
}
if (wrap) {
// wrapper element around our args
QName wrapperElementQName = msgInfo.getMessageInfo().getName();
eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName, paramIterator, service, orb);
} else {
eventProducer = new ParameterEventProducer(paramIterator, service, orb);
}
CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
message.setContent(XMLStreamReader.class, reader);
}
use of org.omg.CORBA.ServerRequest in project cxf by apache.
the class CorbaServerConduitTest method testBuildRequestResultArgumentReturn.
@Test
public void testBuildRequestResultArgumentReturn() {
CorbaStreamable[] arguments = new CorbaStreamable[1];
QName objName = new QName("object");
QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
CorbaStreamable arg = new CorbaStreamableImpl(obj, objName);
arguments[0] = arg;
arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
NVList nvlist = orb.create_list(2);
Any value = orb.create_any();
value.insert_Streamable(arguments[0]);
nvlist.add_value(arguments[0].getName(), value, arguments[0].getMode());
CorbaServerConduit conduit = setupCorbaServerConduit(false);
CorbaMessage msg = control.createMock(CorbaMessage.class);
Exchange exchange = control.createMock(Exchange.class);
ServerRequest request = control.createMock(ServerRequest.class);
EasyMock.expect(msg.getExchange()).andReturn(exchange);
EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
EasyMock.expect(exchange.isOneWay()).andReturn(false);
EasyMock.expect(msg.getExchange()).andReturn(exchange);
Message message = new MessageImpl();
CorbaMessage corbaMessage = new CorbaMessage(message);
corbaMessage.setList(nvlist);
EasyMock.expect(exchange.getInMessage()).andReturn(corbaMessage);
EasyMock.expect(msg.getStreamableException()).andReturn(null);
EasyMock.expect(msg.getStreamableArguments()).andReturn(arguments);
EasyMock.expect(msg.getStreamableReturn()).andReturn(arg);
control.replay();
conduit.buildRequestResult(msg);
control.verify();
}
Aggregations