if (extensionsForSegmentSet == null) {
final ServiceLoader<? extends RexsterExtension> extensions = ServiceLoader.load(RexsterExtension.class);
extensionsForSegmentSet = new ArrayList<RexsterExtension>();
for (RexsterExtension extension : extensions) {
final Class clazz = extension.getClass();
final ExtensionNaming extensionNaming = (ExtensionNaming) clazz.getAnnotation(ExtensionNaming.class);
// initialize the defaults
String currentExtensionNamespace = "g";
String currentExtensionName = clazz.getName();
if (extensionNaming != null) {
// naming annotation is present to try to override the defaults
// if the values are valid.
if (extensionNaming.name() != null && !extensionNaming.name().isEmpty()) {
currentExtensionName = extensionNaming.name();
}
// naming annotation is defaulted to "g" anyway but checking anyway to make sure
// no one tries to pull any funny business.
if (extensionNaming.namespace() != null && !extensionNaming.namespace().isEmpty()) {
currentExtensionNamespace = extensionNaming.namespace();
}
}
if (extensionSegmentSet.getNamespace().equals(currentExtensionNamespace)
&& extensionSegmentSet.getExtension().equals(currentExtensionName)) {