use of org.apache.cxf.endpoint.ServerRegistry in project cxf by apache.
the class StartEndpointCommand method execute.
@Override
public Object execute() throws Exception {
Bus b = getBus(busName);
ServerRegistry reg = b.getExtension(ServerRegistry.class);
List<Server> servers = reg.getServers();
for (Server serv : servers) {
if (endpoint.equals(serv.getEndpoint().getEndpointInfo().getName().getLocalPart())) {
serv.start();
}
}
return null;
}
use of org.apache.cxf.endpoint.ServerRegistry in project cxf by apache.
the class StopEndpointCommand method execute.
@Override
public Object execute() throws Exception {
Bus b = getBus(busName);
ServerRegistry reg = b.getExtension(ServerRegistry.class);
List<Server> servers = reg.getServers();
for (Server serv : servers) {
if (endpoint.equals(serv.getEndpoint().getEndpointInfo().getName().getLocalPart())) {
serv.stop();
}
}
return null;
}
use of org.apache.cxf.endpoint.ServerRegistry in project cxf by apache.
the class EndpointCompleterSupport method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> list) {
StringsCompleter delegate = new StringsCompleter();
try {
List<Bus> busses = getBusses();
for (Bus b : busses) {
ServerRegistry reg = b.getExtension(ServerRegistry.class);
List<Server> servers = reg.getServers();
for (Server serv : servers) {
if (acceptsFeature(serv)) {
String qname = serv.getEndpoint().getEndpointInfo().getName().getLocalPart();
delegate.getStrings().add(qname);
}
}
}
} catch (Exception e) {
// Ignore
}
return delegate.complete(session, commandLine, list);
}
use of org.apache.cxf.endpoint.ServerRegistry in project cxf by apache.
the class ColocOutInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
if (bus == null) {
bus = message.getExchange().getBus();
if (bus == null) {
bus = BusFactory.getDefaultBus(false);
}
if (bus == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("BUS_NOT_FOUND", BUNDLE));
}
}
ServerRegistry registry = bus.getExtension(ServerRegistry.class);
if (registry == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("SERVER_REGISTRY_NOT_FOUND", BUNDLE));
}
Exchange exchange = message.getExchange();
Endpoint senderEndpoint = exchange.getEndpoint();
if (senderEndpoint == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_FOUND", BUNDLE));
}
BindingOperationInfo boi = exchange.getBindingOperationInfo();
if (boi == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("OPERATIONINFO_NOT_FOUND", BUNDLE));
}
Server srv = isColocated(registry.getServers(), senderEndpoint, boi);
if (srv != null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Operation:" + boi.getName() + " dispatched as colocated call.");
}
InterceptorChain outChain = message.getInterceptorChain();
outChain.abort();
exchange.put(Bus.class, bus);
message.put(COLOCATED, Boolean.TRUE);
message.put(Message.WSDL_OPERATION, boi.getName());
message.put(Message.WSDL_INTERFACE, boi.getBinding().getInterface().getName());
invokeColocObserver(message, srv.getEndpoint());
if (!exchange.isOneWay()) {
invokeInboundChain(exchange, senderEndpoint);
}
} else {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Operation:" + boi.getName() + " dispatched as remote call.");
}
message.put(COLOCATED, Boolean.FALSE);
}
}
use of org.apache.cxf.endpoint.ServerRegistry in project cxf by apache.
the class ColocOutInterceptorTest method testColocOutIsColocatedPropertySet.
@Test
public void testColocOutIsColocatedPropertySet() throws Exception {
colocOut = new TestColocOutInterceptor1();
Bus bus = setupBus();
ServerRegistry sr = control.createMock(ServerRegistry.class);
EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
ex.put(Endpoint.class, sep);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
BindingInfo sbi = control.createMock(BindingInfo.class);
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
ex.put(BindingOperationInfo.class, sboi);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
EasyMock.expect(sr.getServers()).andReturn(list);
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).anyTimes();
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op).anyTimes();
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
InterceptorChain chain = control.createMock(InterceptorChain.class);
msg.setInterceptorChain(chain);
EasyMock.expect(sboi.getBinding()).andReturn(sbi);
EasyMock.expect(sbi.getInterface()).andReturn(sii);
control.replay();
colocOut.handleMessage(msg);
assertEquals("COLOCATED property should be set", Boolean.TRUE, msg.get(COLOCATED));
assertEquals("Message.WSDL_OPERATION property should be set", op, msg.get(Message.WSDL_OPERATION));
assertEquals("Message.WSDL_INTERFACE property should be set", intf, msg.get(Message.WSDL_INTERFACE));
control.verify();
}
Aggregations