private UniverseFactoryLoader() { final ServiceLoader<UniverseFactory> loader = ServiceLoader.load(UniverseFactory.class); Map<String, UniverseFactory> factories = Collections.emptyMap(); for(UniverseFactory factory : loader) { if(factories.isEmpty()) { factories = Collections.singletonMap(factory.getFactoryId(), factory); continue; } if(factories.containsKey(factory.getFactoryId())) { throw new IllegalStateException("Only one universe factory is allowed per repository type " + factory.getFactoryId() + " but found " + factory + " and " + factories.get(factory.getFactoryId())); } if(factories.size() == 1) { final HashMap<String, UniverseFactory> tmp = new HashMap<>(2); tmp.putAll(factories); factories = tmp; } factories.put(factory.getFactoryId(), factory); } this.factories = CollectionUtils.unmodifiable(factories); }
public Universe<?> getUniverse(String factoryId, String location) throws ProvisioningException { final UniverseFactory factory = getUniverseFactory(factoryId); return factory.getUniverse(getArtifactResolver(factory.getRepositoryId()), location); }
public Universe<?> getUniverse(String factoryId, String location, RepositoryArtifactResolver artifactResolver) throws ProvisioningException { final UniverseFactory factory = getUniverseFactory(factoryId); if(artifactResolver == null) { throw new ProvisioningException("artifactResolver is null"); } return factory.getUniverse(artifactResolver, location); }
public Universe<?> getUniverse(String factoryId, String location, String repoId) throws ProvisioningException { return getUniverseFactory(factoryId).getUniverse(getArtifactResolver(repoId), location); }
public Universe<?> getUniverse(UniverseSpec universeSpec) throws ProvisioningException { final UniverseFactory factory = getUniverseFactory(universeSpec.getFactory()); return factory.getUniverse(getArtifactResolver(factory.getRepositoryId()), universeSpec.getLocation()); }