private static ObjectDefinition getExtensionObjectDefinition( ExtensionDefinitionContract extensionDefinition, String defaultApplicationId) { if (StringUtils.isBlank(extensionDefinition.getApplicationId()) && StringUtils.isNotBlank(defaultApplicationId)) { return new ObjectDefinition( extensionDefinition.getResourceDescriptor(), defaultApplicationId); } else { return new ObjectDefinition( extensionDefinition.getResourceDescriptor(), extensionDefinition.getApplicationId()); } }
public static Builder create(ExtensionDefinitionContract contract) { if (contract == null) { throw new IllegalArgumentException("contract was null"); } Builder builder = create(contract.getName(), contract.getType(), contract.getResourceDescriptor()); builder.setId(contract.getId()); builder.setApplicationId(contract.getApplicationId()); builder.setLabel(contract.getLabel()); builder.setDescription(contract.getDescription()); builder.setConfiguration(contract.getConfiguration()); builder.setVersionNumber(contract.getVersionNumber()); return builder; }
public static <T> T loadExtension( ExtensionDefinitionContract extensionDefinition, String defaultApplicationId) { T extensionService = null; // first check if the class name is a valid and available java class String resourceDescriptor = extensionDefinition.getResourceDescriptor(); ObjectDefinition extensionObjectDefinition = getExtensionObjectDefinition(extensionDefinition, defaultApplicationId); extensionService = GlobalResourceLoader.<T>getObject(extensionObjectDefinition); if (extensionService == null) { // if we can't find a class, try a service extensionService = GlobalResourceLoader.<T>getService(QName.valueOf(resourceDescriptor)); } return extensionService; }