X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FConfigImpl.java;h=ae2351f97d37c2e4ae08c5dd0d7a7d5ea090352a;hb=3b2c669b25bfcb5a3c3f06ff9180d85143bebb2a;hp=a1733ab41bf84a9b84cb3986f460586871bd763e;hpb=f8027d76e1c3e517a8b80a3476f51adee845fc5b;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java index a1733ab..ae2351f 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java @@ -23,8 +23,6 @@ import java.util.HashMap; import java.util.Map; import org.wamblee.xmlrouter.common.Id; -import org.wamblee.xmlrouter.config.Config; -import org.wamblee.xmlrouter.config.ConfigException; import org.wamblee.xmlrouter.config.Identifiable; /** @@ -37,21 +35,44 @@ import org.wamblee.xmlrouter.config.Identifiable; public abstract class ConfigImpl> implements ExtendedConfig { - private Id id; + private Class type; + private String prefix; private Map, T> registered; /** * Constructs the object. */ - public ConfigImpl(Id aId) { - notNull("id", aId); - id = aId; + public ConfigImpl(Class aType, String aPrefix) { + notNull("type", aType); + notNull("id", aPrefix); + type = aType; + prefix = aPrefix; registered = new HashMap, T>(); } @Override - public Id getId() { - return id; + public Class getType() { + return type; + } + + /** + * Copies the config object. + * + * @param aConfig + * Config to copy. + */ + public ConfigImpl(ConfigImpl aConfig) { + notNull("config", aConfig); + prefix = aConfig.prefix; + registered = new HashMap, T>(); + for (Map.Entry, T> entry : aConfig.registered.entrySet()) { + registered.put(entry.getKey(), entry.getValue()); + } + } + + @Override + public String getPrefix() { + return prefix; } /* @@ -65,7 +86,7 @@ public abstract class ConfigImpl> implements if (registered.containsKey(aT.getId())) { throw new ConfigException("Duplicate id '" + aT.getId() + "'"); } - registered.put(aT.getId(), wrap(id.getId() + ".", aT)); + registered.put(aT.getId(), wrap(aT)); } /** @@ -75,7 +96,7 @@ public abstract class ConfigImpl> implements * Object to wrap. * @return Wrapped object. */ - public abstract T wrap(String aPrefix, T aT); + public abstract T wrap(T aT); /* * (non-Javadoc)