package org.glassfish.grizzly.attributes;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.grizzly.Grizzly;
class AttributeBuilderInitializer {
private static final String PROP = "org.glassfish.grizzly.DEFAULT_ATTRIBUTE_BUILDER";
private static final Logger LOGGER = Grizzly.logger(AttributeBuilderInitializer.class);
@SuppressWarnings("unchecked")
static AttributeBuilder initBuilder() {
final String className = System.getProperty(PROP);
if (className != null) {
try {
Class<? extends AttributeBuilder> builderClass = (Class<? extends AttributeBuilder>) Class.forName(className, true,
AttributeBuilder.class.getClassLoader());
return builderClass.newInstance();
} catch (Exception e) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE, "Unable to load or create a new instance of AttributeBuilder {0}. Cause: {1}",
new Object[] { className, e.getMessage() });
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, e.toString(), e);
}
return new DefaultAttributeBuilder();
}
}
return new DefaultAttributeBuilder();
}
}