* @param manual If true, the service is manually added to the {@link ShutdownCoordinator}
*/
private Registry createRegistryWithSimpleService(final String serviceModel, final boolean manual)
{
ModuleDefinitionImpl module = createModuleDefinition("hivemind.lib.test");
ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
ServicePointDefinition sp1 = helper.addServicePoint("Simple", Simple.class.getName());
// Define inline implementation constructor, that passes the ShutdownCoordinator service if manual is true
ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(module.getLocation())
{
public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
{
Object result;
if (manual) {
ShutdownCoordinator coordinator = (ShutdownCoordinator) context.getService(ShutdownCoordinator.class);
result = new SimpleImpl(coordinator);
} else {
result = new SimpleImpl();
}
return result;
}
};
helper.addServiceImplementation(sp1, constructor, serviceModel);
return buildFrameworkRegistry(module);
}