use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method initializeWSDLOperations.
protected void initializeWSDLOperations() {
List<OperationInfo> removes = new ArrayList<>();
Method[] methods = serviceClass.getMethods();
Arrays.sort(methods, new MethodComparator());
InterfaceInfo intf = getInterfaceInfo();
Map<QName, Method> validMethods = new HashMap<>();
for (Method m : methods) {
if (isValidMethod(m)) {
QName opName = getOperationName(intf, m);
validMethods.put(opName, m);
}
}
for (OperationInfo o : intf.getOperations()) {
Method selected = null;
for (Map.Entry<QName, Method> m : validMethods.entrySet()) {
QName opName = m.getKey();
if (o.getName().getNamespaceURI().equals(opName.getNamespaceURI()) && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart())) {
selected = m.getValue();
break;
}
}
if (selected == null) {
LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
removes.add(o);
} else {
initializeWSDLOperation(intf, o, selected);
}
}
for (OperationInfo op : removes) {
intf.removeOperation(op);
}
// Update the bindings.
for (ServiceInfo service : getService().getServiceInfos()) {
for (BindingInfo bi : service.getBindings()) {
List<BindingOperationInfo> biremoves = new ArrayList<>();
for (BindingOperationInfo binfo : bi.getOperations()) {
if (removes.contains(binfo.getOperationInfo())) {
biremoves.add(binfo);
} else {
binfo.updateUnwrappedOperation();
}
}
for (BindingOperationInfo binfo : biremoves) {
bi.removeOperation(binfo);
}
}
}
sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JAXRSServiceImpl method getServiceInfos.
public List<ServiceInfo> getServiceInfos() {
if (!createServiceModel) {
return Collections.emptyList();
}
// try to convert to WSDL-centric model so that CXF DataBindings can get initialized
// might become useful too if we support wsdl2
// make databindings to use databinding-specific information
// like @XmlRootElement for ex to select a namespace
this.put("org.apache.cxf.databinding.namespace", "true");
List<ServiceInfo> infos = new ArrayList<>();
for (ClassResourceInfo cri : classResourceInfos) {
ServiceInfo si = new ServiceInfo();
infos.add(si);
QName qname = JAXRSUtils.getClassQName(cri.getServiceClass());
si.setName(qname);
InterfaceInfo inf = new InterfaceInfo(si, qname);
si.setInterface(inf);
for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos()) {
Method m = ori.getMethodToInvoke();
QName oname = new QName(qname.getNamespaceURI(), m.getName());
OperationInfo oi = inf.addOperation(oname);
createMessagePartInfo(oi, m.getReturnType(), qname, m, false);
for (Parameter pm : ori.getParameters()) {
if (pm.getType() == ParameterType.REQUEST_BODY) {
createMessagePartInfo(oi, ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()], qname, m, true);
}
}
}
}
return infos;
}
Aggregations