/**
  * Called whenever an instance is registered.
  *
  * @param info the key or info of the instance that was registered, null if not a component
  * @param registeredObject the instance that was registered, may be null
  */
 protected void registeredComponent(final ComponentInfo info, final Object registeredObject) {
   if (info.getAttributes().isEmpty()) {
     _logger.logDebug(" Registered component: " + info.toComponentKey());
   } else {
     _logger.logDebug(
         " Registered component: " + info.toComponentKey() + " " + info.getAttributes());
   }
 }
  /**
   * Registers a non-component object that requires closing or shutdown when the repository stops.
   *
   * <p>Certain interfaces are automatically detected. If it implements {@code InitializingBean},
   * then it will be initialized as though using {@link #initialize(InitializingBean)}.
   *
   * @param obj the object to close/shutdown, not null
   * @param methodName the method name to call, not null
   */
  public void registerLifecycleStop(final Object obj, final String methodName) {
    ArgumentChecker.notNull(obj, "object");
    ArgumentChecker.notNull(methodName, "methodName");
    checkStatus(Status.CREATING);

    initialize0(obj);
    registerLifecycle0(
        new Lifecycle() {
          @Override
          public void stop() {
            ReflectionUtils.invokeNoArgsNoException(obj, methodName);
          }

          @Override
          public void start() {}

          @Override
          public boolean isRunning() {
            return false;
          }

          @Override
          public String toString() {
            return obj.getClass().getSimpleName() + ":" + obj.toString();
          }
        });
    _logger.logDebug(" Registered lifecycle-stop: " + obj);
  }
  /**
   * Registers a non-component object implementing {@code Lifecycle}.
   *
   * <p>Certain interfaces are automatically detected. If it implements {@code InitializingBean},
   * then it will be initialized as though using {@link #initialize(InitializingBean)}.
   *
   * @param lifecycleObject the object that has a lifecycle, not null
   */
  public void registerLifecycle(final Lifecycle lifecycleObject) {
    ArgumentChecker.notNull(lifecycleObject, "lifecycleObject");
    checkStatus(Status.CREATING);

    try {
      initialize0(lifecycleObject);
      registerLifecycle0(lifecycleObject);
      _logger.logDebug(" Registered lifecycle: " + lifecycleObject);

    } catch (final RuntimeException ex) {
      _status.set(Status.FAILED);
      throw new RuntimeException("Failed during registering Lifecycle: " + lifecycleObject, ex);
    }
  }
  /**
   * Registers a non-component object implementing {@code Lifecycle}.
   *
   * <p>Certain interfaces are automatically detected. If it implements {@code InitializingBean},
   * then it will be initialized as though using {@link #initialize(InitializingBean)}.
   *
   * @param servletContextAware the object that requires a servlet context, not null
   */
  public void registerServletContextAware(final ServletContextAware servletContextAware) {
    ArgumentChecker.notNull(servletContextAware, "servletContextAware");
    checkStatus(Status.CREATING);

    try {
      initialize0(servletContextAware);
      registerServletContextAware0(servletContextAware);
      _logger.logDebug(" Registered lifecycle-stop: " + servletContextAware);

    } catch (final RuntimeException ex) {
      _status.set(Status.FAILED);
      throw new RuntimeException(
          "Failed during registering ServletContextAware: " + servletContextAware, ex);
    }
  }
  /**
   * Registers an instance that should be treated as a JMX Managed Resource.
   *
   * @param managedResource the object that should be treated as an MBean
   * @param name The fully qualified JMX ObjectName
   */
  public void registerMBean(final Object managedResource, final ObjectName name) {
    ArgumentChecker.notNull(managedResource, "managedResource");
    ArgumentChecker.notNull(name, "name");
    checkStatus(Status.CREATING);

    try {
      initialize0(managedResource);
      registerMBean0(managedResource, name);
      _logger.logDebug(" Registered mbean: " + managedResource);

    } catch (final RuntimeException ex) {
      _status.set(Status.FAILED);
      throw new RuntimeException(
          "Failed during registering ManagedResource: " + managedResource, ex);
    }
  }