Java Code Examples for org.apache.cxf.service.model.EndpointInfo#getAddress()

The following examples show how to use org.apache.cxf.service.model.EndpointInfo#getAddress() . 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: CxfWSDLImporter.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected WSService importService(ServiceInfo service) {
    String name = service.getName().getLocalPart();
    String location = "";

    for (EndpointInfo endpoint : service.getEndpoints()) {
        location = endpoint.getAddress();
    }

    WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
    for (OperationInfo operation : service.getInterface().getOperations()) {
        WSOperation wsOperation = this.importOperation(operation, wsService);
        wsService.addOperation(wsOperation);

        this.wsOperations.put(this.namespace + operation.getName().getLocalPart(), wsOperation);
    }
    return wsService;
}
 
Example 2
Source File: AbstractHTTPDestination.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected static EndpointInfo getAddressValue(EndpointInfo ei, boolean dp) {
    if (dp) {

        String eiAddress = ei.getAddress();
        if (eiAddress == null) {
            try {
                ServerSocket s = new ServerSocket(0);
                ei.setAddress("http://localhost:" + s.getLocalPort());
                s.close();
                return ei;
            } catch (IOException ex) {
                // problem allocating a random port, go to the default one
                ei.setAddress("http://localhost");
            }
        }

        String addr = StringUtils.addDefaultPortIfMissing(ei.getAddress());
        if (addr != null) {
            ei.setAddress(addr);
        }
    }
    return ei;
}
 
Example 3
Source File: HttpUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String getEndpointAddress(Message m) {
    String address = null;
    Destination d = m.getExchange().getDestination();
    if (d != null) {
        if (d instanceof AbstractHTTPDestination) {
            EndpointInfo ei = ((AbstractHTTPDestination)d).getEndpointInfo();
            HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
            Object property = request != null
                ? request.getAttribute("org.apache.cxf.transport.endpoint.address") : null;
            address = property != null ? property.toString() : ei.getAddress();
        } else {
            address = m.containsKey(Message.BASE_PATH)
                ? (String)m.get(Message.BASE_PATH) : d.getAddress().getAddress().getValue();
        }
    } else {
        address = (String)m.get(Message.ENDPOINT_ADDRESS);
    }
    if (address.startsWith("http") && address.endsWith("//")) {
        address = address.substring(0, address.length() - 1);
    }
    return address;
}
 
Example 4
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
    try {

        String address = ei.getAddress();
        if (address == null) {
            address = "http://localhost:9090";
        }

        ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
        SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
        soapAddress.setLocationURI(address);

        ei.addExtensor(soapAddress);

    } catch (WSDLException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: CxfWSDLImporter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected WSService importService(ServiceInfo service) {
  String name = service.getName().getLocalPart();
  String location = "";
  
  for (EndpointInfo endpoint : service.getEndpoints()) {
    location = endpoint.getAddress();
  }
  
  WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
  for (OperationInfo operation : service.getInterface().getOperations()) {
    WSOperation wsOperation = this.importOperation(operation, wsService);
    wsService.addOperation(wsOperation);

    this.wsOperations.put(this.namespace + operation.getName().getLocalPart(), wsOperation);
  }
  return wsService;
}
 
Example 6
Source File: AsyncHttpTransportFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected String getAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("hc://")) {
        address = address.substring(5);
    }
    return address;
}
 
Example 7
Source File: UndertowWebSocketDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static String getNonWSAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("ws")) {
        address = "http" + address.substring(2);
    }
    return address;
}
 
Example 8
Source File: NettyHttpDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
private String getAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("netty://")) {
        address = address.substring(8);
    }
    return address;
}
 
Example 9
Source File: AtmosphereWebSocketJettyDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static String getNonWSAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("ws")) {
        address = "http" + address.substring(2);
    }
    return address;
}
 
Example 10
Source File: NettyHttpTransportFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected String getAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("netty://")) {
        address = address.substring(8);
    }
    return address;
}
 
Example 11
Source File: ServiceJavascriptBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void begin(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    String portClassName = currentInterfaceClassName + "_"
        + nameManager.getJavascriptName(endpointInfo.getName());
    code.append("function " + portClassName + " () {\n");
    code.append("  this.url = '" + address + "';\n");
    code.append("}\n");
    code.append(portClassName + ".prototype = new " + currentInterfaceClassName + ";\n");
}
 
