Search in sources :

Example 1 with RSocketService

use of com.alibaba.rsocket.RSocketService in project alibaba-rsocket-broker by alibaba.

the class RSocketRequesterSupportImpl method exposedServices.

@Override
public Supplier<Set<ServiceLocator>> exposedServices() {
    return () -> {
        return applicationContext.getBeansWithAnnotation(RSocketService.class).values().stream().filter(bean -> !(bean instanceof RSocketServiceHealth || bean instanceof MetricsService)).map(o -> {
            Class<?> managedBeanClass = AopUtils.isAopProxy(o) ? AopUtils.getTargetClass(o) : o.getClass();
            RSocketService rsocketService = AnnotationUtils.findAnnotation(managedBeanClass, RSocketService.class);
            // noinspection ConstantConditions
            String serviceName = rsocketService.serviceInterface().getCanonicalName();
            if (!rsocketService.name().isEmpty()) {
                serviceName = rsocketService.name();
            }
            String group = properties.getGroup();
            if (group == null || group.isEmpty()) {
                group = rsocketService.group();
            }
            String version = properties.getVersion();
            if (version == null || version.isEmpty()) {
                version = rsocketService.version();
            }
            return new ServiceLocator(group, serviceName, version, rsocketService.tags());
        }).collect(Collectors.toSet());
    };
}
Also used : java.util(java.util) RSocketServiceHealth(com.alibaba.rsocket.health.RSocketServiceHealth) AopUtils(org.springframework.aop.support.AopUtils) URL(java.net.URL) RSocketAppContext(com.alibaba.rsocket.RSocketAppContext) RSocketRequesterSupport(com.alibaba.rsocket.RSocketRequesterSupport) Supplier(java.util.function.Supplier) Unpooled(io.netty.buffer.Unpooled) RSocketRemoteServiceBuilder(com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) ServicesExposedEvent(com.alibaba.rsocket.events.ServicesExposedEvent) CloudEventImpl(com.alibaba.rsocket.cloudevents.CloudEventImpl) URI(java.net.URI) ByteBufPayload(io.rsocket.util.ByteBufPayload) MetricsService(com.alibaba.rsocket.observability.MetricsService) RSocketService(com.alibaba.rsocket.RSocketService) ResourceLoader(org.springframework.core.io.ResourceLoader) UTF_8(java.nio.charset.StandardCharsets.UTF_8) AnnotationUtils(org.springframework.core.annotation.AnnotationUtils) BeansException(org.springframework.beans.BeansException) IOException(java.io.IOException) Reader(java.io.Reader) SocketAcceptor(io.rsocket.SocketAcceptor) ApplicationContext(org.springframework.context.ApplicationContext) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) RSocketInterceptor(io.rsocket.plugins.RSocketInterceptor) Payload(io.rsocket.Payload) NetworkUtil(com.alibaba.rsocket.transport.NetworkUtil) com.alibaba.rsocket.metadata(com.alibaba.rsocket.metadata) NotNull(org.jetbrains.annotations.NotNull) ServiceLocator(com.alibaba.rsocket.ServiceLocator) ApplicationContextAware(org.springframework.context.ApplicationContextAware) FileCopyUtils(org.springframework.util.FileCopyUtils) InputStream(java.io.InputStream) ServiceLocator(com.alibaba.rsocket.ServiceLocator) RSocketService(com.alibaba.rsocket.RSocketService) MetricsService(com.alibaba.rsocket.observability.MetricsService) RSocketServiceHealth(com.alibaba.rsocket.health.RSocketServiceHealth)

Example 2 with RSocketService

use of com.alibaba.rsocket.RSocketService in project alibaba-rsocket-broker by alibaba.

the class RSocketServiceAnnotationProcessor method scanRSocketServiceAnnotation.

protected void scanRSocketServiceAnnotation(Object bean, String beanName) {
    Class<?> managedBeanClass = bean.getClass();
    RSocketService reactiveService = AnnotationUtils.findAnnotation(managedBeanClass, RSocketService.class);
    if (reactiveService != null) {
        registerRSocketService(reactiveService, bean);
    }
    SpringRSocketService springRSocketService = AnnotationUtils.findAnnotation(managedBeanClass, SpringRSocketService.class);
    if (springRSocketService != null) {
        registerRSocketService(springRSocketService, bean);
    }
}
Also used : SpringRSocketService(com.alibaba.rsocket.spring.SpringRSocketService) RSocketService(com.alibaba.rsocket.RSocketService) SpringRSocketService(com.alibaba.rsocket.spring.SpringRSocketService)

Aggregations

RSocketService (com.alibaba.rsocket.RSocketService)2 RSocketAppContext (com.alibaba.rsocket.RSocketAppContext)1 RSocketRequesterSupport (com.alibaba.rsocket.RSocketRequesterSupport)1 ServiceLocator (com.alibaba.rsocket.ServiceLocator)1 CloudEventImpl (com.alibaba.rsocket.cloudevents.CloudEventImpl)1 ServicesExposedEvent (com.alibaba.rsocket.events.ServicesExposedEvent)1 RSocketServiceHealth (com.alibaba.rsocket.health.RSocketServiceHealth)1 RSocketRemoteServiceBuilder (com.alibaba.rsocket.invocation.RSocketRemoteServiceBuilder)1 com.alibaba.rsocket.metadata (com.alibaba.rsocket.metadata)1 MetricsService (com.alibaba.rsocket.observability.MetricsService)1 SpringRSocketService (com.alibaba.rsocket.spring.SpringRSocketService)1 NetworkUtil (com.alibaba.rsocket.transport.NetworkUtil)1 Unpooled (io.netty.buffer.Unpooled)1 Payload (io.rsocket.Payload)1 SocketAcceptor (io.rsocket.SocketAcceptor)1 RSocketInterceptor (io.rsocket.plugins.RSocketInterceptor)1 ByteBufPayload (io.rsocket.util.ByteBufPayload)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1