Class SpringMethods


  • public final class SpringMethods
    extends Object

    Provides one-liners for performing Spring specific operations. Included in this class are one-liners for adding and removing Spring context files in a MartiniPackage.

    • Constructor Detail

      • SpringMethods

        @Autowired
        public SpringMethods​(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer,
                             MartiniPackageProvider packageProvider)
    • Method Detail

      • addContextFile

        public static void addContextFile​(@GloopParameter(defaultValue="spring-context.xml")
                                          String fileName,
                                          @GloopParameter(allowNull=false)
                                          String contents,
                                          String packageName,
                                          @GloopParameter(defaultValue="false")
                                          boolean replaceExisting)
        Creates a Spring context file with the provided contents. Registers the context file to a package.
        Parameters:
        fileName - the name of to-be-created Spring context file
        contents - the String contents of the context file
        packageName - the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invoked
        replaceExisting - the flag to indicate whether to replace the existing file
        Since:
        1.1
      • addContextFile

        public static void addContextFile​(@GloopParameter(defaultValue="spring-context.xml")
                                          String fileName,
                                          @GloopParameter(allowNull=false)
                                          InputStream contents,
                                          String packageName,
                                          @GloopParameter(defaultValue="false")
                                          boolean replaceExisting)
        Creates a Spring context file from an InputStream. Registers the context file to a package.
        Parameters:
        fileName - the name of to-be-created Spring context file
        contents - the InputStream containing the contents of the context file
        packageName - the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invoked
        replaceExisting - the flag to indicate whether to replace the existing file
        Since:
        1.1
      • removeContextFile

        public static void removeContextFile​(@GloopParameter(defaultValue="spring-context.xml")
                                             String fileName,
                                             String packageName,
                                             @GloopParameter(defaultValue="false")
                                             boolean removeFiles)
        Removes an existing Spring context file a package.
        Parameters:
        fileName - the name of the existing Spring context file
        packageName - the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invoked
        removeFiles - the flag to indicate whether to delete the context files
        Since:
        1.1
      • getBean

        public static Object getBean​(@GloopParameter(allowNull=false)
                                     String beanName,
                                     String packageName)
        Retrieves a bean object from the Spring context.
        Parameters:
        beanName - the name of the bean to retrieve
        packageName - the name of the package where the Spring context resides if empty, this will assume the name of the package where the service is invoked
        Since:
        1.1