- SpringComponent system = new SpringComponent("system", _registry,
- new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
- provided, required);
-
- HelloService helloObject = new HelloService("ladida");
- Service helloService = _registry.register(new AbstractProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
- Service[] services = system.start("Bla", new Service[] { helloService } );
- assertEquals(1, services.length);
-
- assertTrue(services[0].reference(BlaService.class) instanceof BlaService);
- assertEquals("ladida", services[0].reference(BlaService.class)
- .execute());
- system.stop();
+ SpringComponent system = new SpringComponent("system",
+ new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML }, provided,
+ required);
+
+ HelloService helloObject = new HelloService("ladida");
+ ProvidedInterface helloService = new DefaultProvidedInterface("hello",
+ HelloService.class);
+ Scope scope = new DefaultScope(new ProvidedInterface[] { helloService });
+ scope.publishInterface(helloService, helloObject);
+ system.getRequiredInterfaces()[0].setProvider(helloService);
+ Scope runtime = system.start(scope);
+ ProvidedInterface started = runtime.getProvidedInterfaces()[0];
+
+ Object impl = runtime.getInterfaceImplementation(started, BlaService.class);
+ assertNotNull(impl);
+ assertTrue(impl instanceof BlaService);
+ assertEquals("ladida", ((BlaService)impl).execute());
+ system.stop(runtime);