/** * Finds a component type by name. Looks for a component configuration in * context by name and returns the configured component type. * * @param name * the component name * @return the component type if found otherwise null * @throws UnifyException * if an error occurs */ protected Class<? extends UnifyComponent> findComponentType(String name) throws UnifyException { UnifyComponentConfig unifyComponentConfig = unifyComponentContext.getComponentConfig(name); if (unifyComponentConfig != null) { return unifyComponentConfig.getType(); } return null; }
/** * Gets a component type by name. Looks for a component configuration in context * by name and returns the configured component type. * * @param name * the component name * @return the component type * @throws UnifyException * if component configuration with name is not found. */ protected Class<? extends UnifyComponent> getComponentType(String name) throws UnifyException { UnifyComponentConfig unifyComponentConfig = unifyComponentContext.getComponentConfig(name); if (unifyComponentConfig == null) { throw new UnifyException(UnifyCoreErrorConstants.COMPONENT_UNKNOWN_COMP, name); } return unifyComponentConfig.getType(); }
/** * Gets the configuration for a component by name. The method gets the * configuration from the component context using the supplied name. If found, * checks if the supplied component type is assignable from the configuration * component type. * * @param componentType * the component type * @param name * the component name * @return the component configuration if found, otherwise null. * @throws UnifyException * if component configuration with name is unknown. If supplied * component type is not assignable from configuration component * type. */ protected UnifyComponentConfig getComponentConfig(Class<? extends UnifyComponent> componentType, String name) throws UnifyException { UnifyComponentConfig unifyComponentConfig = unifyComponentContext.getComponentConfig(name); if (unifyComponentConfig != null && !componentType.isAssignableFrom(unifyComponentConfig.getType())) { throw new UnifyException(UnifyCoreErrorConstants.COMPONENT_CONFIG_DIFF_TYPE, name, componentType, unifyComponentConfig.getType()); } return unifyComponentConfig; }
/** * Gets a component type by name. Looks for a component configuration in context * by name and returns the configured component type. * * @param clazz * the expected type class * @param name * the component name * @return the component type * @throws UnifyException * if an error occurs */ @SuppressWarnings("unchecked") protected <T extends UnifyComponent> Class<T> getComponentType(Class<T> clazz, String name) throws UnifyException { UnifyComponentConfig unifyComponentConfig = unifyComponentContext.getComponentConfig(name); if (unifyComponentConfig == null) { throw new UnifyException(UnifyCoreErrorConstants.COMPONENT_UNKNOWN_COMP, name); } if (!clazz.isAssignableFrom(unifyComponentConfig.getType())) { throw new UnifyException(UnifyCoreErrorConstants.CONTEXT_COMPONENT_TYPE_MISMATCH, unifyComponentConfig.getType(), clazz); } return (Class<T>) unifyComponentConfig.getType(); }