Search in sources :

Example 1 with SwaggerRestServiceImpl

use of com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl in project sofa-boot by alipay.

the class BoltSwaggerServiceApplicationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
    List<BindingParam> bindingParams = new ArrayList<>();
    bindingParams.add(new RestBindingParam());
    ServiceParam serviceParam = new ServiceParam();
    serviceParam.setInterfaceType(SwaggerRestService.class);
    serviceParam.setInstance(new SwaggerRestServiceImpl());
    serviceParam.setBindingParams(bindingParams);
    ServiceClient serviceClient = clientFactory.getClient(ServiceClient.class);
    serviceClient.service(serviceParam);
}
Also used : SwaggerRestServiceImpl(com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl) RestBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam) ServiceClient(com.alipay.sofa.runtime.api.client.ServiceClient) ArrayList(java.util.ArrayList) BindingParam(com.alipay.sofa.runtime.api.client.param.BindingParam) RestBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam) ServiceParam(com.alipay.sofa.runtime.api.client.param.ServiceParam)

Example 2 with SwaggerRestServiceImpl

use of com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl in project sofa-rpc by sofastack.

the class BoltServerMainWithSwagger method main.

public static void main(String[] args) {
    ApplicationConfig application = new ApplicationConfig().setAppName("test-server");
    ServerConfig serverConfig = new ServerConfig().setPort(22000).setDaemon(false);
    ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setApplication(application).setRef(new HelloServiceImpl()).setServer(serverConfig).setRegister(false);
    ProviderConfig<EchoService> providerConfig2 = new ProviderConfig<EchoService>().setInterfaceId(EchoService.class.getName()).setApplication(application).setRef(new EchoServiceImpl()).setServer(serverConfig).setRegister(false);
    providerConfig.export();
    providerConfig2.export();
    ServerConfig restServer = new ServerConfig().setProtocol("rest").setPort(8888).setDaemon(false);
    ProviderConfig<SwaggerRestService> restProviderConfig = new ProviderConfig<SwaggerRestService>().setInterfaceId(SwaggerRestService.class.getName()).setApplication(application).setRef(new SwaggerRestServiceImpl()).setBootstrap("rest").setServer(restServer).setRegister(false);
    restProviderConfig.export();
    LOGGER.warn("started at pid {}", RpcRuntimeContext.PID);
}
Also used : SwaggerRestServiceImpl(com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl) ServerConfig(com.alipay.sofa.rpc.config.ServerConfig) SwaggerRestService(com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestService) ApplicationConfig(com.alipay.sofa.rpc.config.ApplicationConfig) EchoService(com.alipay.sofa.rpc.test.EchoService) ProviderConfig(com.alipay.sofa.rpc.config.ProviderConfig) HelloService(com.alipay.sofa.rpc.test.HelloService) HelloServiceImpl(com.alipay.sofa.rpc.test.HelloServiceImpl) EchoServiceImpl(com.alipay.sofa.rpc.test.EchoServiceImpl)

Example 3 with SwaggerRestServiceImpl

use of com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl in project sofa-boot by sofastack.

the class BoltSwaggerServiceApplicationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
    List<BindingParam> bindingParams = new ArrayList<>();
    bindingParams.add(new RestBindingParam());
    ServiceParam serviceParam = new ServiceParam();
    serviceParam.setInterfaceType(SwaggerRestService.class);
    serviceParam.setInstance(new SwaggerRestServiceImpl());
    serviceParam.setBindingParams(bindingParams);
    ServiceClient serviceClient = clientFactory.getClient(ServiceClient.class);
    serviceClient.service(serviceParam);
}
Also used : SwaggerRestServiceImpl(com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl) RestBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam) ServiceClient(com.alipay.sofa.runtime.api.client.ServiceClient) ArrayList(java.util.ArrayList) BindingParam(com.alipay.sofa.runtime.api.client.param.BindingParam) RestBindingParam(com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam) ServiceParam(com.alipay.sofa.runtime.api.client.param.ServiceParam)

Aggregations

SwaggerRestServiceImpl (com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestServiceImpl)3 RestBindingParam (com.alipay.sofa.rpc.boot.runtime.param.RestBindingParam)2 ServiceClient (com.alipay.sofa.runtime.api.client.ServiceClient)2 BindingParam (com.alipay.sofa.runtime.api.client.param.BindingParam)2 ServiceParam (com.alipay.sofa.runtime.api.client.param.ServiceParam)2 ArrayList (java.util.ArrayList)2 ApplicationConfig (com.alipay.sofa.rpc.config.ApplicationConfig)1 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)1 ServerConfig (com.alipay.sofa.rpc.config.ServerConfig)1 SwaggerRestService (com.alipay.sofa.rpc.doc.swagger.rest.SwaggerRestService)1 EchoService (com.alipay.sofa.rpc.test.EchoService)1 EchoServiceImpl (com.alipay.sofa.rpc.test.EchoServiceImpl)1 HelloService (com.alipay.sofa.rpc.test.HelloService)1 HelloServiceImpl (com.alipay.sofa.rpc.test.HelloServiceImpl)1