/** * Creates a new item of type {@code itemType} by utilizing an appropriate {@link ItemFactory}. * * @param itemType The type to find the appropriate {@link ItemFactory} for. * @param itemName The name of the {@link Item} to create. * @return An Item instance of type {@code itemType} null if no item factory for it was found. */ private GenericItem createItemOfType(String itemType, String itemName) { if (itemType == null) { return null; } for (ItemFactory factory : itemFactorys) { GenericItem item = factory.createItem(itemType, itemName); if (item != null) { logger.trace("Created item '{}' of type '{}'", itemName, itemType); return item; } } logger.debug("Couldn't find ItemFactory for item '{}' of type '{}'", itemName, itemType); return null; }
/** * Add another instance of an {@link ItemFactory}. Used by Declarative Services. * * @param factory The {@link ItemFactory} to add. */ public void addItemFactory(ItemFactory factory) { itemFactorys.add(factory); dispatchBindingsPerItemType(null, factory.getSupportedItemTypes()); }