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 and Description |
---|
SpringMethods(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer,
MartiniPackageProvider packageProvider) |
Modifier and Type | Method and Description |
---|---|
static void |
addContextFile(String fileName,
InputStream contents,
String packageName,
boolean replaceExisting)
Creates a Spring context file from an
InputStream . |
static void |
addContextFile(String fileName,
String contents,
String packageName,
boolean replaceExisting)
Creates a Spring context file with the provided
contents . |
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.
|
@Autowired public SpringMethods(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer, MartiniPackageProvider packageProvider)
public static void addContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, @GloopParameter(allowNull=false) String contents, String packageName, @GloopParameter(defaultValue="false") boolean replaceExisting)
contents
. Registers the context file to a package.fileName
- the name of to-be-created Spring context filecontents
- the String
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 filepublic static void addContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, @GloopParameter(allowNull=false) InputStream contents, String packageName, @GloopParameter(defaultValue="false") boolean replaceExisting)
InputStream
. Registers the context file to a package.fileName
- the name of to-be-created Spring context filecontents
- the InputStream
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 filepublic static void removeContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, String packageName, @GloopParameter(defaultValue="false") boolean removeFiles)
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 filespublic static Object getBean(@GloopParameter(allowNull=false) String beanName, String packageName)
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 invokedCopyright © 2023. All rights reserved.