Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 15:9ad6ec2d09c3
Implemented restoring artifacts from database.
artifacts/trunk@30 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 07 Sep 2009 10:06:23 +0000 |
parents | 0d6badf6af42 |
children | 83a059c204f8 |
line wrap: on
line source
package de.intevation.artifactdatabase; import java.util.HashMap; import de.intevation.artifacts.ArtifactDatabase; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.Artifact; /** * @author Sascha L. Teichmann */ public class ArtifactDatabaseImpl implements ArtifactDatabase { protected String [] factoryNames; protected HashMap name2factory; protected Backend backend; protected Object context; public ArtifactDatabaseImpl() { } public ArtifactDatabaseImpl(FactoryBootstrap bootstrap, Backend backend) { name2factory = new HashMap(); ArtifactFactory [] factories = bootstrap.getArtifactFactories(); factoryNames = new String[factories.length]; for (int i = 0; i < factories.length; ++i) { ArtifactFactory factory = factories[i]; name2factory.put(factoryNames[i] = factory.getName(), factory); } context = bootstrap.getContext(); } public String [] getArtifactFactoryNames() { return factoryNames; } public Artifact getArtifact(String identifier) { return backend.getArtifact(identifier); } public Artifact createArtifactWithFactory(String factoryName) { ArtifactFactory factory = (ArtifactFactory)name2factory.get(factoryName); return factory == null ? null : backend.createArtifactWithFactory(factory, context); } public Object getArtifactContext() { return context; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: