Package io.toro.martini
Class SpringMethods
- java.lang.Object
-
- io.toro.martini.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 Summary
Constructors Constructor Description SpringMethods(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer, MartiniPackageProvider packageProvider)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addContextFile(String fileName, InputStream contents, String packageName, boolean replaceExisting)
Creates a Spring context file from anInputStream
.static void
addContextFile(String fileName, String contents, String packageName, boolean replaceExisting)
Creates a Spring context file with the providedcontents
.static Object
getBean(String beanName, String packageName)
Retrieves a bean object from the Spring context.static void
removeContextFile(String fileName, String packageName, boolean removeFiles)
Removes an existing Spring context file a package.
-
-
-
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 providedcontents
. Registers the context file to a package.- Parameters:
fileName
- the name of to-be-created Spring context filecontents
- theString
contents of the context filepackageName
- 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 invokedreplaceExisting
- 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 anInputStream
. Registers the context file to a package.- Parameters:
fileName
- the name of to-be-created Spring context filecontents
- theInputStream
containing the contents of the context filepackageName
- 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 invokedreplaceExisting
- 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 filepackageName
- 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 invokedremoveFiles
- 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 retrievepackageName
- 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
-
-