# registerDefinition method

1. @override

Future<void> registerDefinition(

1. String podName,
2. PodDefinition podDefinition

)
override

Register a new `pod` under the given `name`.

This method adds a pod to the registry with the specified name. The pod name must be unique within the registry and follow the naming conventions established by the implementation.

`name`: The name to register the pod under. Must be unique and non-empty. Follows typical pod naming patterns. `pod`: The pod object to register. The type `T` depends on the registry implementation (PodDefinition, Object, etc.)

Throws:

- IllegalArgumentException if name is null, empty, or invalid

Example:

    // Register a pod definition
    final podDef = GenericPodDefinition.forClass(UserService);
    registry.registerDefinition('userService', podDef);

## Implementation

    @override
    Future<void> registerDefinition(String podName, PodDefinition podDefinition) async {
      if (_configurationFrozen) {
        throw PodDefinitionStoreException(
          name: podName,
          resourceDescription: podDefinition.description,
          msg: "Cannot register pod definition '$podName': factory is frozen"
        );
      }

      PodUtils.validateName(podName);

      PodDefinition? existingDefinition;
      if (containsDefinition(podName)) {
        existingDefinition = getDefinition(podName);

        if (!getAllowDefinitionOverriding()) {
          throw PodDefinitionOverrideException(podName);
        }

        _logDefinitionOverriding(podName, podDefinition, existingDefinition);

        if (podDefinition.name.isEmpty) {
          podDefinition.name = podName;
        }

        getPodRegistry().registerDefinition(podName, podDefinition);
      } else {
        if (isAlias(podName)) {
          String aliasedName = targetName(podName);

          if (!getAllowDefinitionOverriding()) {
            if (containsDefinition(aliasedName)) {
              throw PodDefinitionOverrideException(podName);
            } else {
              throw PodDefinitionStoreException(
                name: podName,
                resourceDescription: podDefinition.description,
                msg: "Cannot register pod definition for pod '$podName' when another pod is bound to the alias '$aliasedName'"
              );
            }
          } else {
            if (_logger.getIsInfoEnabled()) {
              _logger.info("Removing alias '$podName' for pod '$aliasedName' due to the registration of a new pod definition [$podDefinition] for pod '$podName'");
            }

            removeAlias(podName);
          }
        }

        if(_logger.getIsTraceEnabled()) {
          _logger.trace("Pod definition '$podName' does not exist. Attempting registration");
        }

        if (podDefinition.name.isEmpty) {
          podDefinition.name = podName;
        }

        getPodRegistry().registerDefinition(podName, podDefinition);
        _frozenPodDefinitionNames = [];
      }

      if (existingDefinition != null || containsSingleton(podName)) {
        resetDefinition(podName);
      }
    }