use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method createOperation.
protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf, Method m) {
OperationInfo op = intf.addOperation(getOperationName(intf, m));
op.setProperty(m.getClass().getName(), m);
op.setProperty("action", getAction(op, m));
final Annotation[] annotations = m.getAnnotations();
final Annotation[][] parAnnotations = m.getParameterAnnotations();
op.setProperty(METHOD_ANNOTATIONS, annotations);
op.setProperty(METHOD_PARAM_ANNOTATIONS, parAnnotations);
boolean isrpc = isRPC(m);
if (!isrpc && isWrapped(m)) {
UnwrappedOperationInfo uOp = new UnwrappedOperationInfo(op);
uOp.setProperty(METHOD_ANNOTATIONS, annotations);
uOp.setProperty(METHOD_PARAM_ANNOTATIONS, parAnnotations);
op.setUnwrappedOperation(uOp);
createMessageParts(intf, uOp, m);
if (uOp.hasInput()) {
MessageInfo msg = new MessageInfo(op, MessageInfo.Type.INPUT, uOp.getInput().getName());
op.setInput(uOp.getInputName(), msg);
createInputWrappedMessageParts(uOp, m, msg);
for (MessagePartInfo p : uOp.getInput().getMessageParts()) {
p.setConcreteName(p.getName());
}
}
if (uOp.hasOutput()) {
QName name = uOp.getOutput().getName();
MessageInfo msg = new MessageInfo(op, MessageInfo.Type.OUTPUT, name);
op.setOutput(uOp.getOutputName(), msg);
createOutputWrappedMessageParts(uOp, m, msg);
for (MessagePartInfo p : uOp.getOutput().getMessageParts()) {
p.setConcreteName(p.getName());
}
}
} else {
if (isrpc) {
op.setProperty(FORCE_TYPES, Boolean.TRUE);
}
createMessageParts(intf, op, m);
}
bindOperation(op, m);
sendEvent(Event.INTERFACE_OPERATION_BOUND, op, m);
return op;
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithSameOperation.
private void verifyIsColocatedWithSameOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ColocOutInterceptorTest method verifyIsColocatedWithCompatibleOperation.
private void verifyIsColocatedWithCompatibleOperation() {
colocOut = new TestColocOutInterceptor1();
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
QName inmi = new QName("M", "in");
QName outmi = new QName("M", "out");
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
MessagePartInfo mpi = mii.addMessagePart("parameters");
mpi.setTypeClass(Source.class);
MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
mpi = mio.addMessagePart("parameters");
mpi.setTypeClass(Source.class);
soi.setInput("in", mii);
soi.setOutput("out", mio);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
mii = new MessageInfo(roi, MessageInfo.Type.INPUT, inmi);
mpi = mii.addMessagePart("parameters");
mpi.setTypeClass(Object.class);
mio = new MessageInfo(roi, MessageInfo.Type.OUTPUT, outmi);
mpi = mio.addMessagePart("parameters");
mpi.setTypeClass(Object.class);
roi.setInput("in", mii);
roi.setOutput("out", mio);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op);
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op);
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
control.replay();
Server val = colocOut.isColocated(list, sep, sboi);
assertEquals("Expecting a colocated call", s1, val);
control.reset();
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class ColocUtilTest method testIsSameFaultInfo.
@Test
public void testIsSameFaultInfo() {
OperationInfo oi = control.createMock(OperationInfo.class);
boolean match = ColocUtil.isSameFaultInfo(null, null);
assertEquals("Should return true", true, match);
List<FaultInfo> fil1 = new ArrayList<>();
match = ColocUtil.isSameFaultInfo(fil1, null);
assertEquals("Should not find a match", false, match);
match = ColocUtil.isSameFaultInfo(null, fil1);
assertEquals("Should not find a match", false, match);
List<FaultInfo> fil2 = new ArrayList<>();
match = ColocUtil.isSameFaultInfo(fil1, fil2);
QName fn1 = new QName("A", "B");
QName fn2 = new QName("C", "D");
FaultInfo fi1 = new FaultInfo(fn1, null, oi);
fi1.setProperty(Class.class.getName(), PingMeFault.class);
fil1.add(fi1);
FaultInfo fi2 = new FaultInfo(fn2, null, oi);
fi2.setProperty(Class.class.getName(), FaultDetailT.class);
match = ColocUtil.isSameFaultInfo(fil1, fil2);
assertEquals("Should not find a match", false, match);
FaultInfo fi3 = new FaultInfo(fn2, null, oi);
fi3.setProperty(Class.class.getName(), PingMeFault.class);
fil2.add(fi3);
match = ColocUtil.isSameFaultInfo(fil1, fil2);
assertEquals("Should find a match", true, match);
}
use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.
the class HolderOutInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
MessageContentsList outObjects = MessageContentsList.getContentsList(message);
Exchange exchange = message.getExchange();
OperationInfo op = exchange.getBindingOperationInfo() == null ? null : exchange.getBindingOperationInfo().getOperationInfo();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("op: " + op);
if (null != op) {
LOG.fine("op.hasOutput(): " + op.hasOutput());
if (op.hasOutput()) {
LOG.fine("op.getOutput().size(): " + op.getOutput().size());
}
}
}
if (op == null || !op.hasOutput() || op.getOutput().size() == 0) {
LOG.fine("Returning.");
return;
}
if (!Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
List<MessagePartInfo> parts = op.getOutput().getMessageParts();
MessageContentsList inObjects = MessageContentsList.getContentsList(exchange.getInMessage());
if (inObjects != null) {
if (!(inObjects == outObjects)) {
for (int x = 0; x < inObjects.size(); x++) {
Object o = inObjects.get(x);
if (o instanceof Holder) {
outObjects.set(x + 1, o);
}
}
} else {
LOG.severe("CANNOT_SET_HOLDER_OBJECTS");
throw new Fault(new org.apache.cxf.common.i18n.Message("CANNOT_SET_HOLDER_OBJECTS", LOG));
}
}
for (MessagePartInfo part : parts) {
if (part.getIndex() > 0 && part.getTypeClass() != null) {
Holder<?> holder = (Holder<?>) outObjects.get(part);
outObjects.put(part, holder.value);
}
}
} else {
List<Object> holders = new ArrayList<>(outObjects);
for (int x = 0; x < outObjects.size(); x++) {
Object o = outObjects.get(x);
if (o instanceof Holder) {
outObjects.set(x, ((Holder<?>) o).value);
} else {
holders.set(x, null);
}
}
message.put(HolderInInterceptor.CLIENT_HOLDERS, holders);
}
}
Aggregations