DirectComponent implements ServiceComponent { public static String getServiceUri(String id) { ServiceProvider<?> provider = providerById.get(id); if (provider == null) { throw new IllegalArgumentException("No provider registered with id: " + id); } return AstrixServiceComponentNames.DIRECT + ":" + id; } DirectComponent(ObjectSerializerFactory objectSerializerFactory, ReactiveTypeConverter reactiveTypeConverter); List<? extends BoundServiceBeanInstance<?>> getBoundServices(); @Override BoundServiceBeanInstance<T> bind(ServiceDefinition<T> serviceDefinition, ServiceProperties serviceProperties); @Override ServiceProperties parseServiceProviderUri(String serviceProviderUri); @Override String getName(); @Override boolean canBindType(Class<?> type); static String register(Class<T> type, T provider); static String register(Class<T> type, T provider, String id); static void unregister(String id); static ServiceProperties registerAndGetProperties(Class<T> type, T provider); static ServiceProperties getServiceProperties(String id); static String getServiceUri(String id); Collection<ServiceProvider<?>> listProviders(); void clear(String id); @Override void exportService(Class<T> providedApi, T provider, ServiceDefinition<T> serviceDefinition); @Override boolean requiresProviderInstance(); @Override ServiceProperties createServiceProperties(ServiceDefinition<T> exportedService); static String registerAndGetUri(Class<T> api, T provider); static String registerAndGetUri(Class<T> api, T provider, ObjectSerializerDefinition serverSerializerDefinition);  }
@Test public void itsPossibleToStubReactiveServiceUsingDirectComponent() throws Exception { InMemoryServiceRegistry serviceRegistry = new InMemoryServiceRegistry(); serviceRegistry.registerProvider(Ping.class, new PingImpl()); TestAstrixConfigurer astrixConfigurer = new TestAstrixConfigurer(); astrixConfigurer.registerApiProvider(PingApiProvider.class); astrixConfigurer.set(AstrixSettings.SERVICE_REGISTRY_URI, serviceRegistry.getServiceUri()); astrixContext = astrixConfigurer.configure(); PingAsync ping = astrixContext.getBean(PingAsync.class); assertEquals("foo", ping.ping("foo").get()); }