org.springframework.context

Interface ApplicationContext

    • Method Detail

      • getId

        @Nullable
        java.lang.String getId()
        Return the unique id of this application context.
        Returns:
        the unique id of the context, or null if none
      • getApplicationName

        java.lang.String getApplicationName()
        Return a name for the deployed application that this context belongs to.
        Returns:
        a name for the deployed application, or the empty String by default
      • getDisplayName

        java.lang.String getDisplayName()
        Return a friendly name for this context.
        Returns:
        a display name for this context (never null)
      • getStartupDate

        long getStartupDate()
        Return the timestamp when this context was first loaded.
        Returns:
        the timestamp (ms) when this context was first loaded
      • getParent

        @Nullable
        ApplicationContext getParent()
        Return the parent context, or null if there is no parent and this is the root of the context hierarchy.
        Returns:
        the parent context, or null if there is no parent
      • getAutowireCapableBeanFactory

        AutowireCapableBeanFactory getAutowireCapableBeanFactory()
                                                          throws java.lang.IllegalStateException
        Expose AutowireCapableBeanFactory functionality for this context.

        This is not typically used by application code, except for the purpose of initializing bean instances that live outside of the application context, applying the Spring bean lifecycle (fully or partly) to them.

        Alternatively, the internal BeanFactory exposed by the ConfigurableApplicationContext interface offers access to the AutowireCapableBeanFactory interface too. The present method mainly serves as a convenient, specific facility on the ApplicationContext interface.

        NOTE: As of 4.2, this method will consistently throw IllegalStateException after the application context has been closed. In current Spring Framework versions, only refreshable application contexts behave that way; as of 4.2, all application context implementations will be required to comply.

        Returns:
        the AutowireCapableBeanFactory for this context
        Throws:
        java.lang.IllegalStateException - if the context does not support the AutowireCapableBeanFactory interface, or does not hold an autowire-capable bean factory yet (e.g. if refresh() has never been called), or if the context has been closed already
        See Also:
        ConfigurableApplicationContext.refresh(), ConfigurableApplicationContext.getBeanFactory()