]> source.dussan.org Git - archiva.git/commitdiff
Adding repository factory impl
authorJames William Dumay <jdumay@apache.org>
Thu, 12 Feb 2009 09:27:47 +0000 (09:27 +0000)
committerJames William Dumay <jdumay@apache.org>
Thu, 12 Feb 2009 09:27:47 +0000 (09:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-with-new-repoapi@743665 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java [new file with mode: 0644]

diff --git a/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java b/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java
new file mode 100644 (file)
index 0000000..0e92129
--- /dev/null
@@ -0,0 +1,29 @@
+package org.apache.archiva.repository;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.archiva.repository.api.Repository;
+import org.apache.archiva.repository.api.RepositoryFactory;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+
+public class DefaultRepositoryFactory implements RepositoryFactory
+{
+    private final ArchivaConfiguration archivaConfiguration;
+
+    public DefaultRepositoryFactory(ArchivaConfiguration archivaConfiguration)
+    {
+        this.archivaConfiguration = archivaConfiguration;
+    }
+
+    public Map<String, Repository> getRepositories()
+    {
+        final HashMap<String, Repository> repositories = new HashMap<String, Repository>();
+        for (ManagedRepositoryConfiguration configuration : archivaConfiguration.getConfiguration().getManagedRepositories())
+        {
+            repositories.put(configuration.getId(), new DefaultRepository(configuration.getId(), configuration.getName(), new File(configuration.getLocation())));
+        }
+        return repositories;
+    }
+}