Example 12
Source File: HttpHandlerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(HttpExchange exchange) throws IOException {
    try {
        //Update address in EndpointInfo; this can only happen here,
        //as the contextPath is provided in the HttpExchange only
        EndpointInfo ei = destination.getEndpointInfo();
        if (ei != null) {
            String ad = ei.getAddress();
            String path = exchange.getHttpContext().getPath();
            if (ad != null && ad.equals(path)) {
                synchronized (ei) {
                    String contextPath = exchange.getContextPath();
                    ei.setAddress(contextPath + path);
                    if (ei.getExtensor(AddressType.class) != null) {
                        ei.getExtensor(AddressType.class).setLocation(contextPath + path);
                    } else if (ei.getExtensor(SoapAddress.class) != null) {
                        ei.getExtensor(SoapAddress.class).setLocationURI(contextPath + path);
                    }
                }
            }
        }
        //service request
        destination.doService(new HttpServletRequestAdapter(exchange),
                              new HttpServletResponseAdapter(exchange));
    } finally {
        exchange.close();
    }
}
 
Example 13
Source File: NettyHttpTransportFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected String getAddress(EndpointInfo endpointInfo) {
    String address = endpointInfo.getAddress();
    if (address.startsWith("netty://")) {
        address = address.substring(8);
    }
    return address;
}
 
Example 14
Source File: ServerImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void initDestination(DestinationFactory destinationFactory) throws BusException, IOException {
    EndpointInfo ei = endpoint.getEndpointInfo();

    //Treat local transport as a special case, transports loaded by transportId can be replaced
    //by local transport when the publishing address is a local transport protocol.
    //Of course its not an ideal situation here to use a hard-coded prefix. To be refactored.
    if (destinationFactory == null) {
        if (ei.getAddress() != null && ei.getAddress().indexOf("local://") != -1) {
            destinationFactory = bus.getExtension(DestinationFactoryManager.class)
                .getDestinationFactoryForUri(ei.getAddress());
        }

        if (destinationFactory == null) {
            destinationFactory = bus.getExtension(DestinationFactoryManager.class)
                .getDestinationFactory(ei.getTransportId());
        }
    }

    destination = destinationFactory.getDestination(ei, bus);
    String wantFilter = ei.getAddress();
    
    if (wantFilter != null && wantFilter.startsWith("jms")) {
        RegexLoggingFilter filter = new RegexLoggingFilter();
        filter.setPattern("jms(.*?)password=+([^ ]+)");
        filter.setGroup(2);
        wantFilter = filter.filter(wantFilter).toString();
    }
    LOG.info("Setting the server's publish address to be " + wantFilter);
    serverRegistry = bus.getExtension(ServerRegistry.class);

    mep = new ManagedEndpoint(bus, endpoint, this);

    slcMgr = bus.getExtension(ServerLifeCycleManager.class);
    if (slcMgr != null) {
        slcMgr.registerListener(mep);
    }

    iMgr = bus.getExtension(InstrumentationManager.class);
    if (iMgr != null) {
        try {
            iMgr.register(mep);
        } catch (JMException jmex) {
            LOG.log(Level.WARNING, "Registering ManagedEndpoint failed.", jmex);
        }
    }
}
 
Example 15
Source File: UndertowHTTPDestination.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
public String getAddress(EndpointInfo endpointInfo) {
    return endpointInfo.getAddress();
}
 
Example 16
Source File: JAXWSHttpSpiDestination.java    From cxf with Apache License 2.0 4 votes vote down vote up
public JAXWSHttpSpiDestination(Bus b,
                               DestinationRegistry registry,
                               EndpointInfo ei) throws IOException {
    super(b, registry, ei, ei.getAddress(), false);
}
 
Example 17
Source File: ServletDestinationFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
public AbstractHTTPDestination createDestination(EndpointInfo endpointInfo,
                                                 Bus bus,
                                                 DestinationRegistry registry) throws IOException {
    return new ServletDestination(bus, registry, endpointInfo, endpointInfo.getAddress());
}
 
Example 18
Source File: JettyHTTPDestination.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected String getAddress(EndpointInfo endpointInfo) {
    return endpointInfo.getAddress();
}
 
Example 19
Source File: UndertowHTTPDestination.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected String getAddress(EndpointInfo endpointInfo) {
    return endpointInfo.getAddress();
}
 
Example 20
Source File: JMSEndpoint.java    From cxf with Apache License 2.0 2 votes vote down vote up
/**
 * Get the extensors from the wsdl and/or configuration that will
 * then be used to configure the JMSConfiguration object
 * @param endpointInfo
 * @param target
 */
public JMSEndpoint(EndpointInfo endpointInfo, EndpointReferenceType target) {
    this(endpointInfo,  target == null ? endpointInfo.getAddress() : target.getAddress().getValue());
}