# initializeExistingPod method

1. @protected

Future<Object> initializeExistingPod(

1. Object existing,
2. Class podClass,
3. String podName

)

Initializes an existing pod instance by applying post-processors and calling initialization methods.

@param existing The pod instance to initialize @param podClass The class of the pod @param podName The name of the pod @return The initialized pod instance

## Implementation

    @protected
    Future<Object> initializeExistingPod(Object existing, Class podClass, String podName) async {
      Object wrappedPod = existing;

      // Apply before-initialization post-processors
      wrappedPod = await applyBeforeInitializationProcessing(existing, podName, podClass);

      // Call initialization methods
      PodDefinition? root = containsDefinition(podName) ? getDefinition(podName) : null;

      try {
        await _initMethodsManager.invokeInitMethods(podName, wrappedPod, root);
      } catch (e) {
        final message = e is Throwable ? e.getMessage() : e.toString();
        final exception = e is Throwable ? e : RuntimeException(e.toString());

        throw PodCreationException.withResource(root?.description, podName, message, cause: exception);
      }

      // Apply after-initialization post-processors
      wrappedPod = await applyAfterInitializationProcessing(wrappedPod, podName, podClass);

      return wrappedPod;
    }