*/
package org.wamblee.xmlrouter.impl;
+import static org.wamblee.xmlrouter.impl.MessageUtil.*;
+
import java.util.logging.Level;
import java.util.logging.Logger;
import org.wamblee.xmlrouter.common.Id;
+import org.wamblee.xmlrouter.config.ConfigException;
import org.wamblee.xmlrouter.config.Identifiable;
/**
// TODO test that id is constant even though delegated changes its id.
public RobustIdentifiable(String aPrefix, Identifiable<T> aIdentifiable) {
+ notNull("prefix", aPrefix);
+ notNull("identifiable", aIdentifiable);
// TODO test id is null
// TODO getId() throws exception
try {
id = aIdentifiable.getId();
if (id == null) {
- id = new Id<T>(Constants.UNKNOWN_ID.toString());
- temporarilyThrowException();
- } else {
- id = new Id<T>(aPrefix + id.getId());
+ throwConfigException("identifiable.getId() returned null", null);
}
+ id = new Id<T>(aPrefix + id.getId());
} catch (Exception e) {
- LOGGER
- .log(Level.WARNING, "Identifiable getId() threw exception", e);
+ throwConfigException("identifiable.getId() threw exception", e);
}
}
- private void temporarilyThrowException() {
- throw new RuntimeException(
- "Temporary to catch nulls during refactoring");
+ private void throwConfigException(String aMsg, Exception aException) {
+ LOGGER.log(Level.WARNING, aMsg, aException);
+ throw new ConfigException("id is null");
}
@Override