Class SpringSupplierSource

    • Field Detail

      • PROPERTY_ACTIVE_PROFILES

        public static final java.lang.String PROPERTY_ACTIVE_PROFILES
        PropertyValue to configure active Spring profiles.
        See Also:
        Constant Field Values
      • PROPERTY_UNLINK_CONTEXT_PROFILES

        public static final java.lang.String PROPERTY_UNLINK_CONTEXT_PROFILES
        PropertyValue to flag whether to unlink Spring profiles to Office profiles.
        See Also:
        Constant Field Values
      • CONFIGURATION_CLASS_NAME

        public static final java.lang.String CONFIGURATION_CLASS_NAME
        Name of PropertyValue for the Spring Boot configuration Class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SpringSupplierSource

        public SpringSupplierSource()
    • Method Detail

      • getManagedObject

        public static <O> O getManagedObject​(java.lang.String qualifier,
                                             java.lang.Class<? extends O> objectType)

        Obtains the bean from OfficeFloor.

        This should be used as follows:

         @Configuration
         public class SomeConfigurationOnScanPath {
         
                @Bean
                public DependencyType officeFloorDependency() {
                        return SpringSupplierSource.getManagedObject("qualifier", DependencyType.class);
                }
         }
         
        Type Parameters:
        O - Object type.
        Parameters:
        qualifier - Qualifier. May be null.
        objectType - Type of object required.
        Returns:
        Object sourced from an OfficeFloor ManagedObject.
      • captureApplicationContext

        public static <S,​E extends java.lang.Throwable> S captureApplicationContext​(java.util.function.Consumer<org.springframework.context.ConfigurableApplicationContext> capture,
                                                                                          SpringSupplierSource.SpringLoader<S,​E> loader)
                                                                                   throws E extends java.lang.Throwable

        Allows capturing the ConfigurableApplicationContext.

        Typically this is for testing to enable using Spring beans.

        Parameters:
        capture - Consumer to receive the ConfigurableApplicationContext.
        loader - SpringSupplierSource.SpringLoader.
        Returns:
        Loaded context.
        Throws:
        E - Possible failure in loading.
        E extends java.lang.Throwable
      • forceStartSpring

        public static org.springframework.context.ConfigurableApplicationContext forceStartSpring​(AvailableType[] availableTypes)
                                                                                           throws java.lang.Exception
        Forces starting Spring.
        Parameters:
        availableTypes - AvailableType instances.
        Returns:
        ConfigurableApplicationContext. null if already started.
        Throws:
        java.lang.Exception - If fails to start Spring.
      • terminate

        public void terminate()
        Description copied from interface: SupplierSource

        Terminates the supply contract.

        This should release all resources required by the supplier.