I finally have some time to dig into this further. Unfortunately eclipse (STS, actually) is being a real pain and not letting me set breakpoints so I'm having to play with reflection instead of doing it more directly.
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
RepositorySystem rs = locator.getService(RepositorySystem.class);
System.out.println(" rs --> " + rs);
and when I ask the locator for a list of these services I get an empty list:
List<RepositorySystem> l = locator.getServices(RepositorySystem.class);
System.out.println(" cnt --> " + l.size());
but when I use a bit of reflection to peek at the underlying data structure I can find a value:
Field f = locator.getClass().getDeclaredField("entries");
f.setAccessible(true);
Map<Class, Object> map = (Map<Class, Object>) f.get(locator);
System.out.println(" contains --> " + map.containsKey(RepositorySystem.class));
Object obj = map.get(RepositorySystem.class);
and with a bit more reflection I see that there is one provider, of type DefaultRepositorySystem, but no instances. It's the latter that's returned by "getService()" and that's why I'm getting a null value. I don't know why I have a provider but no instance.
When I try creating a DefaultRepositorySystem directly I get a NPE in newLocalRepositoryManager() - I'm sure it's a null localRepositoryProvider. I see that that value is annotated with @Requirement.
This raises the question of initialization... it's failing when I try a naked junit test and when @RunWith SpringJUnit4ClassRunner, but I don't have a @ContextConfiguration in the latter case. Am I simply missing some magic initialization?
Bear