Java Code Examples for org.apache.cxf.endpoint.ServerRegistry#getServers()

The following examples show how to use org.apache.cxf.endpoint.ServerRegistry#getServers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractWebServiceExporter.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/** 
 * This determines if the service has already been published on the CXF bus.
 * 
 * @return true if cxf server exists for this service.
 */
protected boolean isServicePublished(String serviceAddress) {
	
	ServerRegistry serverRegistry = getCXFServerRegistry();
	List<Server> servers = serverRegistry.getServers();
	
	for (Server server:servers){		
		String endpointAddress = server.getEndpoint().getEndpointInfo().getAddress();
		if (endpointAddress.contains(serviceAddress)){
			LOG.info("Service already published on CXF, not republishing: " + serviceAddress);
			return true;
		}
	}
	
	return false;
}
 
Example 2
Source File: EndpointCompleterSupport.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: EndpointReferenceUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static MultiplexDestination getMatchingMultiplexDestination(QName serviceQName, String portName,
                                                                    Bus bus) {
    MultiplexDestination destination = null;
    ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
    if (null != serverRegistry) {
        List<Server> servers = serverRegistry.getServers();
        for (Server s : servers) {
            QName targetServiceQName = s.getEndpoint().getEndpointInfo().getService().getName();
            if (serviceQName.equals(targetServiceQName) && portNameMatches(s, portName)) {
                Destination dest = s.getDestination();
                if (dest instanceof MultiplexDestination) {
                    destination = (MultiplexDestination)dest;
                    break;
                }
            }
        }
    } else {
        LOG.log(Level.WARNING,
                "Failed to locate service matching " + serviceQName
                + ", because the bus ServerRegistry extension provider is null");
    }
    return destination;
}
 
Example 4
Source File: NoSpringServletClientTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void stopServer() {
    ServerRegistry reg = serverBus.getExtension(ServerRegistry.class);
    List<Server> servers = reg.getServers();
    for (Server serv : servers) {
        serv.stop();
    }
}
 
Example 5
Source File: NoSpringServletClientTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void startServer() {
    ServerRegistry reg = serverBus.getExtension(ServerRegistry.class);
    List<Server> servers = reg.getServers();
    for (Server serv : servers) {
        serv.start();
    }
}
 
Example 6
Source File: StartEndpointCommand.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 7
Source File: StopEndpointCommand.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Definition getWSDLDefinition(String string) throws WSDLException {
    ServerRegistry svrMan = getBus().getExtension(ServerRegistry.class);
    for (Server s : svrMan.getServers()) {
        Service svc = s.getEndpoint().getService();
        if (svc.getName().getLocalPart().equals(string)) {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, svc.getServiceInfos());
            return builder.build();
        }
    }
    return null;

}
 
Example 9
Source File: TestUtilities.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Server getServerForService(QName serviceName) throws WSDLException {
    ServerRegistry svrMan = bus.getExtension(ServerRegistry.class);
    for (Server s : svrMan.getServers()) {
        Service svc = s.getEndpoint().getService();
        if (svc.getName().equals(serviceName)) {
            return s;
        }
    }
    return null;
}
 
Example 10
Source File: TestUtilities.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Server getServerForAddress(String address) throws WSDLException {
    ServerRegistry svrMan = bus.getExtension(ServerRegistry.class);
    for (Server s : svrMan.getServers()) {
        if (address.equals(s.getEndpoint().getEndpointInfo().getAddress())) {
            return s;
        }
    }
    return null;
}
 
Example 11
Source File: JAXWSEnvironment.java    From dropwizard-jaxws with Apache License 2.0 5 votes vote down vote up
public void logEndpoints() {
    ServerRegistry sr = bus.getExtension(org.apache.cxf.endpoint.ServerRegistry.class);
    if (sr.getServers().size() > 0) {
        String endpoints = "";
        for (Server s : sr.getServers()) {
            endpoints += "    " + this.defaultPath +  s.getEndpoint().getEndpointInfo().getAddress() +
                    " (" + s.getEndpoint().getEndpointInfo().getInterface().getName() + ")\n";
        }
        log.info("JAX-WS service endpoints [" + this.defaultPath + "]:\n\n" + endpoints);
    }
    else {
        log.info("No JAX-WS service endpoints were registered.");
    }
}