Search in sources :

Example 6 with ServerRegistry

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;
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 7 with ServerRegistry

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;
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 8 with ServerRegistry

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);
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 9 with ServerRegistry

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);
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Server(org.apache.cxf.endpoint.Server) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) Fault(org.apache.cxf.interceptor.Fault)

Example 10 with ServerRegistry

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();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) Service(org.apache.cxf.service.Service) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Aggregations

ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)12 Server (org.apache.cxf.endpoint.Server)9 Bus (org.apache.cxf.Bus)8 Test (org.junit.Test)4 Endpoint (org.apache.cxf.endpoint.Endpoint)3 Fault (org.apache.cxf.interceptor.Fault)3 QName (javax.xml.namespace.QName)2 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 ArrayList (java.util.ArrayList)1 ServerImpl (org.apache.cxf.endpoint.ServerImpl)1 Exchange (org.apache.cxf.message.Exchange)1 Service (org.apache.cxf.service.Service)1 BindingInfo (org.apache.cxf.service.model.BindingInfo)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 Destination (org.apache.cxf.transport.Destination)1 MultiplexDestination (org.apache.cxf.transport.MultiplexDestination)1