use of org.apache.cxf.ws.discovery.wsdl.HelloType in project cxf by apache.
the class WSDiscoveryClient method probe.
public ProbeMatchesType probe(ProbeType params, int timeout) {
Dispatch<Object> disp = this.getDispatchInternal(false, version.getProbeAction());
if (adHoc) {
disp.getRequestContext().put("udp.multi.response.timeout", timeout);
final ProbeMatchesType response = new ProbeMatchesType();
AsyncHandler<Object> handler = new AsyncHandler<Object>() {
public void handleResponse(Response<Object> res) {
try {
Object o = res.get();
while (o instanceof JAXBElement) {
o = ((JAXBElement) o).getValue();
}
if (o instanceof ProbeMatchesType) {
response.getProbeMatch().addAll(((ProbeMatchesType) o).getProbeMatch());
} else if (o instanceof HelloType) {
HelloType h = (HelloType) o;
QName sn = version.getServiceName();
if (h.getTypes().contains(sn) || h.getTypes().contains(new QName("", sn.getLocalPart()))) {
// A DiscoveryProxy wants us to flip to managed mode
uncache();
resetDispatch(h.getXAddrs().get(0));
}
}
} catch (InterruptedException e) {
// ?
} catch (ExecutionException e) {
// ?
}
}
};
disp.invokeAsync(new ObjectFactory().createProbe(params), handler);
return response;
}
Object o = disp.invoke(new ObjectFactory().createProbe(params));
while (o instanceof JAXBElement) {
o = ((JAXBElement) o).getValue();
}
return (ProbeMatchesType) o;
}
use of org.apache.cxf.ws.discovery.wsdl.HelloType in project cxf by apache.
the class WSDiscoveryClient method register.
/**
* Sends the "Hello" to broadcast the availability of a service
* @param ert The endpoint reference of the Service itself
* @return the Hello that was used to broadcast the availability.
*/
public HelloType register(EndpointReference ert) {
HelloType hello = new HelloType();
hello.setScopes(new ScopesType());
hello.setMetadataVersion(1);
EndpointReferenceType ref = ProviderImpl.convertToInternal(ert);
proccessEndpointReference(ref, hello.getScopes(), hello.getTypes(), hello.getXAddrs());
hello.setEndpointReference(generateW3CEndpointReference());
return register(hello);
}
use of org.apache.cxf.ws.discovery.wsdl.HelloType in project cxf by apache.
the class WSDiscoveryServiceImpl method handleProbe.
public ProbeMatchesType handleProbe(ProbeType pt) {
List<HelloType> consider = new LinkedList<HelloType>(registered);
// ALL types in the probe must be in the registered type
if (pt.getTypes() != null && !pt.getTypes().isEmpty()) {
ListIterator<HelloType> cit = consider.listIterator();
while (cit.hasNext()) {
HelloType ht = cit.next();
boolean matches = true;
for (QName qn : pt.getTypes()) {
if (!ht.getTypes().contains(qn)) {
matches = false;
}
}
if (!matches) {
cit.remove();
}
}
}
// next, consider the scopes
matchScopes(pt, consider);
if (consider.isEmpty()) {
return null;
}
ProbeMatchesType pmt = new ProbeMatchesType();
for (HelloType ht : consider) {
ProbeMatchType m = new ProbeMatchType();
m.setEndpointReference(ht.getEndpointReference());
m.setScopes(ht.getScopes());
m.setMetadataVersion(ht.getMetadataVersion());
m.getTypes().addAll(ht.getTypes());
m.getXAddrs().addAll(ht.getXAddrs());
pmt.getProbeMatch().add(m);
}
return pmt;
}
use of org.apache.cxf.ws.discovery.wsdl.HelloType in project cxf by apache.
the class WSDiscoveryServiceImpl method register.
public HelloType register(EndpointReference ref) {
startup(false);
HelloType ht = client.register(ref);
registered.add(ht);
return ht;
}
use of org.apache.cxf.ws.discovery.wsdl.HelloType in project cxf by apache.
the class WSDiscoveryServiceImpl method serverStarted.
public void serverStarted(Server server) {
Object o = getProperty(server, "ws-discovery-disable");
if (o == Boolean.TRUE || Boolean.valueOf((String) o)) {
return;
}
if (!startup(true)) {
return;
}
HelloType ht = new HelloType();
ht.setScopes(new ScopesType());
ht.setMetadataVersion(1);
o = getProperty(server, "ws-discovery-types");
if (o instanceof QName) {
ht.getTypes().add((QName) o);
} else if (o instanceof List) {
for (Object o2 : (List<?>) o) {
if (o2 instanceof QName) {
ht.getTypes().add((QName) o2);
} else if (o2 instanceof String) {
ht.getTypes().add(QName.valueOf((String) o2));
}
}
} else if (o instanceof String) {
ht.getTypes().add(QName.valueOf((String) o));
}
if (ht.getTypes().isEmpty()) {
QName sn = ServiceModelUtil.getServiceQName(server.getEndpoint().getEndpointInfo());
ht.getTypes().add(sn);
}
o = getProperty(server, "ws-discovery-scopes");
if (o != null) {
setScopes(ht, o);
}
setXAddrs(ht, server);
String uuid = (String) getProperty(server, "ws-discovery-uuid");
if (uuid != null) {
// persistent uuid
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.address(uuid);
ht.setEndpointReference(builder.build());
}
ht = client.register(ht);
registered.add(ht);
server.getEndpoint().put(HelloType.class.getName(), ht);
}
Aggregations